Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tab showing the production summary #38

Merged
merged 15 commits into from
Feb 29, 2024

Conversation

veger
Copy link
Collaborator

@veger veger commented Feb 15, 2024

It took some preparation and bug fix PRs, but this is (finally) the PR adding the 'Summary Tab'

I tried to reuse the existing UI of YAFC, so I based the whole thing on a ProjectPageContents and a ProjectPageView, so it would be recognized and fit into the MainScreen (tabs) and serialization.

YAFC-production-summary

The UI of the new 'Summary' tab is ugly, I tried making it nicer, but I found it hard to understand the ImGui and its features and how to use them... So I propose this could be further improved om in separate PRs to get the basic functionality/feature into YAFC already and make it available for everyone (I used it a lot and cannot live without this anymore).

I also fixed some issues I found while implementing the Summary tab, moved to #31 and #34, except for:

  • calculating DatGrid width when header is not used (I found the header useless here)

The original idea is from ShadowTheAge#123

@shpaass
Copy link
Owner

shpaass commented Feb 15, 2024

For future bugfixing: The tab name overlaps with other information.
image

@shpaass
Copy link
Owner

shpaass commented Feb 15, 2024

Do I understand it correctly that for now the user cannot scroll to the right?
image

@shpaass
Copy link
Owner

shpaass commented Feb 15, 2024

When comparing your Summary that can be opened from the top-left menu and the Production Summary that can be opened from the "+" sign, what is the difference between their purposes?

@veger
Copy link
Collaborator Author

veger commented Feb 15, 2024

For future bugfixing: The tab name overlaps with other information.

Hm... your screenshot looks different than what I am used to (except the dark vs light themes I guess).

Oh... when you make the Window too small for the tab bar?

I never tried/did this as I have short tab names to prevent making the bar too long/large 😄
Is it an issue in general, or related to the Summary screen only? The Summary sreen is build in a 'regular page' so I would assume it happens elsewhere as well?

image

Do I understand it correctly that for now the user cannot scroll to the right?

It was mentioned in #31 (IIRC) Must have gone lost at some conversion/rebasing, but: use CRL+scrollwheel or arrow key to scroll horizontally. For some reasons it is not possible to click on the scrollbar (something we might want to fix in the future).

When comparing your Summary that can be opened from the top-left menu and the Production Summary that can be opened from the "+" sign, what is the difference between their purposes?

This is something that @ShadowTheAge started, but never finished:

I do not know the extact intention, but I do not it was (slightly) different compared to this one. @ShadowTheAge also had the idea that this PR should be a plugin, but the plugin system was/is not available: ShadowTheAge#145 (comment).

Unfortunately, it is not in a feature branch, so finding all commits related to this is quite a bit of work.
If/when this PR is merged, we can start a cleanup of this WIP implementation.

@shpaass
Copy link
Owner

shpaass commented Feb 15, 2024

[did this happen] when you make the Window too small for the tab bar?

I haven't understood what exactly you meant by "making it too small", but I didn't make it small on purpose. The app window was around 1500x900 at the time of making a screenshot. I attached the full-screen version below.

I have short tab names

I think the tab names that have the length of something like "Military Science" should be handled without overlapping because that's a common name length.

image

@veger
Copy link
Collaborator Author

veger commented Feb 15, 2024

Oh now I see, it is the name on the left side of the Summary view, I thought it was on the tab bar that was wrapping.

IIRC, the width could not be made dynamic (or I was not able to do so, but I'll verify when I have some time)

@shpaass
Copy link
Owner

shpaass commented Feb 15, 2024

Also, I got a NullReferenceException when trying to delete the Summary page
Steps to reproduce:

  1. Launch YAFC, make it full screen.
  2. Have a couple of sheets open. In my case, they were already opened as I was loading the existing project.
  3. Open the Summary tab. Click "Only show issues", with ending on it being enabled.
  4. Delete the Summary tab by clicking on it and choosing the delete option.
  5. Get the error.
Object reference not set to an instance of an object.

   at YAFC.SummaryView.SummaryDataColumn.BuildElement(ImGui gui, ProjectPage page) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFC\Workspace\SummaryView.cs:line 76
   at YAFC.UI.DataGrid`1.BuildRow(ImGui gui, TData element, Single startX) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFC\Widgets\DataGrid.cs:line 168
   at YAFC.SummaryView.BuildScrollArea(ImGui gui) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFC\Workspace\SummaryView.cs:line 225
   at YAFC.UI.ImGui.DoGui(ImGuiAction action) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFCui\ImGui\ImGuiBuilding.cs:line 173
   at YAFC.UI.ImGui.MouseMove(Int32 mouseDownButton) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFCui\ImGui\ImGuiBuilding.cs:line 222
   at YAFC.UI.InputSystem.MouseMove(Int32 rawX, Int32 rawY) in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFCui\Core\InputSystem.cs:line 114
   at YAFC.UI.Ui.ProcessEvents() in C:\Users\Chill\Documents\git\have-fun\yafc-ce\YAFCui\Core\Ui.cs:line 112

image

@veger
Copy link
Collaborator Author

veger commented Feb 15, 2024

I got a NullReferenceException when trying to delete the Summary page

I never tried this 🤣

The Summary view is a singleton, as it is a special production page. So it should not be fully deleted (hence the error).
Instead, it gets hidden now, like the close button on the tab got clicked.

@veger
Copy link
Collaborator Author

veger commented Feb 15, 2024

the width could not be made dynamic (or I was not able to do so, but I'll verify when I have some time)

I checked and it is possible to set a min/max width for the column. But it does not work when I make the maxWidth larger than the (initial) width. After I quick code inspection, I do see some code that is supposed to calculate the width, but it does not seem to be working...?

I have a plan to move the first column outside of the DataGrid, but I got some headaches as it still would need to scroll vertically! (we'd need to two/nested ScrollAreas for that...)

Either way, I do feel there is a bug in the DataGrid and calculating dynamic widths. Most stuff in YAFC is using static widths, so I guess this bug is not triggered until now when I tried to set the min/max allowed width.

@shpaass shpaass requested a review from SWeini February 15, 2024 14:48
@shpaass
Copy link
Owner

shpaass commented Feb 17, 2024

I think this feature will take quite some time to polish and then replace the current Summary with. So I think about releasing YAFC with the current features, and moving this one to the next release. @veger what do you think?

@veger
Copy link
Collaborator Author

veger commented Feb 18, 2024

It is fine by me, we can focus for the release after this include this overview/summary tab. There is already a lot of new and exiting stuff to release.

@shpaass
Copy link
Owner

shpaass commented Feb 18, 2024

Alright! Then I'll playtest the current version for a bit and then release.

@veger
Copy link
Collaborator Author

veger commented Feb 27, 2024

I rebased and reformatted (for the new editorconfig) this PR.

Known issues (summary):

NullReferenceException when trying to delete the Summary page

Fixed

The tab name overlaps with other information

The data grid does not support dynamic widths (although the code looks like it should).
I think the grid needs to be adjusted to have heading (top and left) support. Then it is able to calculate the required width and adjust accordingly.
Or we could even add such a support for each row/column to have automatic widths/heights for the whole grid (no idea if this is (too) computation intensive or something though)

Nonetheless, I guess we should open an issue for this (bug), and discuss the wished outcome/support of the data grid?

For this PR I could increase the width, but it won't help too much...

Do I understand it correctly that for now the user cannot scroll to the right?

<CRTL>+<scroll wheel> or arrow keys do work.

Clicking the scrollbar does not work. Back then I tried to figure out what is causing this, but was not able to.
I suppose it is some YAFCui/SDL issue.

Let's open a ticket for this as well?


Is there anything else known that needs solving?

@veger
Copy link
Collaborator Author

veger commented Feb 27, 2024

Is there anything else known that needs solving?

Well... there are a lot of improvements imaginable, but I would propose to add new features for the Summary Tab in future PRs 😉

@shpaass
Copy link
Owner

shpaass commented Feb 27, 2024

The data grid does not support dynamic widths

What do you think about calculating the max length of the name column before generating the page, and setting it to that number? Is that a dynamic width you meant, or can it be arranged?

@shihan42
Copy link
Collaborator

The data grid does not support dynamic widths (although the code looks like it should). I think the grid needs to be adjusted to have heading (top and left) support. Then it is able to calculate the required width and adjust accordingly. Or we could even add such a support for each row/column to have automatic widths/heights for the whole grid (no idea if this is (too) computation intensive or something though)

Nonetheless, I guess we should open an issue for this (bug), and discuss the wished outcome/support of the data grid?

Discussion is a good idea. Right know, I'm not sure how that could be solved or in what way the data grid should change.

Clicking the scrollbar does not work. Back then I tried to figure out what is causing this, but was not able to. I suppose it is some YAFCui/SDL issue.
Let's open a ticket for this as well?

Good idea, too. It is more than irritating that there are scrollbars but only one of them works.

@veger
Copy link
Collaborator Author

veger commented Feb 27, 2024

What do you think about calculating the max length of the name column before generating the page, and setting it to that number? Is that a dynamic width you meant, or can it be arranged?

It could be done like this (yes, it makes the width dynamic) but that is moving UI related stuff to the model/analyzer code.

Ideally, the DataGrid UI should do this automatically without the non-UI part (or at least the non-low level UI part) of YAFC to know about this calculations.

Discussion is a good idea. Right know, I'm not sure how that could be solved or in what way the data grid should change.

Me neither, I feel there is a bug, or unfinished code in the DataGrid.

Good idea, too. It is more than irritating that there are scrollbars but only one of them works.

I'll make a ticket, so other know how to use it. And for us to remember to figure this out and fix it

@shpaass
Copy link
Owner

shpaass commented Feb 27, 2024

Then I would suggest to make the length of the first column so that it can fit at least 20 characters.

@veger
Copy link
Collaborator Author

veger commented Feb 27, 2024

20 characters.

Sure, I'll use a o for the width.

As the w and i have different (extreme) widths, 20 w would be too wide and 20 i too narrow, I suppose.

The DataGrid component does not (properly) support automatic width
calculation, so a sensible hard-coded width is applied
Copy link
Collaborator

@shihan42 shihan42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you take into account that these measurements are some logical measurements and are converted to real pixels at a late step during UI drawing?
Thats something I fell for, at first.

@veger
Copy link
Collaborator Author

veger commented Feb 27, 2024

I used the low-tech approach: fill in some value and see whether it was wide enough.

After 5 ( 😞 ) iterations I could fit 20 o without too much empty space after it 😉

@shpaass shpaass mentioned this pull request Feb 27, 2024
@shpaass shpaass merged commit afcb955 into shpaass:master Feb 29, 2024
@veger veger deleted the summary-tab-ce branch February 29, 2024 14:17
shpaass added a commit that referenced this pull request Jun 21, 2024
With this PR the fixed width (introduced by #38) will be no more and the
column width is dynamically calculated depending on the names of the
production sheets.

---

This change is part of a larger set of changes that I am planning to
commit, but those changes need some additional love... (It works, but I
broke some things that should not be broken).

This change is ready and works separately and adds value to YAFC
already.

I had to apply one small hack to make this a stand-alone PR, which is
making `firstColumnWidth` static. In the upcoming PR it will be a
regular field of its class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants