mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-04 08:55:21 -05:00
Return Widget::children() by reference.
This commit is contained in:
parent
2b6bc03408
commit
5a66c68861
@ -46,6 +46,8 @@ bool is_dirty() {
|
|||||||
|
|
||||||
/* Widget ****************************************************************/
|
/* Widget ****************************************************************/
|
||||||
|
|
||||||
|
const std::vector<Widget*> Widget::no_children { };
|
||||||
|
|
||||||
Point Widget::screen_pos() {
|
Point Widget::screen_pos() {
|
||||||
return screen_rect().pos;
|
return screen_rect().pos;
|
||||||
}
|
}
|
||||||
@ -153,8 +155,8 @@ bool Widget::on_touch(const TouchEvent event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Widget*> Widget::children() const {
|
const std::vector<Widget*>& Widget::children() const {
|
||||||
return { };
|
return no_children;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context& Widget::context() const {
|
Context& Widget::context() const {
|
||||||
@ -244,7 +246,7 @@ void View::remove_child(Widget* const widget) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Widget*> View::children() const {
|
const std::vector<Widget*>& View::children() const {
|
||||||
return children_;
|
return children_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
virtual bool on_key(const KeyEvent event);
|
virtual bool on_key(const KeyEvent event);
|
||||||
virtual bool on_encoder(const EncoderEvent event);
|
virtual bool on_encoder(const EncoderEvent event);
|
||||||
virtual bool on_touch(const TouchEvent event);
|
virtual bool on_touch(const TouchEvent event);
|
||||||
virtual const std::vector<Widget*> children() const;
|
virtual const std::vector<Widget*>& children() const;
|
||||||
|
|
||||||
virtual Context& context() const;
|
virtual Context& context() const;
|
||||||
|
|
||||||
@ -136,6 +136,8 @@ private:
|
|||||||
.highlighted = false,
|
.highlighted = false,
|
||||||
.visible = false,
|
.visible = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const std::vector<Widget*> no_children;
|
||||||
};
|
};
|
||||||
|
|
||||||
class View : public Widget {
|
class View : public Widget {
|
||||||
@ -154,7 +156,7 @@ public:
|
|||||||
void add_child(Widget* const widget);
|
void add_child(Widget* const widget);
|
||||||
void add_children(const std::vector<Widget*>& children);
|
void add_children(const std::vector<Widget*>& children);
|
||||||
void remove_child(Widget* const widget);
|
void remove_child(Widget* const widget);
|
||||||
const std::vector<Widget*> children() const override;
|
const std::vector<Widget*>& children() const override;
|
||||||
|
|
||||||
virtual std::string title() const;
|
virtual std::string title() const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user