MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / UpdateFixedBounds

Method UpdateFixedBounds

LibLemon/src/gui/widgets.cpp:46–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 void Widget::OnCommand(__attribute__((unused)) unsigned short key) {}
45
46 void Widget::UpdateFixedBounds(){
47 fixedBounds.pos = bounds.pos;
48
49 if(parent){
50 fixedBounds.pos += parent->GetFixedBounds().pos;
51
52 if(sizeX == LayoutSize::Stretch){
53 if(align == WidgetAlignment::WAlignRight)
54 fixedBounds.width = (parent->GetFixedBounds().size.x - bounds.pos.x) - parent->GetFixedBounds().pos.x;
55 else
56 fixedBounds.width = parent->GetFixedBounds().width - bounds.width - bounds.x;
57 } else {
58 fixedBounds.width = bounds.width;
59 }
60
61 if(sizeY == LayoutSize::Stretch){
62 if(verticalAlign == WidgetAlignment::WAlignBottom)
63 fixedBounds.height = (parent->GetFixedBounds().height - bounds.y) - parent->GetFixedBounds().y;
64 else
65 fixedBounds.height = parent->GetFixedBounds().height - bounds.height - bounds.y;
66 } else {
67 fixedBounds.height = bounds.height;
68 }
69
70 if(align == WidgetAlignment::WAlignRight){
71 fixedBounds.pos.x = (parent->GetFixedBounds().pos.x + parent->GetFixedBounds().size.x) - bounds.pos.x - fixedBounds.width;
72 } else if(align == WAlignCentre){
73 fixedBounds.pos.x = parent->GetFixedBounds().width / 2 - fixedBounds.width / 2 + bounds.x;
74 }
75
76 if(verticalAlign == WidgetAlignment::WAlignBottom){
77 fixedBounds.pos.y = (parent->GetFixedBounds().y + parent->GetFixedBounds().height) - bounds.y - fixedBounds.height;
78 } else if(verticalAlign == WAlignCentre){
79 fixedBounds.pos.y = parent->GetFixedBounds().height / 2 - fixedBounds.height / 2 + bounds.y;
80 }
81 } else {
82 fixedBounds.size = bounds.size;
83 }
84 }
85
86 //////////////////////////
87 // Contianer

Callers 1

ResizeMethod · 0.45

Calls 4

GetFixedBoundsMethod · 0.80
SetBoundsMethod · 0.80
SetLayoutMethod · 0.80
ResetScrollBarMethod · 0.80

Tested by

no test coverage detected