mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-25 14:08:23 -05:00
Add Widget::parent_rect() accessor, rename member variable.
Some day I will settle on a convention for naming members... I think that day is near.
This commit is contained in:
parent
3f94591083
commit
f2dd6827ea
@ -53,15 +53,19 @@ Point Widget::screen_pos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size Widget::size() const {
|
Size Widget::size() const {
|
||||||
return parent_rect.size();
|
return _parent_rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect Widget::screen_rect() const {
|
Rect Widget::screen_rect() const {
|
||||||
return parent() ? (parent_rect + parent()->screen_pos()) : parent_rect;
|
return parent() ? (parent_rect() + parent()->screen_pos()) : parent_rect();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Widget::parent_rect() const {
|
||||||
|
return _parent_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::set_parent_rect(const Rect new_parent_rect) {
|
void Widget::set_parent_rect(const Rect new_parent_rect) {
|
||||||
parent_rect = new_parent_rect;
|
_parent_rect = new_parent_rect;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ void Widget::hidden(bool hide) {
|
|||||||
if( hide ) {
|
if( hide ) {
|
||||||
// TODO: Instead of dirtying parent entirely, dirty only children
|
// TODO: Instead of dirtying parent entirely, dirty only children
|
||||||
// that overlap with this widget.
|
// that overlap with this widget.
|
||||||
parent()->dirty_overlapping_children_in_rect(parent_rect);
|
parent()->dirty_overlapping_children_in_rect(parent_rect());
|
||||||
/* TODO: Notify self and all non-hidden children that they're
|
/* TODO: Notify self and all non-hidden children that they're
|
||||||
* now effectively hidden?
|
* now effectively hidden?
|
||||||
*/
|
*/
|
||||||
@ -214,7 +218,7 @@ void Widget::set_highlighted(const bool value) {
|
|||||||
|
|
||||||
void Widget::dirty_overlapping_children_in_rect(const Rect& child_rect) {
|
void Widget::dirty_overlapping_children_in_rect(const Rect& child_rect) {
|
||||||
for(auto child : children()) {
|
for(auto child : children()) {
|
||||||
if( !child_rect.intersect(child->parent_rect).is_empty() ) {
|
if( !child_rect.intersect(child->parent_rect()).is_empty() ) {
|
||||||
child->set_dirty();
|
child->set_dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ private:
|
|||||||
class Widget {
|
class Widget {
|
||||||
public:
|
public:
|
||||||
Widget(
|
Widget(
|
||||||
) : parent_rect { }
|
) : _parent_rect { }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget(
|
Widget(
|
||||||
Rect parent_rect
|
Rect parent_rect
|
||||||
) : parent_rect { parent_rect }
|
) : _parent_rect { parent_rect }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ public:
|
|||||||
Point screen_pos();
|
Point screen_pos();
|
||||||
Size size() const;
|
Size size() const;
|
||||||
Rect screen_rect() const;
|
Rect screen_rect() const;
|
||||||
|
Rect parent_rect() const;
|
||||||
virtual void set_parent_rect(const Rect new_parent_rect);
|
virtual void set_parent_rect(const Rect new_parent_rect);
|
||||||
|
|
||||||
Widget* parent() const;
|
Widget* parent() const;
|
||||||
@ -119,7 +120,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* Widget rectangle relative to parent pos(). */
|
/* Widget rectangle relative to parent pos(). */
|
||||||
Rect parent_rect;
|
Rect _parent_rect;
|
||||||
const Style* style_ { nullptr };
|
const Style* style_ { nullptr };
|
||||||
Widget* parent_ { nullptr };
|
Widget* parent_ { nullptr };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user