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

A tab button can now be set to not take the full space within the tab bar, also exposed the button's Background property in TabButton. #140

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

emayevski
Copy link

@emayevski emayevski commented Nov 9, 2024

The problem: imagine you have a tab bar with a TabItem, a TabButton, and a TabItem. The width is 900 px. Each of the entries gets the width of 300 px (by default). The icons and texts of tabitems are centered within the provided 300 px (at positions cca 150 and 750 respectively). Now, if the TabButton is 60 px wide and is centered around point 450, you have a huge empty space from point 150 to point 420 - the distance between 0 and 150 is way lower than the distance between 150 and 420. The centered icon and text at point ~150 appear visually shifted to the left, and those at point ~750 appear shifted to the right. Now, if we give the button the width of 60 px, the left tab item would get the width of 420 px and the left icon and text would be centered around point 210, and thus appear centered between the left edge and the button. The same would apply to the tab item.

A similar problem, albeit less visible, would occur with four tab items and a tab button.

The solution: included in this revision. It is optional and the default is the same as before in order not to break other users' design.

A tab button can now be set to not take the full space (width for horizontal tab bars and height for vertical tab bars) of the bar item but be constrained to its necessary size. This lets other tab items be sized appropriately, taking all visible empty space and centering their icon or text appropriately. The behavior is controlled by the added ExpandToTabSize property of TabButton (the default value is true to keep the previous behavior).

Additionally, I have exposed the internal button's Background property in TabButton in order to be able to customize the brush (I needed a gradient tab button).

emayevski and others added 2 commits November 9, 2024 14:47
…izontal tab bars and height for vertical tab bars) of the bar item but be constrained to its necessary size. This lets other tab items be sized appropriately, taking all visible empty space and centering their icon or text appropriately. The behavios is controlled by the added ExpandToTabSize property of TabButton (the default value is true to keep the previous behavior).
@emayevski emayevski changed the title A tab button can now be set to not take the full space within the tab bar. A tab button can now be set to not take the full space within the tab bar, also exposed the button's Background property in TabButton. Nov 11, 2024
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.

1 participant