important gui fixes

This commit is contained in:
MihailRis 2024-04-17 01:39:18 +03:00
parent 502ebf4075
commit 59f721543e
3 changed files with 4 additions and 3 deletions

View File

@ -209,7 +209,7 @@ void UINode::setGravity(Gravity gravity) {
switch (gravity) {
case Gravity::top_left:
case Gravity::center_left:
case Gravity::bottom_left: x = parentSize.x+margin.x; break;
case Gravity::bottom_left: x = margin.x; break;
case Gravity::top_center:
case Gravity::center_center:
case Gravity::bottom_center: x = (parentSize.x-size.x)/2.0f; break;
@ -221,7 +221,7 @@ void UINode::setGravity(Gravity gravity) {
switch (gravity) {
case Gravity::top_left:
case Gravity::top_center:
case Gravity::top_right: y = parentSize.y+margin.y; break;
case Gravity::top_right: y = margin.y; break;
case Gravity::center_left:
case Gravity::center_center:
case Gravity::center_right: y = (parentSize.y-size.y)/2.0f; break;

View File

@ -192,6 +192,7 @@ void Panel::cropToContent() {
}
void Panel::add(std::shared_ptr<UINode> node) {
node->setResizing(true);
Container::add(node);
refresh();
cropToContent();

View File

@ -35,7 +35,7 @@ static Gravity gravity_from_string(const std::string& str) {
{"bottom-right", Gravity::bottom_right},
};
auto found = gravity_names.find(str);
if (found == gravity_names.end()) {
if (found != gravity_names.end()) {
return found->second;
}
return Gravity::none;