Wed, 23 Sep 2020 22:21:50 +0300
#176 ModifyPositionAndSize and similar modification functionality
#7 Scrollbar template
#7 Partial working scrollbar
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

1  #pragma once 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

2  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

3  #include "Common.h" 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

4  #include "../UI/ComponentStackWidget.h" 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

5  #include "../UI/Helpers.h" 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

6  #include "../Property.h" 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

7  #include "Registry.h" 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

8  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

9  namespace Gorgon { namespace Widgets { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

10  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

11  /** 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

12  * This is an internal basis for slider. It is not very useful by its 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

13  * own as many of its functions are protected. It is used as a base 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

14  * for Slider, Progressbar (not yet), and Scrollbar widgets. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

15  */ 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

16  template< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

17  class T_ = int, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

18  float(*DIV_)(T_, T_, T_) = FloatDivider<T_>, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

19  T_(*VAL_)(float, T_, T_) = FloatToValue<T_>, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

20  template<class C_, class PT_, PT_(C_::*Getter_)() const, void(C_::*Setter_)(const PT_ &)> class P_ = Gorgon::NumericProperty, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

21  bool interactive = false 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

22  > 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

23  class SliderBase: 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

24  public UI::ComponentStackWidget, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

25  public P_< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

26  UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

27  T_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

28  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::get_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

29  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::set_ 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

30  > 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

31  { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

32  public: 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

33  using Type = T_; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

34  using PropType = P_< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

35  UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

36  T_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

37  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::get_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

38  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::set_ 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

39  >; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

40  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

41  friend class P_< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

42  UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

43  T_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

44  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::get_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

45  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>::set_ 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

46  >; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

47  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

48  template< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

49  class T1_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

50  float(*DIV1_)(T1_, T1_, T1_), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

51  T1_(*VAL1_)(float, T1_, T1_), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

52  template< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

53  class C_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

54  class PT_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

55  PT_(C_::*Getter_)() const, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

56  void(C_::*Setter_)(const PT_&) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

57  > class P1_, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

58  bool I2_ 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

59  > 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

60  friend class SliderBase; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

61  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

62  friend struct UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

63  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

64  SliderBase(const SliderBase &) = delete; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

65  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

66  explicit SliderBase(T_ cur, T_ max, Registry::TemplateType type = Registry::Progress_Regular) : 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

67  SliderBase(Registry::Active()[type], cur, max) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

68  { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

69  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

70  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

71  explicit SliderBase(T_ cur = T_{}, Registry::TemplateType type = Registry::Progress_Regular) : 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

72  SliderBase(Registry::Active()[type], cur) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

73  { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

74  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

75  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

76  explicit SliderBase(const UI::Template &temp, T_ cur = T_{}) : SliderBase(temp, cur, T_{100}) { } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

77  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

78  SliderBase(const UI::Template &temp, T_ cur, T_ max) : 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

79  ComponentStackWidget(temp), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

80  PropType(&helper), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

81  Maximum(this), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

82  Minimum(this), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

83  Range(this), 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

84  value(cur), max(max) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

85  { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

86  refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

87  stack.SetValueTransitionSpeed({changespeed, 0, 0, 0}); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

88  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

89  if(interactive) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

90  stack.HandleMouse(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

91  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

92  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

93  protected: //these methods are here to be elevated to public if necessary. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

94  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

95  /// Sets the maximum value that this slider reaches up to. If equal to minimum, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

96  /// progress will display 0. SliderBase will always keep the value between minimum 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

97  /// and maximum. If maximum is less than minimum, this function will automatically 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

98  /// exchange these values. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

99  void SetMaximum(const T_ &value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

100  if(value < min) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

101  max = min; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

102  min = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

103  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

104  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

105  max = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

106  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

107  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

108  if(!setval(this>value)) //if returns true, refresh is already called 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

109  refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

110  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

111  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

112  /// Returns the current maximum value. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

113  T_ GetMaximum() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

114  return max; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

115  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

116  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

117  /// Sets the minimum value that this slider reaches up to. If equal to maximum, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

118  /// progress will display 0. SliderBase will always keep the value between minimum 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

119  /// and maximum. If maximum is less than minimum, this function will automatically 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

120  /// exchange these values. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

121  void SetMinimum(const T_ &value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

122  if(value > max) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

123  min = max; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

124  max = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

125  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

126  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

127  min = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

128  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

129  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

130  if(!setval(this>value)) //if returns true, refresh is already called 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

131  refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

132  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

133  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

134  /// Sets minimum and maximum limits. If minimum is equal to maximum, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

135  /// progress will display 0. SliderBase will always keep the value between minimum 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

136  /// and maximum. If maximum is less than minimum, this function will automatically 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

137  /// exchange these values if exchange is set. If exchange is not set, they will both 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

138  /// be set to T_{}, effectively locking progress at 0. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

139  void SetLimits(T_ min, T_ max, bool exchange = true) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

140  if(min > max) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

141  if(exchange) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

142  using std::swap; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

143  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

144  swap(min, max); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

145  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

146  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

147  min = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

148  max = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

149  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

150  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

151  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

152  this>min = min; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

153  this>max = max; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

154  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

155  if(setval(this>value)) //if returns true, refresh is already called 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

156  refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

157  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

158  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

159  /// Returns the current minimum value. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

160  T_ GetMinimum() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

161  return min; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

162  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

163  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

164  /// Sets the current value of the slider 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

165  SliderBase &operator =(T_ value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

166  set(value); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

167  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

168  return *this; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

169  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

170  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

171  /// Sets the range the container can display. This is used to show how 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

172  /// much more the scroller can be scrolled. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

173  void SetRange(const T_ &value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

174  range = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

175  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

176  if(range < this>min) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

177  range = this>min; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

178  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

179  if(range > this>max) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

180  range = this>max; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

181  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

182  this>refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

183  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

184  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

185  /// Returns the range the container can display. This is used to show 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

186  /// how much more the scroller can be scrolled. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

187  T_ GetRange() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

188  return range; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

189  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

190  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

191  /// Returns the current value of the slider 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

192  operator T_() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

193  return get(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

194  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

195  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

196  virtual bool Activate() override { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

197  return Focus(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

198  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

199  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

200  /// Disables smooth change 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

201  void DisableSmoothChange() { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

202  SetSmoothChangeSpeed(0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

203  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

204  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

205  /// Adjusts the smooth change speed. Given value is in values per second, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

206  /// default value is max and will be sync to the maximum value. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

207  void SetSmoothChangeSpeed(T_ value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

208  SetSmoothChangeSpeedRatio(DIV_(value, min, max)); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

209  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

210  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

211  /// Adjusts the smooth change speed. Given value is in values per second, 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

212  /// default value is 1 and will be sync to the maximum value. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

213  void SetSmoothChangeSpeedRatio(float value) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

214  changespeed = value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

215  stack.SetValueTransitionSpeed({value, 0, 0, 0}); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

216  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

217  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

218  /// Returns the smooth change speed. If smooth change is disabled, this 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

219  /// value will be 0. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

220  T_ GetSmoothChangeSpeed() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

221  return changespeed * (max  min); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

222  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

223  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

224  /// Returns the smooth change in ratio to the maximum. 1 means full progress 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

225  /// will be done in 1 second. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

226  float GetSmoothChangeSpeedRatio() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

227  return changespeed; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

228  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

229  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

230  /// Returns if the smooth change is enabled. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

231  bool IsSmoothChangeEnabled() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

232  return changespeed != 0; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

233  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

234  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

235  /// This property controls the maximum value that the slider can have 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

236  NumericProperty<SliderBase, T_, &SliderBase::GetMaximum, &SliderBase::SetMaximum> Maximum; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

237  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

238  /// This property controls the minimum value that the slider can have 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

239  NumericProperty<SliderBase, T_, &SliderBase::GetMinimum, &SliderBase::SetMinimum> Minimum; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

240  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

241  /// This is used to show how much more the scroller can be scrolled. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

242  NumericProperty<SliderBase, T_, &SliderBase::GetRange, &SliderBase::SetRange> Range; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

243  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

244  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

245  protected: 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

246  virtual bool allowfocus() const override { return false; } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

247  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

248  /// Returns the value in the box 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

249  T_ get() const { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

250  return value; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

251  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

252  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

253  /// Changes the value in the box 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

254  void set(const T_ &val) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

255  setval(val); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

256  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

257  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

258  bool setval(T_ val) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

259  if(val > max) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

260  val = max; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

261  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

262  if(val < min) 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

263  val = min; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

264  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

265  if(value != val) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

266  value = val; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

267  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

268  valuechanged(value); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

269  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

270  refreshvalue(); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

271  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

272  return true; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

273  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

274  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

275  return false; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

276  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

277  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

278  virtual void refreshvalue() { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

279  float val = DIV_(this>value, min, max); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

280  float val2 = DIV_(this>value+this>range, this>min, this>max); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

281  float r = DIV_(this>range, this>min, this>max); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

282  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

283  stack.SetValue(val, val2, r); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

284  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

285  val = std::round(val*1000); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

286  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

287  if(val == 0) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

288  stack.AddCondition(UI::ComponentCondition::Ch1V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

289  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

290  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

291  stack.RemoveCondition(UI::ComponentCondition::Ch1V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

292  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

293  if(val == 500) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

294  stack.AddCondition(UI::ComponentCondition::Ch1V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

295  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

296  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

297  stack.RemoveCondition(UI::ComponentCondition::Ch1V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

298  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

299  if(val == 1000) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

300  stack.AddCondition(UI::ComponentCondition::Ch1V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

301  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

302  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

303  stack.RemoveCondition(UI::ComponentCondition::Ch1V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

304  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

305  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

306  val2 = std::round(val2*1000); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

307  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

308  if(val2 == 0) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

309  this>stack.AddCondition(UI::ComponentCondition::Ch2V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

310  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

311  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

312  this>stack.RemoveCondition(UI::ComponentCondition::Ch2V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

313  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

314  if(val2 == 500) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

315  this>stack.AddCondition(UI::ComponentCondition::Ch2V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

316  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

317  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

318  this>stack.RemoveCondition(UI::ComponentCondition::Ch2V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

319  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

320  if(val2 == 1000) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

321  this>stack.AddCondition(UI::ComponentCondition::Ch2V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

322  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

323  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

324  this>stack.RemoveCondition(UI::ComponentCondition::Ch2V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

325  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

326  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

327  r = std::round(r*1000); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

328  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

329  if(r == 0) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

330  this>stack.AddCondition(UI::ComponentCondition::Ch3V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

331  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

332  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

333  this>stack.RemoveCondition(UI::ComponentCondition::Ch3V0); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

334  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

335  if(r == 500) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

336  this>stack.AddCondition(UI::ComponentCondition::Ch3V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

337  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

338  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

339  this>stack.RemoveCondition(UI::ComponentCondition::Ch3V05); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

340  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

341  if(r == 1000) { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

342  this>stack.AddCondition(UI::ComponentCondition::Ch3V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

343  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

344  else { 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

345  this>stack.RemoveCondition(UI::ComponentCondition::Ch3V1); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

346  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

347  } 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

348  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

349  T_ value = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

350  T_ min = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

351  T_ max = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

352  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

353  //this is range that is covered by the scrollbar 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

354  T_ range = T_{}; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

355  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

356  float changespeed = 1; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

357  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

358  virtual void valuechanged(T_) = 0; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

359  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

360  private: 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

361  struct UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_> helper = UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive>, T_>(this); 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

362  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

363  }; 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

364  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

365  
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

366  } } 