Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_widgets.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_WIDGETS_H
7 #define TB_WIDGETS_H
8 
9 #include "tb_core.h"
10 #include "tb_geometry.h"
11 #include "tb_skin.h"
12 #include "tb_linklist.h"
13 #include "tb_widget_value.h"
14 #include "tb_object.h"
15 #include "tb_font_desc.h"
16 
17 namespace tb {
18 
19 class TBWindow;
20 class TBWidget;
21 class TBFontFace;
22 class TBScroller;
23 class TBWidgetListener;
24 class TBLongClickTimer;
25 struct INFLATE_INFO;
26 
27 // == Generic widget stuff =================================================
28 
29 enum TB_ALIGN {
34 };
35 
36 enum EVENT_TYPE {
46 
55  EVENT_TYPE_POINTER_DOWN,
56  EVENT_TYPE_POINTER_UP,
57  EVENT_TYPE_POINTER_MOVE,
58  EVENT_TYPE_WHEEL,
59 
60  EVENT_TYPE_MULTI_GESTURE,
61 
62  EVENT_TYPE_FINGER_DOWN,
63  EVENT_TYPE_FINGER_UP,
64  EVENT_TYPE_FINGER_MOVE,
69  EVENT_TYPE_KEY_DOWN,
70  EVENT_TYPE_KEY_UP,
71 
78 
83 
87 
90 };
91 
92 enum MODIFIER_KEYS {
93  TB_MODIFIER_NONE = 0,
94  TB_CTRL = 1,
95  TB_SHIFT = 2,
96  TB_ALT = 4,
97  TB_SUPER = 8
98 };
99 MAKE_ENUM_FLAG_COMBO(MODIFIER_KEYS);
100 
101 enum SPECIAL_KEY
102 {
103  TB_KEY_UNDEFINED = 0,
104  TB_KEY_UP, TB_KEY_DOWN, TB_KEY_LEFT, TB_KEY_RIGHT,
105  TB_KEY_PAGE_UP, TB_KEY_PAGE_DOWN, TB_KEY_HOME, TB_KEY_END,
106  TB_KEY_TAB, TB_KEY_BACKSPACE, TB_KEY_INSERT, TB_KEY_DELETE,
107  TB_KEY_ENTER, TB_KEY_ESC,
108  TB_KEY_F1, TB_KEY_F2, TB_KEY_F3, TB_KEY_F4, TB_KEY_F5, TB_KEY_F6,
109  TB_KEY_F7, TB_KEY_F8, TB_KEY_F9, TB_KEY_F10, TB_KEY_F11, TB_KEY_F12
110 };
111 
113 {
114 public:
117  int target_x;
118  int target_y;
119  int delta_x;
120  int delta_y;
121  int count;
122  int key;
127  SPECIAL_KEY special_key;
130  MODIFIER_KEYS modifierkeys;
132  bool touch;
133 
135  TBOBJECT_SUBCLASS(TBWidgetEvent, TBTypedObject);
136 
137  TBWidgetEvent(EVENT_TYPE type) : target(nullptr), type(type), target_x(0), target_y(0), delta_x(0), delta_y(0), count(1),
138  key(0), special_key(TB_KEY_UNDEFINED), modifierkeys(TB_MODIFIER_NONE), touch(false) {}
139 
140  TBWidgetEvent(EVENT_TYPE type, int x, int y, bool touch, MODIFIER_KEYS modifierkeys = TB_MODIFIER_NONE) :
141  target(nullptr), type(type), target_x(x), target_y(y), delta_x(0), delta_y(0),
142  count(1), key(0), special_key(TB_KEY_UNDEFINED), modifierkeys(modifierkeys),
143  touch(touch) {}
144 
148  int GetCountCycle(int max) { return ((count - 1) % max) + 1; }
149 
150  bool IsPointerEvent() const { return type == EVENT_TYPE_POINTER_DOWN ||
151  type == EVENT_TYPE_POINTER_UP ||
152  type == EVENT_TYPE_POINTER_MOVE; }
153  bool IsKeyEvent() const { return type == EVENT_TYPE_KEY_DOWN ||
154  type == EVENT_TYPE_KEY_UP; }
155 };
156 
161 {
162 public:
163  float center_x;
164  float center_y;
165  float dTheta;
166  float dDist;
167 
168  TBOBJECT_SUBCLASS(TBWidgetEventMultiGesture, TBWidgetEvent);
169 
170  TBWidgetEventMultiGesture(int target_x, int target_y, float cx, float cy, float dTheta, float dDist, uint16_t numFingers)
171  : TBWidgetEvent(EVENT_TYPE_MULTI_GESTURE, target_x, target_y, 1),
172  center_x(cx), center_y(cy), dTheta(dTheta), dDist(dDist)
173  {
174  count = numFingers;
175  }
176 };
177 
188 {
189 public:
190  float x;
191  float y;
192  float dx;
193  float dy;
194 
195  TBOBJECT_SUBCLASS(TBWidgetEventFinger, TBWidgetEvent);
196 
197  TBWidgetEventFinger(EVENT_TYPE type, int target_x, int target_y, float x, float y, float dx, float dy, int fingerid)
198  : TBWidgetEvent(type, target_x, target_y, 1), x(x), y(y), dx(dx), dy(dy)
199  {
200  //count = numFingers;
201  key = fingerid;
202  }
203 };
204 
208 {
209 public:
211 
212  TBOBJECT_SUBCLASS(TBWidgetEventFileDrop, TBWidgetEvent);
213 
215 };
216 
220  WIDGET_STATE_NONE = 0,
221  WIDGET_STATE_DISABLED = 1,
222  WIDGET_STATE_FOCUSED = 2,
223  WIDGET_STATE_PRESSED = 4,
224  WIDGET_STATE_SELECTED = 8,
225  WIDGET_STATE_HOVERED = 16,
226 
227  WIDGET_STATE_ALL = WIDGET_STATE_DISABLED |
228  WIDGET_STATE_FOCUSED |
229  WIDGET_STATE_PRESSED |
230  WIDGET_STATE_SELECTED |
231  WIDGET_STATE_HOVERED
232 };
233 MAKE_ENUM_FLAG_COMBO(WIDGET_STATE);
234 
238  WIDGET_GRAVITY_NONE = 0,
239  WIDGET_GRAVITY_LEFT = 1,
240  WIDGET_GRAVITY_RIGHT = 2,
241  WIDGET_GRAVITY_TOP = 4,
242  WIDGET_GRAVITY_BOTTOM = 8,
243 
244  WIDGET_GRAVITY_LEFT_RIGHT = WIDGET_GRAVITY_LEFT | WIDGET_GRAVITY_RIGHT,
245  WIDGET_GRAVITY_TOP_BOTTOM = WIDGET_GRAVITY_TOP | WIDGET_GRAVITY_BOTTOM,
246  WIDGET_GRAVITY_ALL = WIDGET_GRAVITY_LEFT_RIGHT | WIDGET_GRAVITY_TOP_BOTTOM,
247  WIDGET_GRAVITY_DEFAULT = WIDGET_GRAVITY_LEFT | WIDGET_GRAVITY_TOP
248 };
249 MAKE_ENUM_FLAG_COMBO(WIDGET_GRAVITY);
250 
251 enum AXIS {
255 };
256 
259 enum SIZE_DEP {
270 };
271 MAKE_ENUM_FLAG_COMBO(SIZE_DEP);
272 
278 {
279 public:
280  PreferredSize() : min_w(0), min_h(0)
281  , max_w(10000), max_h(10000)
282  , pref_w(0), pref_h(0)
284  PreferredSize(int w, int h) : min_w(w), min_h(h)
285  , max_w(w), max_h(h)
286  , pref_w(w), pref_h(h)
288 
289  int min_w, min_h;
290  int max_w, max_h;
291  int pref_w, pref_h;
293 };
294 
299 {
300 public:
301  static const int UNSPECIFIED = TB_INVALID_DIMENSION;
302  LayoutParams() : min_w(UNSPECIFIED), min_h(UNSPECIFIED)
303  , max_w(UNSPECIFIED), max_h(UNSPECIFIED)
304  , pref_w(UNSPECIFIED), pref_h(UNSPECIFIED) {}
305  LayoutParams(int w, int h) : min_w(w), min_h(h)
306  , max_w(w), max_h(h)
307  , pref_w(w), pref_h(h) {}
308 
310  void SetWidth(int width) { min_w = max_w = pref_w = width; }
311 
313  void SetHeight(int height) { min_h = max_h = pref_h = height; }
314 
315  int min_w, min_h;
316  int max_w, max_h;
317  int pref_w, pref_h;
318 };
319 
322 {
323 public:
324  static const int NO_RESTRICTION = 10000;
325 
327  int available_w, available_h;
328 
330  SizeConstraints(int w, int h) : available_w(w), available_h(h) {}
331 
333  SizeConstraints() : available_w(NO_RESTRICTION), available_h(NO_RESTRICTION) {}
334 
336  SizeConstraints ConstrainByPadding(int horizontal_padding, int vertical_padding) const
337  {
338  return SizeConstraints(available_w == NO_RESTRICTION ? NO_RESTRICTION : available_w - horizontal_padding,
339  available_h == NO_RESTRICTION ? NO_RESTRICTION : available_h - vertical_padding);
340  }
341 
344  {
345  return SizeConstraints(ConstrainByLPMax(available_w, lp.min_w, lp.max_w),
346  ConstrainByLPMax(available_h, lp.min_h, lp.max_h));
347  }
348 
349  bool operator == (const SizeConstraints &sc) const { return available_w == sc.available_w &&
350  available_h == sc.available_h; }
351 
352 private:
353  int ConstrainByLPMax(int constraint, int lp_min, int lp_max) const
354  {
355  if (constraint == NO_RESTRICTION)
356  return lp_max != LayoutParams::UNSPECIFIED ? lp_max : NO_RESTRICTION;
357  int ret = constraint;
358  if (lp_min != LayoutParams::UNSPECIFIED)
359  ret = MAX(ret, lp_min);
360  if (lp_max != LayoutParams::UNSPECIFIED)
361  ret = MIN(ret, lp_max);
362  return ret;
363  }
364 };
365 
367 enum WIDGET_Z {
370 };
371 
376 };
377 
383 };
384 
385 enum WIDGET_INVOKE_INFO {
386  WIDGET_INVOKE_INFO_NORMAL,
387  WIDGET_INVOKE_INFO_NO_CALLBACKS
388 };
389 
395 };
396 
402 };
403 
418 class TBWidget : public TBTypedObject, public TBLinkOf<TBWidget>
419 {
420 public:
423 
424  TBWidget(TBValue::TYPE sync_type = TBValue::TYPE_NULL);
425  virtual ~TBWidget();
426 
430  virtual void SetRect(const TBRect &rect);
432  inline const TBRect & GetRect() const { return m_rect; }
433 
436  void SetPosition(const TBPoint &pos) { SetRect(TBRect(pos.x, pos.y, m_rect.w, m_rect.h)); }
437 
439  void SetSize(int width, int height);
440 
443  void Invalidate();
444 
454  void InvalidateStates();
455 
459  void InvalidateSkinStates();
460 
468  void Die();
469 
471  bool GetIsDying() const { return m_packed.is_dying || (m_parent && m_parent->GetIsDying()); }
472 
476  void SetID(const TBID &id);
478  TBID &GetID() { return m_id; }
480  const TBID &GetID() const { return m_id; }
481 
485  void SetGroupID(const TBID &id) { m_group_id = id; }
487  TBID &GetGroupID() { return m_group_id; }
489  const TBID &GetGroupID() const { return m_group_id; }
490 
492  TBWidget *GetWidgetByID(const TBID &id) const { return GetWidgetByIDInternal(id); }
493 
495  template<class T> T *GetWidgetByIDAndType(const TBID &id) const
496  { return (T*) GetWidgetByIDInternal(id, GetTypeId<T>()); }
497 
500  void SetState(WIDGET_STATE state, bool on);
501 
503  bool GetState(WIDGET_STATE state) const { return (m_state & state) ? true : false; }
504 
507  void SetStateRaw(WIDGET_STATE state);
508 
510  WIDGET_STATE GetStateRaw() const { return m_state; }
511 
519  WIDGET_STATE GetAutoState() const;
520 
524  static void SetAutoFocusState(bool on);
525 
528  void SetOpacity(float opacity);
530  float GetOpacity() const { return m_opacity; }
531 
537 
540  bool GetVisibilityCombined() const;
541 
543  bool GetDisabled() const;
544 
547  void AddChild(TBWidget *child, WIDGET_Z z = WIDGET_Z_TOP, WIDGET_INVOKE_INFO info = WIDGET_INVOKE_INFO_NORMAL);
548 
551  void AddChildRelative(TBWidget *child, WIDGET_Z_REL z, TBWidget *reference, WIDGET_INVOKE_INFO info = WIDGET_INVOKE_INFO_NORMAL);
552 
554  void RemoveChild(TBWidget *child, WIDGET_INVOKE_INFO info = WIDGET_INVOKE_INFO_NORMAL);
555 
557  void RemoveFromParent() { if (m_parent) m_parent->RemoveChild(this); }
558 
562  void DeleteAllChildren();
563 
566  void SetZ(WIDGET_Z z);
567 
569  void SetZInflate(WIDGET_Z z) { m_packed.inflate_child_z = z; }
571  WIDGET_Z GetZInflate() const { return (WIDGET_Z) m_packed.inflate_child_z; }
572 
580  void SetGravity(WIDGET_GRAVITY g);
582  WIDGET_GRAVITY GetGravity() const { return m_gravity; }
583 
594  void SetSkinBg(const TBID &skin_bg, WIDGET_INVOKE_INFO info = WIDGET_INVOKE_INFO_NORMAL);
595 
597  TBID GetSkinBg() const { return m_skin_bg; }
598 
601 
604  void SetIsGroupRoot(bool group_root) { m_packed.is_group_root = group_root; }
606  bool GetIsGroupRoot() const { return m_packed.is_group_root; }
607 
609  void SetIsFocusable(bool focusable) { m_packed.is_focusable = focusable; }
611  bool GetIsFocusable() const { return m_packed.is_focusable; }
612 
614  void SetClickByKey(bool click_by_key) { m_packed.click_by_key = click_by_key; }
616  bool GetClickByKey() const { return m_packed.click_by_key; }
617 
620  void SetWantLongClick(bool want_long_click) { m_packed.want_long_click = want_long_click; }
622  bool GetWantLongClick() const { return m_packed.want_long_click; }
623 
625  void SetIgnoreInput(bool ignore_input) { m_packed.ignore_input = ignore_input; }
627  bool GetIgnoreInput() const { return m_packed.ignore_input; }
628 
632  bool GetIsInteractable() const;
633 
642  bool SetFocus(WIDGET_FOCUS_REASON reason, WIDGET_INVOKE_INFO info = WIDGET_INVOKE_INFO_NORMAL);
644  bool GetIsFocused() const { return focused_widget == this; }
645 
649 
653  bool MoveFocus(bool forward);
654 
657  TBWidget *GetWidgetAt(int x, int y, bool include_children) const;
658 
662  TBWidget *GetChildFromIndex(int index) const;
663 
667  int GetIndexFromChild(TBWidget *child) const;
668 
671  TBStr GetTextByID(const TBID &id);
672 
675  int GetValueByID(const TBID &id);
676 
678  TBWidget *GetNextDeep(const TBWidget *bounding_ancestor = nullptr) const;
680  TBWidget *GetPrevDeep() const;
682  TBWidget *GetLastLeaf() const;
684  inline TBWidget *GetFirstChild() const { return m_children.GetFirst(); }
686  inline TBWidget *GetLastChild() const { return m_children.GetLast(); }
688  TBLinkListOf<TBWidget>::Iterator GetIteratorForward() { return m_children.IterateForward(); }
690  TBLinkListOf<TBWidget>::Iterator GetIteratorBackward() { return m_children.IterateBackward(); }
691 
693  bool IsAncestorOf(TBWidget *other_widget) const;
694 
697  bool IsEventDestinationFor(TBWidget *other_widget) const;
698 
699  // == Callbacks ==============================================
700 
703  void AddListener(TBWidgetListener *listener);
705  void RemoveListener(TBWidgetListener *listener);
707  bool HasListener(TBWidgetListener *listener) const;
708 
712  virtual bool OnEvent(const TBWidgetEvent & /*ev*/) { return false; }
713 
716  virtual void OnProcess() {}
717 
720  virtual void OnProcessAfterChildren() {}
721 
726  virtual void OnProcessStates() {}
727 
732  {
733  public:
734  PaintProps();
735 
738  };
739 
743  virtual void OnPaint(const PaintProps & /*paint_props*/) {}
744 
747  virtual void OnPaintChildren(const PaintProps &paint_props);
748 
751  virtual void OnInvalid() {}
752 
759  virtual void OnSkinChanged() {}
760 
762  virtual void OnFontChanged() {}
763 
765  virtual void OnFocusChanged(bool /*focused*/) {}
766 
770  virtual void OnVisibilityChanged() {}
771 
773  virtual void OnCaptureChanged(bool /*captured*/) {}
774 
776  virtual void OnChildAdded(TBWidget * /*child*/) {}
777 
779  virtual void OnChildRemove(TBWidget * /*child*/) {}
780 
782  virtual void OnAdded() {}
783 
785  virtual void OnRemove() {}
786 
789  virtual void OnDie() {}
790 
793  virtual void OnResized(int old_w, int old_h);
794 
796  virtual void OnScroll(int /*scroll_x*/, int /*scroll_y*/) {}
797 
802  virtual void OnInflateChild(TBWidget *child);
803 
808  virtual void OnInflate(const INFLATE_INFO &info);
809 
814  virtual void OnDeflate(const INFLATE_INFO &info);
815 
819  virtual WIDGET_HIT_STATUS GetHitStatus(int x, int y);
820 
824  virtual bool GetCustomSkinCondition(const TBSkinCondition::CONDITION_INFO & /*info*/) { return false; }
825 
828  virtual TBWidget *GetContentRoot() { return this; }
829 
832 
836 
838  inline TBWidget *GetParent() const { return m_parent; }
839 
841  virtual TBWidget *GetEventDestination() { return m_parent; }
842 
851  virtual void GetChildTranslation(int &x, int &y) const { x = y = 0; }
852 
856  virtual void ScrollTo(int /*x*/, int /*y*/) {}
857 
860  void ScrollToSmooth(int x, int y);
861 
864  void ScrollBy(int dx, int dy);
865 
868  void ScrollBySmooth(int dx, int dy);
869 
872  {
873  public:
874  ScrollInfo() : min_x(0), min_y(0), max_x(0), max_y(0), x(0), y(0) {}
875  bool CanScrollX() const { return max_x > min_x; }
876  bool CanScrollY() const { return max_y > min_y; }
877  bool CanScrollLeft() const { return x > min_x; }
878  bool CanScrollRight() const { return x < max_x; }
879  bool CanScrollUp() const { return y > min_y; }
880  bool CanScrollDown() const { return y < max_y; }
881  bool CanScroll() const { return CanScrollX() || CanScrollY(); }
882  int min_x, min_y;
883  int max_x, max_y;
884  int x, y;
885  };
886 
889  virtual ScrollInfo GetScrollInfo() { return ScrollInfo(); }
890 
894  virtual TBWidget *GetScrollRoot() { return this; }
895 
899  void ScrollByRecursive(int &dx, int &dy);
900 
903 
906  void ScrollIntoView(const TBRect &rect);
907 
910 
911  // == Setter shared for many types of widgets ============
912 
914  virtual void SetAxis(AXIS /*axis*/) {}
916  virtual AXIS GetAxis() const { return AXIS_X; }
917 
920  virtual void SetValue(long /*value*/) {}
922  virtual void SetValue(const TBValue & value) { data = value; }
924  virtual long GetValue() const { return 0; }
925 
928  virtual void SetValueDouble(double value) { SetValue((long) value); }
929 
932  virtual double GetValueDouble() const { return (double) GetValue(); }
933 
935  virtual bool SetText(const TBStr & /*text*/) { return true; }
936 
939  virtual bool GetText(TBStr &text) const { text.Clear(); return true; }
940 
942  TBStr GetText() const { TBStr str; GetText(str); return str; }
943 
952  void Connect(TBWidgetValue *value) { m_connection.Connect(value, this); }
953 
955  void Unconnect() { m_connection.Unconnect(); }
956 
958  const TBWidgetValueConnection & GetConnection() const { return m_connection; }
959 
967  virtual TBRect GetPaddingRect();
968 
973 
979  virtual PreferredSize OnCalculatePreferredSize(const SizeConstraints &constraints);
980 
983  PreferredSize GetPreferredSize(const SizeConstraints &constraints);
986 
991  };
992 
1012  virtual void InvalidateLayout(INVALIDATE_LAYOUT il);
1013 
1015  void SetLayoutParams(const LayoutParams &lp);
1016 
1022  const LayoutParams *GetLayoutParams() const { return m_layout_params; }
1023 
1024  // == Misc methods for invoking events. Should normally be called only on the root widget ===============
1025 
1028  void InvokeProcess();
1029 
1032  void InvokeProcessStates(bool force_update = false);
1033 
1035  void InvokePaint(const PaintProps &parent_paint_props);
1036 
1039  void InvokeFontChanged();
1040 
1060  bool InvokeEvent(TBWidgetEvent &ev);
1061 
1063  bool InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch);
1065  bool InvokePointerUp(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch);
1067  void InvokePointerMove(int x, int y, MODIFIER_KEYS modifierkeys, bool touch);
1069  bool InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys);
1070 
1072  bool InvokeMultiGesture(float dTheta, float dDist, int targetx, int targety, float x, float y, uint16_t numFingers);
1074  bool InvokeFingerMotion(int x, int y, float cx, float cy, float dx, float dy, int finger);
1076  bool InvokeFingerDown(int x, int y, float cx, float cy, float dx, float dy, int finger);
1078  bool InvokeFingerUp(int x, int y, float cx, float cy, float dx, float dy, int finger);
1079 
1082  bool InvokeKey(int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool down);
1083 
1089  void ReleaseCapture();
1090 
1092  void ConvertToRoot(int &x, int &y) const;
1093 
1095  void ConvertFromRoot(int &x, int &y) const;
1096 
1106  bool SetFontDescription(const TBFontDescription &font_desc);
1107 
1110  TBFontDescription GetFontDescription() const { return m_font_desc; }
1111 
1116 
1119  TBFontFace *GetFont() const;
1120 
1121 private:
1122  friend class TBWidgetListener;
1123  TBWidget *m_parent;
1124  TBRect m_rect;
1125  TBID m_id;
1126  TBID m_group_id;
1127  TBID m_skin_bg;
1128  TBID m_skin_bg_expected;
1129  TBLinkListOf<TBWidget> m_children;
1131  TBWidgetValueConnection m_connection;
1132  TBLinkListOf<TBWidgetListener> m_listeners;
1133  float m_opacity;
1134  WIDGET_STATE m_state;
1135  WIDGET_GRAVITY m_gravity;
1136  TBFontDescription m_font_desc;
1137  PreferredSize m_cached_ps;
1138  SizeConstraints m_cached_sc;
1139  LayoutParams *m_layout_params;
1140  TBScroller *m_scroller;
1141  TBLongClickTimer *m_long_click_timer;
1142  union {
1143  struct {
1144  uint16_t is_group_root : 1;
1145  uint16_t is_focusable : 1;
1146  uint16_t click_by_key : 1;
1147  uint16_t has_key_pressed_state : 1;
1148  uint16_t ignore_input : 1;
1149  uint16_t is_dying : 1;
1150  uint16_t is_cached_ps_valid : 1;
1151  uint16_t no_automatic_hover_state : 1;
1152  uint16_t is_panning : 1;
1153  uint16_t want_long_click : 1;
1154  uint16_t visibility : 2;
1155  uint16_t inflate_child_z : 1; // Should have enough bits to hold WIDGET_Z values.
1156  } m_packed;
1157  uint16_t m_packed_init;
1158  };
1159 
1160 public:
1164 
1168 
1169  // Debugging
1170 #ifdef TB_RUNTIME_DEBUG_INFO
1171  double last_measure_time;
1172  double last_layout_time;
1173 #endif // TB_RUNTIME_DEBUG_INFO
1174 
1175  // TBWidget related globals
1183  static bool cancel_click;
1184  static bool update_widget_states;
1185  static bool update_skin_states;
1186  static bool show_focus_state;
1187 
1188  void StopLongClickTimer();
1189 private:
1192  TBWidget *FindScrollableWidget(bool scroll_x, bool scroll_y);
1193  TBScroller *FindStartedScroller();
1194  TBScroller *GetReadyScroller(bool scroll_x, bool scroll_y);
1195  TBWidget *GetWidgetByIDInternal(const TBID &id, const TB_TYPE_ID type_id = nullptr) const;
1196  void InvokeSkinUpdatesInternal(bool force_update);
1197  void InvokeProcessInternal();
1198  static void SetHoveredWidget(TBWidget *widget, bool touch);
1199  static void SetCapturedWidget(TBWidget *widget);
1200  void HandlePanningOnMove(int x, int y);
1201  void StartLongClickTimer(bool touch);
1202  friend class TBLongClickTimer;
1203  void MaybeInvokeLongClickOrContextMenu(bool touch);
1205  float CalculateOpacityInternal(WIDGET_STATE state, TBSkinElement *skin_element);
1206 };
1207 
1210 } // namespace tb
1211 
1212 #endif // TB_WIDGETS_H
void SetHeight(int height)
Set both min max and preferred height to the given height.
Definition: tb_widgets.h:313
AXIS
Definition: tb_widgets.h:251
bool SetFocusRecursive(WIDGET_FOCUS_REASON reason=WIDGET_FOCUS_REASON_UNKNOWN)
Call SetFocus on all children and their children, until a widget is found that accepts it...
Definition: tb_widgets.cpp:605
void SetIgnoreInput(bool ignore_input)
Set if this widget should ignore input, as if it didn&#39;t exist.
Definition: tb_widgets.h:625
void InvokeFontChanged()
Invoke OnFontChanged on this widget and recursively on any children that inherit the font...
Definition: tb_widgets.cpp:1770
virtual PreferredSize OnCalculatePreferredSize(const SizeConstraints &constraints)
Calculate the preferred size for this widget.
Definition: tb_widgets.cpp:960
int max_h
The maximum preferred width and height.
Definition: tb_widgets.h:290
bool InvokeEvent(TBWidgetEvent &ev)
Invoke a event on this widget.
Definition: tb_widgets.cpp:1228
virtual TBWidget * GetScrollRoot()
If this widget is implementing ScrollTo and GetScrollInfo but the corresponding GetChildTranslation i...
Definition: tb_widgets.h:894
static int pointer_move_widget_x
Pointer x position on last pointer event, relative to the captured widget (if any) or hovered widget...
Definition: tb_widgets.h:1181
void RemoveFromParent()
Remove this widget from parent if it has one.
Definition: tb_widgets.h:557
int GetIndexFromChild(TBWidget *child) const
Get the child index of the given widget (that must be a child of this widget).
Definition: tb_widgets.cpp:726
void SetState(WIDGET_STATE state, bool on)
Enable or disable the given state(s).
Definition: tb_widgets.cpp:212
bool MoveFocus(bool forward)
Move focus from the currently focused widget to another focusable widget.
Definition: tb_widgets.cpp:618
bool InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1470
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_widgets.h:916
virtual void OnDeflate(const INFLATE_INFO &info)
Called when this widget is deflated to a node, before any children have been deflated.
Definition: tb_widgets_reader.cpp:249
bool GetIsGroupRoot() const
See TBWidget::SetIsGroupRoot.
Definition: tb_widgets.h:606
void DeleteAllChildren()
Remove and delete all children in this widget.
Definition: tb_widgets.cpp:367
virtual void OnChildRemove(TBWidget *)
Called when a child widget is about to be removed from this widget (before calling OnRemove on child)...
Definition: tb_widgets.h:779
virtual bool GetCustomSkinCondition(const TBSkinCondition::CONDITION_INFO &)
Get if skin condition applies to this widget.
Definition: tb_widgets.h:824
int available_w
The available width and height.
Definition: tb_widgets.h:327
static bool update_skin_states
true if something has called InvalidateSkinStates() and skin still hasn&#39;t been updated.
Definition: tb_widgets.h:1185
void RemoveChild(TBWidget *child, WIDGET_INVOKE_INFO info=WIDGET_INVOKE_INFO_NORMAL)
Remove child from this widget without deleting it.
Definition: tb_widgets.cpp:341
bool GetIsFocused() const
See TBWidget::SetFocus.
Definition: tb_widgets.h:644
virtual void OnPaint(const PaintProps &)
Callback for painting this widget.
Definition: tb_widgets.h:743
int delta_x
Set for EVENT_TYPE_WHEEL. Positive is a turn right.
Definition: tb_widgets.h:119
TYPE
The current type of the value.
Definition: tb_value.h:64
int min_h
The minimal preferred width and height.
Definition: tb_widgets.h:315
The base TBWidget class.
Definition: tb_widgets.h:418
static int pointer_move_widget_y
Pointer y position on last pointer event, relative to the captured widget (if any) or hovered widget...
Definition: tb_widgets.h:1182
TBWidget * target
The widget that invoked the event.
Definition: tb_widgets.h:115
Before the reference widget (visually behind reference).
Definition: tb_widgets.h:374
WIDGET_VISIBILITY
Defines widget visibility, used with TBWidget::SetVisibility.
Definition: tb_widgets.h:379
virtual void OnSkinChanged()
Called when the background skin changes by calling SetSkinBg(), or when the skin has changed indirect...
Definition: tb_widgets.h:759
void InvokeProcessStates(bool force_update=false)
Invoke OnProcessStates on all child widgets, if state processing is needed (InvalidateStates() has be...
Definition: tb_widgets.cpp:1134
SIZE_DEP
Defines how the size in one axis depend on the other axis when a widgets size is affected by constrai...
Definition: tb_widgets.h:259
The width is dependant on the height.
Definition: tb_widgets.h:263
WIDGET_STATE GetStateRaw() const
Get the widget state.
Definition: tb_widgets.h:510
virtual TBRect GetPaddingRect()
Get the rectangle inside any padding, relative to this widget.
Definition: tb_widgets.cpp:902
TBWidgetListener listens to some callbacks from TBWidget.
Definition: tb_widgets_listener.h:28
void InvokePaint(const PaintProps &parent_paint_props)
Invoke paint on this widget and all its children.
Definition: tb_widgets.cpp:1157
virtual void GetChildTranslation(int &x, int &y) const
Return translation the children should have.
Definition: tb_widgets.h:851
virtual void OnPaintChildren(const PaintProps &paint_props)
Callback for painting child widgets.
Definition: tb_widgets.cpp:789
TBID & GetID()
See TBWidget::SetID.
Definition: tb_widgets.h:478
TBFontFace represents a loaded font that can measure and render strings.
Definition: tb_font_renderer.h:142
The widget was hit, any child may be hit too.
Definition: tb_widgets.h:400
TBWidget * GetPrevDeep() const
Get the prev node in depth search of the widget tree.
Definition: tb_widgets.cpp:655
The toplevel (Visually drawn on top of everything else).
Definition: tb_widgets.h:368
bool HasListener(TBWidgetListener *listener) const
See TBWidget::AddListener.
Definition: tb_widgets.cpp:784
WIDGET_GRAVITY
TBWidget gravity (may be combined).
Definition: tb_widgets.h:237
virtual void OnProcess()
Callback for doing anything that might be needed before paint.
Definition: tb_widgets.h:716
The bottomlevel (Visually drawn behind everything else).
Definition: tb_widgets.h:369
virtual void SetValueDouble(double value)
Set the value in double precision.
Definition: tb_widgets.h:928
void ScrollIntoViewRecursive()
Make this widget visible by calling ScrollIntoView on all parent widgets.
Definition: tb_widgets.cpp:513
Definition: tb_widgets.h:112
WIDGET_FOCUS_REASON
Definition: tb_widgets.h:390
int count
1 for all events, but increased for POINTER_DOWN event to 2 for doubleclick, 3 for tripleclick and so...
Definition: tb_widgets.h:121
InvalidateLayout should not be recursively called on parents.
Definition: tb_widgets.h:989
PreferredSize GetPreferredSize()
See TBWidget::GetPreferredSize.
Definition: tb_widgets.h:985
void ReleaseCapture()
A widget that receive a EVENT_TYPE_POINTER_DOWN event, will stay &quot;captured&quot; until EVENT_TYPE_POINTER_...
Definition: tb_widgets.cpp:1637
virtual bool SetText(const TBStr &)
Set the text of this widget.
Definition: tb_widgets.h:935
LayoutParams defines size preferences for a TBWidget that are set on the widget to override size pref...
Definition: tb_widgets.h:298
virtual void OnCaptureChanged(bool)
Called when the capture has changed.
Definition: tb_widgets.h:773
float dy
the distance moved in the y direction, normalized [-1 1]
Definition: tb_widgets.h:193
The height is dependant on the width.
Definition: tb_widgets.h:265
virtual void OnChildAdded(TBWidget *)
Called when a child widget has been added to this widget (before calling OnAdded on child)...
Definition: tb_widgets.h:776
void ScrollBySmooth(int dx, int dy)
Start the TBScroller for this widget and scroll it by the given delta.
Definition: tb_widgets.cpp:476
float dTheta
the amount that the fingers rotated during this motion
Definition: tb_widgets.h:165
virtual WIDGET_HIT_STATUS GetHitStatus(int x, int y)
Get hit status tests if this widget should be hit at the given coordinate.
Definition: tb_widgets.cpp:682
TBWindow is a TBWidget that provides some window-like features.
Definition: tb_window.h:33
WIDGET_GRAVITY GetGravity() const
See TBWidget::SetGravity.
Definition: tb_widgets.h:582
Simple point class.
Definition: tb_geometry.h:15
float y
the y-location of the touch event, normalized [0 1]
Definition: tb_widgets.h:191
void InvalidateStates()
Call if something changes that might need other widgets to update their state.
Definition: tb_widgets.cpp:146
bool InvokeFingerUp(int x, int y, float cx, float cy, float dx, float dy, int finger)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1550
bool GetVisibilityCombined() const
Return true if this widget and all its ancestors are visible (has a opacity &gt; 0 and visibility WIDGET...
Definition: tb_widgets.cpp:281
TBOBJECT_SUBCLASS(TBWidget, TBTypedObject)
For safe typecasting.
PaintProps contains properties needed for painting a widget.
Definition: tb_widgets.h:731
TBWidget * GetNextDeep(const TBWidget *bounding_ancestor=nullptr) const
Get the next node in depth search of the widget tree.
Definition: tb_widgets.cpp:645
Vertical layout.
Definition: tb_widgets.h:253
Click event is what should be used to trig actions in almost all cases.
Definition: tb_widgets.h:45
int key
for EVENT_TYPE_KEY_* the key, or 0 if key is in special_key; for EVENT_TYPE_FINGER_* is the finger nu...
Definition: tb_widgets.h:126
Set focus by navigation (i.e.
Definition: tb_widgets.h:391
bool GetIsDying() const
Return true if this widget or any of its parents is dying.
Definition: tb_widgets.h:471
int y
Current x and y scroll position.
Definition: tb_widgets.h:884
int min_h
The minimal preferred width and height.
Definition: tb_widgets.h:289
void InvokePointerMove(int x, int y, MODIFIER_KEYS modifierkeys, bool touch)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1394
float GetOpacity() const
See TBWidget::SetOpacity.
Definition: tb_widgets.h:530
WIDGET_Z
Defines widget z level, used with TBWidget::SetZ, TBWidget::AddChild.
Definition: tb_widgets.h:367
int GetCountCycle(int max)
The count value may be 1 to infinity.
Definition: tb_widgets.h:148
static void SetAutoFocusState(bool on)
Set if the state WIDGET_STATE_FOCUSED should be set automatically for the focused widget...
Definition: tb_widgets.cpp:235
void SetIsFocusable(bool focusable)
Set if this widget should be able to receive focus or not.
Definition: tb_widgets.h:609
int pref_h
The preferred width and height.
Definition: tb_widgets.h:291
void InvalidateSkinStates()
Call if something changes that might cause any skin to change due to different state or conditions...
Definition: tb_widgets.cpp:152
bool GetClickByKey() const
See TBWidget::SetClickByKey.
Definition: tb_widgets.h:616
virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints)
Calculate the preferred content size for this widget.
Definition: tb_widgets.cpp:915
Invoked by the platform when one or multiple files has been dropped on the widget.
Definition: tb_widgets.h:86
virtual void OnFocusChanged(bool)
Called when the focus has changed.
Definition: tb_widgets.h:765
int max_h
The maximum preferred width and height.
Definition: tb_widgets.h:316
virtual ScrollInfo GetScrollInfo()
If this is a widget that scroll children (see GetChildTranslation), it should return the current scro...
Definition: tb_widgets.h:889
Specifies size constraints used during size calculations.
Definition: tb_widgets.h:321
Horizontal layout.
Definition: tb_widgets.h:252
TBStr GetTextByID(const TBID &id)
Get the text of a child widget with the given id, or an empty string if there was no widget with that...
Definition: tb_widgets.cpp:183
TBWidgetEventFileDrop is a event of type EVENT_TYPE_FILE_DROP.
Definition: tb_widgets.h:207
virtual void OnRemove()
Called when a this widget has been removed from its parent (after calling OnChildRemove on parent)...
Definition: tb_widgets.h:785
TBID ref_id
Sometimes (when documented) events have a ref_id (The id that caused this event)
Definition: tb_widgets.h:131
void SetOpacity(float opacity)
Set opacity for this widget and its children from 0.0 - 1.0.
Definition: tb_widgets.cpp:244
float center_y
the normalized center of gesture
Definition: tb_widgets.h:164
void SetGravity(WIDGET_GRAVITY g)
Set the widget gravity (any combination of WIDGET_GRAVITY).
Definition: tb_widgets.cpp:389
static int pointer_down_widget_y
Pointer y position on down event, relative to the captured widget.
Definition: tb_widgets.h:1180
Invisible and no layout. Interaction disabled.
Definition: tb_widgets.h:382
int delta_y
Set for EVENT_TYPE_WHEEL. Positive is a turn against the user.
Definition: tb_widgets.h:120
Skin element.
Definition: tb_skin.h:168
void SetZInflate(WIDGET_Z z)
Set the z order in which children are added during resource loading.
Definition: tb_widgets.h:569
virtual void SetAxis(AXIS)
Set along which axis the content should be layed out.
Definition: tb_widgets.h:914
Invoked when a context menu should be opened at the event x and y coordinates.
Definition: tb_widgets.h:82
virtual void OnAdded()
Called when this widget has been added to a parent (after calling OnChildAdded on parent)...
Definition: tb_widgets.h:782
TBWidget * GetLastChild() const
Get the widget&#39;s last child.
Definition: tb_widgets.h:686
static bool cancel_click
true if the pointer up event should not generate a click event.
Definition: tb_widgets.h:1183
bool GetState(WIDGET_STATE state) const
Get status of the given state(s).
Definition: tb_widgets.h:503
bool InvokeMultiGesture(float dTheta, float dDist, int targetx, int targety, float x, float y, uint16_t numFingers)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1493
virtual TBWidget * GetEventDestination()
Get the widget that should receive the events this widget invoke.
Definition: tb_widgets.h:841
WIDGET_Z_REL
Defines widget z level relative to another widget, used with TBWidget::AddChildRelative.
Definition: tb_widgets.h:373
virtual void InvalidateLayout(INVALIDATE_LAYOUT il)
Invalidate layout for this widget so it will be scheduled for relayout.
Definition: tb_widgets.cpp:1084
Set focus by pointer (i.e. clicking)
Definition: tb_widgets.h:393
float x
the x-location of the touch event, normalized [0 1]
Definition: tb_widgets.h:190
TBID is a wrapper for a uint32_t to be used as ID.
Definition: tb_id.h:18
Both width and height are dependant on each other.
Definition: tb_widgets.h:268
virtual void SetValue(long)
Set the value of this widget.
Definition: tb_widgets.h:920
TBWidgetValue stores a TBValue that will be synchronized with all widgets connected to it...
Definition: tb_widget_value.h:62
void SetSize(int width, int height)
Set size of this widget.
Definition: tb_widgets.cpp:121
WIDGET_Z GetZInflate() const
See TBWidget::SetZInflate.
Definition: tb_widgets.h:571
void Die()
Delete the widget with the possibility for some extended life during animations.
Definition: tb_widgets.cpp:157
void SetSkinBg(const TBID &skin_bg, WIDGET_INVOKE_INFO info=WIDGET_INVOKE_INFO_NORMAL)
Set the skin background for this widget and call OnSkinChanged if it changed.
Definition: tb_widgets.cpp:397
static int pointer_down_widget_x
Pointer x position on down event, relative to the captured widget.
Definition: tb_widgets.h:1179
void SetClickByKey(bool click_by_key)
Set if this widget should emulate a click when it&#39;s focused and pressing enter or space...
Definition: tb_widgets.h:614
void Unconnect()
Unconnect, if this widget is connected to a TBWidgetValue.
Definition: tb_widgets.h:955
void SetVisibility(WIDGET_VISIBILITY vis)
Set visibility for this widget and its children.
Definition: tb_widgets.cpp:255
virtual void OnInflateChild(TBWidget *child)
Called just after a child has been inflated into this widget.
Definition: tb_widgets.cpp:871
Custom event.
Definition: tb_widgets.h:89
TBWidget * GetParent() const
Get the parent widget, or nullptr if this widget is not added.
Definition: tb_widgets.h:838
TBValue data
This value is free to use for anything.
Definition: tb_widgets.h:1167
virtual double GetValueDouble() const
Return the value in double precision.
Definition: tb_widgets.h:932
TBWidget * GetWidgetByID(const TBID &id) const
Get this widget or any child widget with a matching id, or nullptr if none is found.
Definition: tb_widgets.h:492
Information about scrolling for a widget at the time of calling GetScrollInfo.
Definition: tb_widgets.h:871
bool InvokeKey(int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool down)
Invoke the EVENT_TYPE_KEY_DOWN and EVENT_TYPE_KEY_UP events on the currently focused widget...
Definition: tb_widgets.cpp:1568
void SetWidth(int width)
Set both min max and preferred width to the given width.
Definition: tb_widgets.h:310
static bool update_widget_states
true if something has called InvalidateStates() and it still hasn&#39;t been updated. ...
Definition: tb_widgets.h:1184
bool SetFontDescription(const TBFontDescription &font_desc)
Set the font description for this widget and any children that inherit the font.
Definition: tb_widgets.cpp:1753
TBWidgetEventMultiGesture is a event of type EVENT_TYPE_MULTI_GESTURE It contains the corresponding v...
Definition: tb_widgets.h:160
TBListAutoDeleteOf is a list (array) of pointers to the specified object type.
Definition: tb_list.h:118
virtual void OnScroll(int, int)
Called when this widget has been scrolled.
Definition: tb_widgets.h:796
TBWidgetEventFinger is a subclass of TBWidgetEvent It is triggered by finger event such as up down or...
Definition: tb_widgets.h:187
After the reference widget (visually above reference).
Definition: tb_widgets.h:375
virtual long GetValue() const
See TBWidget::SetValue.
Definition: tb_widgets.h:924
bool GetIgnoreInput() const
See TBWidget::SetIgnoreInput.
Definition: tb_widgets.h:627
TBWidget * GetParentRoot()
Get this widget or a parent widget that is the absolute root parent.
Definition: tb_widgets.cpp:758
SizeConstraints ConstrainByPadding(int horizontal_padding, int vertical_padding) const
Return new constraints reduced by the given padding.
Definition: tb_widgets.h:336
TBID & GetGroupID()
See TBWidget::SetGroupID.
Definition: tb_widgets.h:487
void AddChildRelative(TBWidget *child, WIDGET_Z_REL z, TBWidget *reference, WIDGET_INVOKE_INFO info=WIDGET_INVOKE_INFO_NORMAL)
Add the child to this widget.
Definition: tb_widgets.cpp:310
virtual ~TBWidget()
Definition: tb_widgets.cpp:84
bool IsEventDestinationFor(TBWidget *other_widget) const
Return true if this widget is the same as other_widget or if other_widget events are going through th...
Definition: tb_widgets.cpp:747
void SetLayoutParams(const LayoutParams &lp)
Set layout params.
Definition: tb_widgets.cpp:1073
INVALIDATE_LAYOUT
Type used for InvalidateLayout.
Definition: tb_widgets.h:988
virtual TBWidget * GetContentRoot()
Get this widget or a child widget that should be root for other children.
Definition: tb_widgets.h:828
WIDGET_HIT_STATUS
Hit status return value for TBWidget::GetHitStatus.
Definition: tb_widgets.h:398
virtual void OnFontChanged()
Called when the font has changed.
Definition: tb_widgets.h:762
virtual void SetRect(const TBRect &rect)
Set the rect for this widget in its parent.
Definition: tb_widgets.cpp:107
int min_y
Minimum x and y scroll position.
Definition: tb_widgets.h:882
virtual void OnDie()
Called when Die() is called on this widget.
Definition: tb_widgets.h:789
Definition: tb_object.h:21
void SetPosition(const TBPoint &pos)
Set position of this widget in its parent.
Definition: tb_widgets.h:436
TBFontDescription GetCalculatedFontDescription() const
Calculate the font description for this widget.
Definition: tb_widgets.cpp:1780
Invoked after changing text in a TBTextField, changing selected item in a TBSelectList etc...
Definition: tb_widgets.h:68
void ScrollBy(int dx, int dy)
If this is a widget that scroll children (see GetChildTranslation), it will scroll by delta dx...
Definition: tb_widgets.cpp:491
const TBRect & GetRect() const
See TBWidget::SetRect.
Definition: tb_widgets.h:432
TB_ALIGN
Definition: tb_widgets.h:29
virtual void OnProcessStates()
Callback for doing state updates that depend on your application state.
Definition: tb_widgets.h:726
INFLATE_INFO contains info passed to TBWidget::OnInflate during resource loading. ...
Definition: tb_widgets_reader.h:21
bool GetIsFocusable() const
See TBWidget::SetIsFocusable.
Definition: tb_widgets.h:611
void AddListener(TBWidgetListener *listener)
Add a listener to this widget.
Definition: tb_widgets.cpp:774
TBValue::TYPE m_sync_type
The data type that should be synchronized through TBWidgetValue.
Definition: tb_widgets.h:1163
const TBID & GetID() const
See TBWidget::SetID.
Definition: tb_widgets.h:480
float dDist
the amount that the fingers pinched during this motion
Definition: tb_widgets.h:166
EVENT_TYPE
Definition: tb_widgets.h:36
Invoked by the platform when a standard keyboard shortcut is pressed.
Definition: tb_widgets.h:77
TBLinkListOf< TBWidget >::Iterator GetIteratorBackward()
Create an iterator to iterate through the widget&#39;s children, backward.
Definition: tb_widgets.h:690
void SetZ(WIDGET_Z z)
Sets the z-order of this widget related to its siblings.
Definition: tb_widgets.cpp:376
The widget was not hit.
Definition: tb_widgets.h:399
int pref_h
The preferred width and height.
Definition: tb_widgets.h:317
const TBID & GetGroupID() const
See TBWidget::SetGroupID.
Definition: tb_widgets.h:489
TBStr is a simple string class.
Definition: tb_str.h:62
No dependency (Faster layout).
Definition: tb_widgets.h:261
int target_y
Y position in target widget. Set for all pointer events, click and wheel.
Definition: tb_widgets.h:118
int max_y
Maximum x and y scroll position.
Definition: tb_widgets.h:883
Align to the bottom (below)
Definition: tb_widgets.h:33
T * GetWidgetByIDAndType(const TBID &id) const
Get this widget or any child widget with a matching id and type, or nullptr if none is found...
Definition: tb_widgets.h:495
virtual void OnProcessAfterChildren()
Callback for doing anything that might be needed before paint.
Definition: tb_widgets.h:720
virtual void OnResized(int old_w, int old_h)
Called when this widget has been resized.
Definition: tb_widgets.cpp:850
Simple rectangle class.
Definition: tb_geometry.h:25
float dx
the distance moved in the x direction, normalized [-1 1]
Definition: tb_widgets.h:192
Invisible, but layouted. Interaction disabled.
Definition: tb_widgets.h:381
Align to the right side.
Definition: tb_widgets.h:32
const TBWidgetValueConnection & GetConnection() const
Get the widget TBWidgetValue.
Definition: tb_widgets.h:958
TBWindow * GetParentWindow()
Get the closest parent widget that is a TBWindow or nullptr if there is none.
Definition: tb_widgets.cpp:766
Visible (default)
Definition: tb_widgets.h:380
int target_x
X position in target widget. Set for all pointer events, click and wheel.
Definition: tb_widgets.h:117
TBValue holds value of a specific type.
Definition: tb_value.h:59
bool InvokeFingerMotion(int x, int y, float cx, float cy, float dx, float dy, int finger)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1514
Align to the left side.
Definition: tb_widgets.h:30
TBID GetSkinBg() const
Return the current skin background, as set by SetSkinBg.
Definition: tb_widgets.h:597
TBLinkListOf< TBWidget >::Iterator GetIteratorForward()
Create an iterator to iterate through the widget&#39;s children, forward.
Definition: tb_widgets.h:688
bool touch
Set for pointer events.
Definition: tb_widgets.h:132
void InvokeProcess()
Invoke OnProcess and OnProcessAfterChildren on this widget and its children.
Definition: tb_widgets.cpp:1094
void SetIsGroupRoot(bool group_root)
Set if this widget is a group root.
Definition: tb_widgets.h:604
TBFontFace * GetFont() const
Get the TBFontFace for this widget from the current font description (calculated by GetCalculatedFont...
Definition: tb_widgets.cpp:1792
static TBWidget * hovered_widget
The currently hovered widget, or nullptr.
Definition: tb_widgets.h:1176
virtual bool GetText(TBStr &text) const
Get the text of this widget.
Definition: tb_widgets.h:939
void ConvertFromRoot(int &x, int &y) const
Make x and y (relative to the upper left corner of the root widget) relative to this widget...
Definition: tb_widgets.cpp:1662
void ScrollIntoView(const TBRect &rect)
If this is a widget that scroll children (see GetChildTranslation), it will scroll so that rect is vi...
Definition: tb_widgets.cpp:526
void ScrollByRecursive(int &dx, int &dy)
Scroll this widget and/or any parent widgets by the given delta.
Definition: tb_widgets.cpp:497
TBWidget * GetLastLeaf() const
Get the last leaf of a depth search of the widget tree.
Definition: tb_widgets.cpp:665
TBColor contains a 32bit color.
Definition: tb_color.h:21
bool InvokeFingerDown(int x, int y, float cx, float cy, float dx, float dy, int finger)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1532
void Connect(TBWidgetValue *value, TBWidget *m_widget)
Connect the value and widget.
Definition: tb_widget_value.cpp:13
void Invalidate()
Invalidate should be called if the widget need to be repainted, to make sure the renderer repaints it...
Definition: tb_widgets.cpp:134
bool IsAncestorOf(TBWidget *other_widget) const
Return true if this widget is the same or a ancestor of other_widget.
Definition: tb_widgets.cpp:736
TBWidgetValueConnection maintains a connection between TBWidget and TBWidgetValue.
Definition: tb_widget_value.h:23
TBScroller handles panning while the pointer is down and measure the pan speed over time...
Definition: tb_scroller.h:64
Stores the information needed for checking a condition.
Definition: tb_skin.h:91
SIZE_DEP size_dependency
The size dependency when size is affected by constraints.
Definition: tb_widgets.h:292
void RemoveListener(TBWidgetListener *listener)
See TBWidget::AddListener.
Definition: tb_widgets.cpp:779
virtual void SetValue(const TBValue &value)
See TBWidget::SetValue.
Definition: tb_widgets.h:922
TBWidget * GetWidgetAt(int x, int y, bool include_children) const
Returns the child widget that contains the coordinate or nullptr if no one does.
Definition: tb_widgets.cpp:689
TBFontDescription GetFontDescription() const
Get the font description as set with SetFontDescription.
Definition: tb_widgets.h:1110
virtual void OnVisibilityChanged()
Called when the visibility has changed.
Definition: tb_widgets.h:770
void SetGroupID(const TBID &id)
Set the group id reference for this widgets.
Definition: tb_widgets.h:485
void SetWantLongClick(bool want_long_click)
Set if this widget should generate long-click event (or context menu event if nothing handles the lon...
Definition: tb_widgets.h:620
virtual void OnInflate(const INFLATE_INFO &info)
Called when this widget is inflated from resources, before any children have been inflated...
Definition: tb_widgets_reader.cpp:29
float center_x
the normalized center of gesture
Definition: tb_widgets.h:163
WIDGET_STATE GetAutoState() const
Return the current combined state for this widget.
Definition: tb_widgets.cpp:217
TBFontDescription describes a font.
Definition: tb_font_desc.h:18
InvalidateLayout should recursively be called on parents too.
Definition: tb_widgets.h:990
static bool show_focus_state
true if the focused state should be painted automatically.
Definition: tb_widgets.h:1186
The widget was hit, no children should be hit.
Definition: tb_widgets.h:401
PreferredSize contains size preferences for a TBWidget.
Definition: tb_widgets.h:277
const LayoutParams * GetLayoutParams() const
Get layout params, or nullptr if not specified.
Definition: tb_widgets.h:1022
bool InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1286
void SetStateRaw(WIDGET_STATE state)
Set the widget state.
Definition: tb_widgets.cpp:203
int GetValueByID(const TBID &id)
Get the value of a child widget with the given id, or 0 if there was no widget with that id...
Definition: tb_widgets.cpp:190
virtual bool OnEvent(const TBWidgetEvent &)
Callback for handling events.
Definition: tb_widgets.h:712
WIDGET_VISIBILITY GetVisibility() const
See TBWidget::SetVisibility.
Definition: tb_widgets.cpp:276
Depth.
Definition: tb_widgets.h:254
void SetID(const TBID &id)
Set the id reference for this widgets.
Definition: tb_widgets.cpp:197
static TBWidget * captured_widget
The currently captured widget, or nullptr.
Definition: tb_widgets.h:1177
bool SetFocus(WIDGET_FOCUS_REASON reason, WIDGET_INVOKE_INFO info=WIDGET_INVOKE_INFO_NORMAL)
Set this widget to be the focused widget.
Definition: tb_widgets.cpp:547
TBColor text_color
Text color as specified in the skin element, or inherited from parent.
Definition: tb_widgets.h:737
SizeConstraints(int w, int h)
Constrain to the given width and height.
Definition: tb_widgets.h:330
bool GetWantLongClick() const
See TBWidget::SetWantLongClick.
Definition: tb_widgets.h:622
SizeConstraints()
No constraints.
Definition: tb_widgets.h:333
virtual void ScrollTo(int, int)
If this is a widget that scroll children (see GetChildTranslation), it should scroll to the coordinat...
Definition: tb_widgets.h:856
TBWidget * GetChildFromIndex(int index) const
Get the child at the given index, or nullptr if there was no child at that index. ...
Definition: tb_widgets.cpp:717
bool GetIsInteractable() const
Get if this widget wants interaction depending on various states.
Definition: tb_widgets.cpp:676
void Connect(TBWidgetValue *value)
Connect this widget to a widget value.
Definition: tb_widgets.h:952
void Unconnect()
Unconnect the value and widget if it is connected.
Definition: tb_widget_value.cpp:22
Set focus by anything else.
Definition: tb_widgets.h:394
TBWidget * GetFirstChild() const
Get the widget&#39;s first child.
Definition: tb_widgets.h:684
SizeConstraints ConstrainByLayoutParams(const LayoutParams &lp) const
Return new constraints that are constrained by LayoutParams.
Definition: tb_widgets.h:343
void AddChild(TBWidget *child, WIDGET_Z z=WIDGET_Z_TOP, WIDGET_INVOKE_INFO info=WIDGET_INVOKE_INFO_NORMAL)
Add the child to this widget.
Definition: tb_widgets.cpp:305
One shot timer for long click event.
Definition: tb_widgets.cpp:39
static TBWidget * focused_widget
The currently focused widget, or nullptr.
Definition: tb_widgets.h:1178
TBStr GetText() const
Get the text of this widget.
Definition: tb_widgets.h:942
void ConvertToRoot(int &x, int &y) const
Make x and y (relative to this widget) relative to the upper left corner of the root widget...
Definition: tb_widgets.cpp:1643
bool InvokePointerUp(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch)
See TBWidget::InvokeEvent.
Definition: tb_widgets.cpp:1350
WIDGET_STATE
TBWidget state types (may be combined).
Definition: tb_widgets.h:219
Long click event is sent when the pointer has been down for some time without moving much...
Definition: tb_widgets.h:54
Align to the top (above)
Definition: tb_widgets.h:31
EVENT_TYPE type
Which type of event.
Definition: tb_widgets.h:116
TBScroller * GetScroller()
Return the TBScroller set up for this widget, or nullptr if creation failed.
Definition: tb_widgets.cpp:460
void ScrollToSmooth(int x, int y)
Start the TBScroller for this widget and scroll it to the given position.
Definition: tb_widgets.cpp:467
TBSkinElement * GetSkinBgElement()
Return the skin background element, or nullptr.
Definition: tb_widgets.cpp:417
virtual void OnInvalid()
Callback for when this widget or any of its children have called Invalidate()
Definition: tb_widgets.h:751
bool GetDisabled() const
Return true if this widget or any of its parents are disabled (has state WIDGET_STATE_DISABLED).
Definition: tb_widgets.cpp:293