Wed, 07 Oct 2020 20:33:51 +0300
#192 Size parsing bug
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  
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

9  #include <limits> 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

12  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

13  /// @cond internal 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

14  namespace internal { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

15  enum class SliderInteractivity { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

16  None, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

17  HandleOnly = 1, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

18  DualHandle = 2, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

19  Jump = 4, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

20  Page = 8, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

21  HandleAndJump = HandleOnly  Jump, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

22  HandleAndPage = HandleOnly  Page, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

23  DualHandleAndJump = DualHandle  Jump, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

24  DualHandleAndPage = DualHandle  Page, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

25  }; 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

26  
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

27  enum class SliderValueMapping { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

28  OneValue = 1, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

29  TwoValues = 2, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

30  ValueAndRange = 3 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

31  }; 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

32  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

33  inline bool operator &(SliderInteractivity l, SliderInteractivity r) { return (int(l)&int(r)) != 0; } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

34  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

35  ///@endcond 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

38  * 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

39  * 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

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

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

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

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

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

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

46  template<class C_, class PT_, PT_(C_::*Getter_)() const, void(C_::*Setter_)(const PT_ &)> class P_ = Gorgon::NumericProperty, 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

47  internal::SliderInteractivity interactive = internal::SliderInteractivity::None, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

48  internal::SliderValueMapping valuemapping = internal::SliderValueMapping::OneValue 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

53  public P_< 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

55  T_, 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

56  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive, valuemapping>, T_>::get_, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

62  using PropType = P_< 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

64  T_, 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

65  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive, valuemapping>, T_>::get_, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

69  friend class P_< 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

71  T_, 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

72  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive, valuemapping>, T_>::get_, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

73  &UI::internal::prophelper<SliderBase<T_, DIV_, VAL_, P_, interactive, valuemapping>, T_>::set_ 
1449
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  template< 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

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

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

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

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

85  > class P1_, 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

86  internal::SliderInteractivity I2_, 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

87  internal::SliderValueMapping V2_ 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

90  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

105  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

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

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

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

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

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

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

112  Range(this), 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

113  SmallChange(this), 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

114  LargeChange(this), 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

119  
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

120  setupinteractivity(); 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

124  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

125  /// Sets the current value of the slider. If instant is set to true, the value 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

126  /// will be set instantly without any animations. 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

127  void SetValue(const T_ &value, bool instant = false) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

128  setval(value, instant); 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

129  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

130  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

131  /// Gets the current value of the slider 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

132  T_ GetValue() const { 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

133  return this>operator T_(); 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

134  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

136  /// Sets the maximum value that this slider reaches up to. If equal to minimum, 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

137  /// progress will display 0. 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

138  void SetMaximum(const T_ &value) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

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

140  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

141  if(valuemapping == internal::SliderValueMapping::ValueAndRange) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

142  SetSmoothChangeSpeedRatio(changespeed); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

143  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

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

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

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

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

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

154  /// Sets the minimum value that this slider reaches up to. If equal to maximum, 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

155  /// progress will display 0. 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

156  void SetMinimum(const T_ &value) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

157  min = value; 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

158  
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

159  if(valuemapping == internal::SliderValueMapping::ValueAndRange) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

160  SetSmoothChangeSpeedRatio(changespeed); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

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

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

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

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

170  /// exchange these values if exchange is set. If exchange is not set, they will both 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

171  /// be set to T_{}, effectively locking progress at 0. Do not use this function if 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

172  /// your type is not a regular numeric type 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

173  void SetLimits(T_ min, T_ max, bool exchange = true) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

174  if(exchange && min > max) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

175  using std::swap; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

176  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

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

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

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

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

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

182  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

183  if(valuemapping == internal::SliderValueMapping::ValueAndRange) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

184  SetSmoothChangeSpeedRatio(changespeed); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

185  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

188  refreshvalue(); 
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 minimum value. 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

193  return min; 
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  /// Sets the current value of the slider 
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

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

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

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

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

205  void SetRange(const T_ &value) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

206  auto r = DIV_(value, min, max); 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

207  
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

208  if(r < 0) 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

209  range = this>min; 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

210  else if(r > 1) 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

211  range = this>max; 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

212  else 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

213  range = value; 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

214  
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

215  if(valuemapping == internal::SliderValueMapping::ValueAndRange) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

216  SetSmoothChangeSpeedRatio(changespeed); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

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

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

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

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

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

227  
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

228  /// Sets the amount of change on a small change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

229  /// click of arrow buttons, keyboard keys or mouse scroll. 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

230  void SetSmallChange(const T_ &value) { 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

231  smallchange = value; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

232  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

233  this>refreshvalue(); 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

234  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

235  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

236  /// Returns the amount of change on a small change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

237  /// click of bar or keyboard keys (page up/down) 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

238  T_ GetSmallChange() const { 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

239  return smallchange; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

240  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

241  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

242  /// Sets the amount of change on a large change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

243  /// click of bar or keyboard keys (page up/down). 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

244  void SetLargeChange(const T_ &value) { 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

245  largechange = value; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

246  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

247  this>refreshvalue(); 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

248  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

249  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

250  /// Returns the amount of change on a large change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

251  /// click of arrow buttons, keyboard keys or mouse scroll. 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

252  T_ GetLargeChange() const { 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

253  return largechange; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

254  } 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

279  changespeed = value; 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

280  if(valuemapping == internal::SliderValueMapping::OneValue) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

281  stack.SetValueTransitionSpeed({value, 0, 0, 0}); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

282  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

283  else if(valuemapping == internal::SliderValueMapping::ValueAndRange) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

284  auto r = DIV_(range, min, max); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

285  auto m = DIV_(max, min, max); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

286  if(m == 0  r == 1) { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

287  stack.SetValueTransitionSpeed({value, 0, 0, 0}); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

288  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

289  else { 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

290  stack.SetValueTransitionSpeed({value / (1  r), 0, 0, 0}); 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

291  } 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

297  T_ GetSmoothChangeSpeed() const { 
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

298  return FloatToValue(changespeed, min, max); 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

320  
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

321  /// Controls the amount of change on a small change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

322  /// click of arrow buttons, keyboard keys or mouse scroll. 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

323  NumericProperty<SliderBase, T_, &SliderBase::GetSmallChange, &SliderBase::SetSmallChange> SmallChange; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

324  
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

325  /// Controls the amount of change on a large change action. This action could be 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

326  /// click of bar or keyboard keys (page up/down). 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

327  NumericProperty<SliderBase, T_, &SliderBase::GetLargeChange, &SliderBase::SetLargeChange> LargeChange; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

342  
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

343  template<internal::SliderValueMapping vm = valuemapping> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

344  typename std::enable_if<vm == internal::SliderValueMapping::ValueAndRange, T_>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

345  actualmax() { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

346  return max  range; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

347  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

348  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

349  template<internal::SliderValueMapping vm = valuemapping> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

350  typename std::enable_if<vm != internal::SliderValueMapping::ValueAndRange, T_>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

351  actualmax() { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

352  return max; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

353  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

354  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

355  bool setval(T_ val, bool instant = false) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

356  auto v = DIV_(val, min, actualmax()); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

357  if(v < 0) 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

358  val = min; 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

359  if(v > 1) 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

360  val = actualmax(); 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

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

366  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

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

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

374  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

375  virtual void refreshvalue(bool instant = false) { 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

376  refreshme(instant); 
1449
db5111962661
#176 ModifyPositionAndSize and similar modification functionality
cemkalyoncu
parents:
diff
changeset

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

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

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

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

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

382  
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

383  //TODO move these out 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

384  T_ smallchange = T_{1}; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

385  T_ largechange = T_{10}; 
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

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

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

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

391  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

392  internal::SliderInteractivity grab = internal::SliderInteractivity::None; 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

393  Geometry::Point downlocation = {0, 0}; 
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

394  float downvalue = 0; 
1450
0c2bcf1bf63a
#183 ComponentStack CoordinateToValue is fixed
cemkalyoncu
parents:
1449
diff
changeset

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

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

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

398  private: 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

399  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

400  template<internal::SliderValueMapping vm = valuemapping> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

401  typename std::enable_if<vm == internal::SliderValueMapping::OneValue, void>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

402  refreshme(bool instant = false) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

403  float val = DIV_(this>value, min, max); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

404  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

405  stack.SetValue(val, 0, 0, instant); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

406  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

407  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

408  template<internal::SliderValueMapping vm = valuemapping> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

409  typename std::enable_if<vm == internal::SliderValueMapping::ValueAndRange, void>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

410  refreshme(bool instant = false) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

411  float val = DIV_(this>value, this>min, this>maxthis>range); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

412  float v1 = DIV_(this>value, this>min, this>max); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

413  float v2 = DIV_(this>value+this>range, this>min, this>max); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

414  float r = DIV_(this>range, this>min, this>max); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

415  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

416  if(DIV_(max, min, max) == 0) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

417  r = 1; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

418  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

419  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

420  stack.SetValue(val, v1, v2, r, instant); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

421  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

422  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

423  template<internal::SliderInteractivity si = interactive> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

424  typename std::enable_if<si == internal::SliderInteractivity::None, void>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

425  setupinteractivity() { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

426  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

427  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

428  //TODO distribute according to actual interactivity 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

429  template<internal::SliderInteractivity si = interactive> 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

430  typename std::enable_if<si != internal::SliderInteractivity::None, void>::type 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

431  setupinteractivity() { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

432  stack.HandleMouse(); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

433  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

434  stack.SetClickEvent([this](auto tag, auto location, auto btn) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

435  if(tag == UI::ComponentTemplate::NoTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

436  auto ind = stack.ComponentAt(location); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

437  if(ind != 1) 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

438  tag = stack.GetTemplate(ind).GetTag(); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

439  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

440  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

441  if(btn == Input::Mouse::Button::Left) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

442  if((interactive & internal::SliderInteractivity::Jump) && tag == UI::ComponentTemplate::DragBarTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

443  auto val = stack.CoordinateToValue(UI::ComponentTemplate::DragTag, location)[0]; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

444  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

445  if(val == std::numeric_limits<float>::infinity()) 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

446  return; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

447  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

448  val = Clamp(val, 0.f, 1.f); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

449  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

450  setval(VAL_(val, this>min, this>max)); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

451  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

452  if((interactive & internal::SliderInteractivity::Page)) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

453  if(tag == UI::ComponentTemplate::DragBarTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

454  auto val = stack.CoordinateToValue(UI::ComponentTemplate::DragTag, location)[0]; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

455  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

456  auto curval = DIV_(value, this>min, this>max); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

457  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

458  if(val > curval) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

459  SetValue(GetValue() + largechange); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

460  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

461  else if(val < curval) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

462  SetValue(GetValue()  largechange); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

463  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

464  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

465  else if(tag == UI::ComponentTemplate::IncrementTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

466  SetValue(GetValue() + largechange); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

467  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

468  else if(tag == UI::ComponentTemplate::DecrementTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

469  SetValue(GetValue()  largechange); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

470  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

471  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

472  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

473  }); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

474  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

475  stack.SetMouseDownEvent([this](auto tag, auto location, auto btn) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

476  if(tag == UI::ComponentTemplate::NoTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

477  auto ind = stack.ComponentAt(location); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

478  if(ind != 1) 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

479  tag = stack.GetTemplate(ind).GetTag(); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

480  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

481  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

482  if((interactive & internal::SliderInteractivity::HandleOnly)) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

483  if(tag == UI::ComponentTemplate::DragTag) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

484  if(btn == Input::Mouse::Button::Left) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

485  downlocation = location; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

486  downvalue = stack.GetValue()[0]; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

487  grab = internal::SliderInteractivity::HandleOnly; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

488  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

489  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

490  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

491  }); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

492  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

493  stack.SetMouseUpEvent([this](auto, auto, auto btn) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

494  if(btn == Input::Mouse::Button::Left) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

495  grab = internal::SliderInteractivity::None; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

496  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

497  }); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

498  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

499  stack.SetMouseMoveEvent([this](UI::ComponentTemplate::Tag, Geometry::Point location) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

500  if((interactive & internal::SliderInteractivity::HandleOnly) && grab == internal::SliderInteractivity::HandleOnly) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

501  auto val = stack.CoordinateToValue(UI::ComponentTemplate::DragTag, location  downlocation, true)[0]; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

502  if(val == std::numeric_limits<float>::infinity()) 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

503  return; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

504  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

505  val += downvalue; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

506  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

507  val = Clamp(val, 0.f, 1.f); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

508  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

509  setval(VAL_(val, this>min, this>max)); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

510  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

511  }); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

512  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

513  stack.SetOtherMouseEvent([this](UI::ComponentTemplate::Tag, Input::Mouse::EventType type, Geometry::Point, float amount) { 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

514  if(type == Input::Mouse::EventType::Scroll_Vert  type == Input::Mouse::EventType::Scroll_Hor) { 
1461  515  SetValue(T_(GetValue()  amount * smallchange)); 
1455
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

516  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

517  return true; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

518  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

519  
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

520  return false; 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

521  }); 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

522  } 
1cd168e97418
#182: Progressbar is now derived from SliderBase
cemkalyoncu
parents:
1454
diff
changeset

523  
1454
829e7660e0c2
#185 Component stack allows widgets embedded in it
cemkalyoncu
parents:
1450
diff
changeset

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

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

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

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

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

529  } } 