Skip to content

Commit

Permalink
Adjust Summary View to window height
Browse files Browse the repository at this point in the history
It is a bit hackish but it seems to work (after updating the UI to
trigger some 'recalculation')

Fixes: #2
  • Loading branch information
veger committed Feb 27, 2024
1 parent 09a9179 commit 238b653
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions YAFC/Workspace/SummaryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ namespace YAFC
{
public class SummaryView : ProjectPageView<Summary>
{
private class SummaryScrollArea : ScrollArea
{
static float DefaultHeight = 10;

public SummaryScrollArea(GuiBuilder builder) : base(DefaultHeight, builder, default, false, true, true)
{
}

public new void Build(ImGui gui)
{
// Maximize scroll area to fit parent area (minus header and 'show issues' heights, and some (2) padding probably)
Build(gui, gui.valid ? gui.parent.contentSize.Y - HeaderFont.size - Font.text.size - ScrollbarSize - 2 : DefaultHeight);
}
}

private class SummaryTabColumn : TextDataColumn<ProjectPage>
{
public SummaryTabColumn() : base("Tab", 6f)
Expand Down Expand Up @@ -131,10 +146,12 @@ struct GoodDetails
public float sum;
}

static Font HeaderFont = Font.header;

private Project project;
private SearchQuery searchQuery;

private readonly ScrollArea scrollArea;
private readonly SummaryScrollArea scrollArea;
private readonly SummaryDataColumn goodsColumn;
private readonly DataGrid<ProjectPage> mainGrid;

Expand All @@ -149,8 +166,7 @@ public SummaryView()
new SummaryTabColumn(),
goodsColumn,
};
// TODO Make height relative to min(window,content) height instead of fixed
scrollArea = new ScrollArea(30, BuildScrollArea, vertical: true, horizontal: true);
scrollArea = new SummaryScrollArea(BuildScrollArea);
mainGrid = new DataGrid<ProjectPage>(columns);
}

Expand Down Expand Up @@ -183,7 +199,7 @@ protected override void BuildHeader(ImGui gui)
base.BuildHeader(gui);

gui.allocator = RectAllocator.Center;
gui.BuildText("Production Sheet Summary", Font.header, false, RectAlignment.Middle);
gui.BuildText("Production Sheet Summary", HeaderFont, false, RectAlignment.Middle);
gui.allocator = RectAllocator.LeftAlign;
}

Expand Down

0 comments on commit 238b653

Please # to comment.