Browse Source

typo fix, and some debugging

master
Odilitime 1 year ago
parent
commit
d6e7b5f327
1 changed files with 16 additions and 4 deletions
  1. 16
    4
      src/interfaces/components/Component.cpp

+ 16
- 4
src/interfaces/components/Component.cpp View File

@@ -18,7 +18,7 @@ std::unique_ptr<std::pair<UImetricV2, UImetricV2>> getUIMetric(UImetricV2 &s1, U
}
std::unique_ptr<std::pair<UImetricV2, UImetricV2>> result=std::make_unique<std::pair<UImetricV2, UImetricV2>>();
if (s1.requested && s2.requested) {
// left/right
// left/right top/bottom
//std::cout << "left/right px " << s1.px << " & " << s2.px << std::endl;
//std::cout << "left/right % " << s1.pct << " & " << s2.pct << std::endl;
result->first = { true, s1.pct, s1.px }; // pos
@@ -41,18 +41,18 @@ std::unique_ptr<std::pair<UImetricV2, UImetricV2>> getUIMetric(UImetricV2 &s1, U
*/
} else
if (s1.requested && size.requested) {
// left + width
// left + width top+height
result->first = { true, s1.pct, s1.px }; // pos
result->second = { true, size.pct, size.px };
} else
if (s2.requested && size.requested) {
// right - width
// right - width bottom-height
// right 25% = left 75%
// + width 50% means start at 25%
result->first = { true, (100.0 - s2.pct) - size.pct, -s2.px - size.px }; // pos
result->second = { true, size.pct, size.px };
} else {
std::cout << "component.getUIMetric - Unkown state" << std::endl;
std::cout << "component.getUIMetric - Unknown state" << std::endl;
}
return result;
}
@@ -66,7 +66,9 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
UILayoutV2 boxSetup;
boxSetup.width.px = 32;
boxSetup.height.px = 32;
//std::cout << "Component::setUpUI - type: " << typeOfComponent(this) << std::endl;
if (properties.find("width") != properties.end()) {
//std::cout << "Component::setUpUI - has width" << std::endl;
boxSetup.width.requested = true;
if (properties["width"][properties["width"].size() - 1] == '%') {
//std::cout << "Component::setUpUI - found width %" << std::endl;
@@ -103,6 +105,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
}
}
if (properties.find("left") != properties.end()) {
//std::cout << "Component::setUpUI - has left" << std::endl;
boxSetup.left.requested = true;
if (properties["left"][properties["left"].size() - 1] == '%') {
//std::cout << "Component::setUpUI - found left %" << std::endl;
@@ -112,6 +115,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
}
}
if (properties.find("right") != properties.end()) {
//std::cout << "Component::setUpUI - has right" << std::endl;
boxSetup.right.requested = true;
if (properties["right"][properties["right"].size() - 1] == '%') {
//std::cout << "Component::setUpUI - found right %" << std::endl;
@@ -120,6 +124,14 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
boxSetup.right.px = std::stoi(properties["right"]);
}
}
/*
std::cout << "boxSetup left : " << boxSetup.left.requested << " " << boxSetup.left.pct << "% @" << boxSetup.left.px << std::endl;
std::cout << "boxSetup right: " << boxSetup.right.requested << " " << boxSetup.right.pct << "% @" << boxSetup.right.px << std::endl;
std::cout << "boxSetup width: " << boxSetup.width.requested << " " << boxSetup.width.pct << "% @" << boxSetup.width.px << std::endl;
std::cout << "boxSetup top : " << boxSetup.top.requested << " " << boxSetup.top.pct << "% @" << boxSetup.top.px << std::endl;
std::cout << "boxSetup bottom: " << boxSetup.bottom.requested << " " << boxSetup.bottom.pct << "% @" << boxSetup.bottom.px << std::endl;
std::cout << "boxSetup height: " << boxSetup.height.requested << " " << boxSetup.height.pct << "% @" << boxSetup.height.px << std::endl;
*/
std::unique_ptr<std::pair<UImetricV2, UImetricV2>> xUI = getUIMetric(boxSetup.left, boxSetup.right, boxSetup.width);
std::unique_ptr<std::pair<UImetricV2, UImetricV2>> yUI = getUIMetric(boxSetup.top, boxSetup.bottom, boxSetup.height);
//int cX = 0, cY = 0;

Loading…
Cancel
Save