Skip to content

Commit

Permalink
Create dummy string table for sizing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRStevens committed Feb 24, 2025
1 parent 185983c commit 0f5e899
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions appOPHD/UI/FactoryProduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <NAS2D/Utility.h>
#include <NAS2D/Renderer/Renderer.h>

#include <algorithm>


using namespace NAS2D;

Expand Down Expand Up @@ -67,10 +69,17 @@ FactoryProduction::FactoryProduction() :
mProductGrid.selectionChanged().connect({this, &FactoryProduction::onProductSelectionChange});
add(mProductGrid, {constants::Margin, sWindowTitleBarHeight + constants::Margin});

// Create dummy object for sizing purposes
auto stringTable = factoryProductionStringTable({99, {}}, 99);
stringTable.position(mProductGrid.area().crossXPoint() + NAS2D::Vector{constants::Margin, 0});
stringTable.computeRelativeCellPositions();

chkIdle.size({50, 20});
add(chkIdle, {mProductGrid.size().x + 12, 116});
add(chkIdle, stringTable.screenRect().crossYPoint() - NAS2D::Point{0, 0} + NAS2D::Vector{0, constants::Margin});

mProductGrid.height(chkIdle.area().endPoint().y - mProductGrid.area().position.y);

const auto buttonArea = Rectangle{mProductGrid.area().endPoint() + Vector{constants::Margin, constants::MarginTight}, {162, 22}};
const auto buttonArea = Rectangle{mProductGrid.area().endPoint() + Vector{constants::Margin, constants::MarginTight}, {std::max(162, stringTable.screenRect().size.x), 22}};
const auto buttonSize = Vector{(buttonArea.size.x - (constants::MarginTight * 2)) / 3, buttonArea.size.y};
const auto buttonSpacing = buttonSize.x + constants::MarginTight;

Expand Down

0 comments on commit 0f5e899

Please sign in to comment.