Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
frame.h
1 #pragma once
2 
3 #include "widget.h"
4 
5 namespace smlt {
6 namespace ui {
7 
17 enum LayoutDirection {
18  LAYOUT_DIRECTION_TOP_TO_BOTTOM,
19  LAYOUT_DIRECTION_LEFT_TO_RIGHT
20 };
21 
22 enum ChildCleanup {
23  CHILD_CLEANUP_DESTROY,
24  CHILD_CLEANUP_RETAIN
25 };
26 
27 class Frame:
28  public Widget {
29 
30 public:
31  using Widget::init; // Pull in init to satisfy Managed<Image>
32  using Widget::clean_up;
33 
34  Frame(UIManager* owner, UIConfig* config);
35 
36  bool pack_child(Widget* widget);
37 
38  bool unpack_child(Widget* widget, ChildCleanup clean_up=CHILD_CLEANUP_DESTROY);
39 
40  const std::vector<smlt::ui::Widget*>& packed_children() const;
41 
42  void set_layout_direction(LayoutDirection dir);
43 
44  void set_space_between(Px spacing);
45 
46  Px space_between() const {
47  return space_between_;
48  }
49 
50 private:
51  std::vector<smlt::ui::Widget*> children_;
52  LayoutDirection direction_ = LAYOUT_DIRECTION_TOP_TO_BOTTOM;
53  Px space_between_ = 0;
54 
55  virtual WidgetBounds calculate_foreground_size(const UIDim& content_dimensions) const override;
56  virtual UIDim calculate_content_dimensions(Px text_width, Px text_height) override;
57 
58  virtual void finalize_build() override;
59 };
60 
61 
62 }
63 }
smlt::ui::UIManager
Definition: ui_manager.h:54
smlt
Definition: animation.cpp:25
smlt::ui::Widget
Definition: widget.h:84
smlt::ui::UIConfig
Definition: ui_config.h:172
smlt::ui::Px
Definition: ui_config.h:37
smlt::ui::Frame
Definition: frame.h:28
smlt::ui::Widget::WidgetBounds
Definition: widget.h:273
smlt::ui::UIDim
Definition: ui_config.h:120