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

feat: change pages with ctrl-tab #199

Merged
merged 5 commits into from
Jul 22, 2024
Merged

Conversation

sfoster1
Copy link
Collaborator

@sfoster1 sfoster1 commented Jul 21, 2024

Use the common browser interaction ctrl-tab to switch pages forward and shift-tab to switch pages back.

Implementation-wise, we have to break a little layering by using the displayPages list of guids that really only the tab bar is supposed to care about... but we have to call ChangePage in the main screen, so I'm not sure how else to do it.

The other change of note is forcing a focus change when you switch tabs; this is to get any active dropdowns (i.e. the GoodsIcon dropdowns for switching recipes or switching modules) to disappear if you hit control-tab while one is open, since the mouse isn't otherwise moving and clicking like it would be if you switched tabs with the mouse.

It's also a pretty good way to test #198 by just holding down the button! This branch has both. That got merged and I rebased so you can just test that on a build of this branch

Yafc.Model/Model/Project.cs Outdated Show resolved Hide resolved
Yafc/Workspace/ProjectPageView.cs Outdated Show resolved Hide resolved
Yafc.Model/Model/Project.cs Outdated Show resolved Hide resolved
Yafc/Windows/MainScreen.cs Show resolved Hide resolved
@sfoster1 sfoster1 requested a review from veger July 21, 2024 21:38
Copy link
Collaborator

@veger veger left a comment

Choose a reason for hiding this comment

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

PR looks good to me now!
I didn't test anything (only looked at code) though. So @shpaass might want to test before merging?

Copy link
Collaborator

@veger veger left a comment

Choose a reason for hiding this comment

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

wasn't removing the pane from the display pages list

Oh... When you close a page it is not deleted, so I doubt removing from the list is a good thing...
I can take a (better) look tomorrow (quite late here already), or maybe someone else can (double) check

@veger veger self-requested a review July 21, 2024 22:25
@sfoster1
Copy link
Collaborator Author

wasn't removing the pane from the display pages list

Oh... When you close a page it is not deleted, so I doubt removing from the list is a good thing... I can take a (better) look tomorrow (quite late here already), or maybe someone else can (double) check

Yeah, I think I might be wording this improperly, but I preserved the difference between closing a page (via the X icon on the page tab in the tab bar) and deleting a page (via the "delete this page" button in the page settings dropdown). Here's a series of screenshots describing the behavior, all are from this PR:

Beginning state: several project tabs
image

I close the "coke hot air" page by clicking the X in the tab bar tab (screen.ClosePage()), and it's still present in the all-pages dropdown. Internally, at this point the page is

  • Present in Project.pages
  • Present in Project.pagesByGuid
  • Not present in Project.displayPages - Project.displayPages
    image
    I can click on the deemphasized text in the extra page list and it comes back. If I then delete the page from the page settings:
    image
    It no longer shows up in the pages list because it's marked for deletion:
    image
  • It's no longer present in Project.pages
  • It's no longer present in Project.pagesByGuid
    Up til now, everything is the same as master.
    In master, in this state, this page is still present in Project.displayPages, so Project.displayPages might actually be longer than project.pages, and definitely would contain content that project.pages does not. In this PR, the guid is removed from Project.displayPages.

However, I can still hit ctrl-z and it will come back and be switchable, including via shift-ctrl-tab:
image

sfoster1 and others added 5 commits July 21, 2024 19:04
Use the common browser interaction ctrl-tab to switch pages forward and alt-tab to switch pages back.

Implementation-wise, we have to break a little layering by using the displayPages list of guids that really only the tab bar is supposed to care about... but we have to call ChangePage in the main screen, so I'm not sure how else to do it.

The other change of note is forcing a focus change when you switch tabs; this is to get any active dropdowns (i.e. the GoodsIcon dropdowns for switching recipes or switching modules) to disappear if you hit control-tab while one is open, since the mouse isn't otherwise moving and clicking like it would be if you switched tabs with the mouse.
- Changelog update
- Clarify just why we're resetting focus there
Also, fix a data consistency issue - the page delete button in the page settings pane wasn't removing the pane from the display pages list, just marking it for deletion. The page still wouldn't be displayed but it would be in the list, which wasn't an issue when we just pick items out of the list based on what's displayed but became an issue when we iterate through it.
Copy link
Collaborator

@veger veger left a comment

Choose a reason for hiding this comment

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

Thanks for your extended explanation, this is indeed the intended behavior.

@veger veger merged commit fba039f into shpaass:master Jul 22, 2024
1 check passed
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