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

Auto-size buttons in bottom panels #3576

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented May 2, 2022

Problems

  • The bottom right button in Delete Directories is supposed to say "Delete Checked," since only the folders with checked checkboxes will be deleted, but on Windows it only says "Delete":
    <data name="DeleteButton.Text" xml:space="preserve"><value>Delete Checked</value></data>

    screenshot
    • This potentially can happen anywhere, especially if a translator picks a long string for a button
  • The text of the progress bar screen's log text box is unreadable black-on-dark when I install things in Windows using the dark theme from Theme all buttons, checkboxes, groupboxes, and listboxes #3489, but readable light-on-dark for refreshing the mod list and repo updates.

Causes

  • Most of our buttons use Anchor to position themselves and have hard coded sizes, and if those sizes aren't big enough to fit the text, it is truncated. Due to differences in fonts, we have enough space for "Delete Checked" on Linux bot not on Windows.
  • The ForeColor we set is ignored because we aren't setting BackColor. The text color change happens because MainTabControl is disabled, which cascades into disabling the log text box.

Changes

  • A new LeftRightRowPanel control hosts two groups of controls, one in .LeftControls and the other in .RightControls. These are passed through to a pair of FlowLayoutPanels, which themselves are hosted in the cells of a one-row TableLayoutPanel. Controls hosted in such a way will be positioned nicely while also being able to autosize themselves.
    • Most of the controls where we have a BottomButtonPanel now use LeftRightRowPanel for it, and the buttons contained therein have autosizing enabled in GrowOnly mode, so they will expand if needed to fit their contents but otherwise keep a nice friendly width for easy clicking:
      image
      As a bonus, the buttons even wrap nicely when space is very limited:
      image
    • The exception is the add repo popup, which has several non-Button controls on its BottomButtonPanel which cannot be easily split into left and right flow layout groups. This panel is now renamed BottomPanel to distinguish it from the ones that only contain Buttons.
    • The Depends/Recommends/etc. buttons in Export Modpack are radio buttons, which have an AutoSize property but not AutoSizeMode, so we have to choose between static sizes and making them smaller in some cases. For now I have left them with static sizes.
    • Since this layout logic is more robust than what we had before, the "Retry" and "Cancel" buttons on the progress bar tab are now hidden rather than disabled when they're not usable. And the update repo action is now properly treated as non-cancellable.
  • Now we set the log text box's BackColor, which makes the text color render correctly in all cases. The disabling of MainTabControl is replaced with calls to tabController.SetTabLock, which is how we are supposed to disable the tab control.
  • The splitter in mod info is now set to treat its top panel as fixed size, which should make it less likely to end up weird sizes.

@HebaruSan HebaruSan added Bug Enhancement GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows labels May 2, 2022
@HebaruSan HebaruSan requested a review from DasSkelett May 2, 2022 22:11
Copy link
Member

@techman83 techman83 left a comment

Choose a reason for hiding this comment

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

Looks like a good enhancement 🎉

@HebaruSan HebaruSan merged commit 988ff23 into KSP-CKAN:master Aug 4, 2022
@HebaruSan HebaruSan deleted the fix/gui-buttons-layout branch August 4, 2022 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Enhancement GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants