1 /* 2 Copyright (C) 2002-2013 Nikolaus Gebhardt 3 This file is part of the "Irrlicht Engine". 4 For conditions of distribution and use, see copyright notice in irrlicht.h 5 6 Modified 2019.05.01 by stujones11, Stuart Jones <stujones111@gmail.com> 7 8 This is a heavily modified copy of the Irrlicht CGUIScrollBar class 9 which includes automatic scaling of the thumb slider and hiding of 10 the arrow buttons where there is insufficient space. 11 */ 12 13 #pragma once 14 15 #include "irrlichttypes_extrabloated.h" 16 17 using namespace irr; 18 using namespace gui; 19 20 class GUIScrollBar : public IGUIElement 21 { 22 public: 23 GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id, 24 core::rect<s32> rectangle, bool horizontal, bool auto_scale); 25 26 enum ArrowVisibility 27 { 28 HIDE, 29 SHOW, 30 DEFAULT 31 }; 32 33 virtual void draw(); 34 virtual void updateAbsolutePosition(); 35 virtual bool OnEvent(const SEvent &event); 36 getMax()37 s32 getMax() const { return max_pos; } getMin()38 s32 getMin() const { return min_pos; } getLargeStep()39 s32 getLargeStep() const { return large_step; } getSmallStep()40 s32 getSmallStep() const { return small_step; } 41 s32 getPos() const; 42 43 void setMax(const s32 &max); 44 void setMin(const s32 &min); 45 void setSmallStep(const s32 &step); 46 void setLargeStep(const s32 &step); 47 void setPos(const s32 &pos); 48 void setPageSize(const s32 &size); 49 void setArrowsVisible(ArrowVisibility visible); 50 51 private: 52 void refreshControls(); 53 s32 getPosFromMousePos(const core::position2di &p) const; range()54 f32 range() const { return f32(max_pos - min_pos); } 55 56 IGUIButton *up_button; 57 IGUIButton *down_button; 58 ArrowVisibility arrow_visibility = DEFAULT; 59 bool is_dragging; 60 bool is_horizontal; 61 bool is_auto_scaling; 62 bool dragged_by_slider; 63 bool tray_clicked; 64 s32 scroll_pos; 65 s32 draw_center; 66 s32 thumb_size; 67 s32 min_pos; 68 s32 max_pos; 69 s32 small_step; 70 s32 large_step; 71 s32 drag_offset; 72 s32 page_size; 73 s32 border_size; 74 75 core::rect<s32> slider_rect; 76 video::SColor current_icon_color; 77 }; 78