-
-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Add support for custom font colors in the TabBar #106263
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
base: master
Are you sure you want to change the base?
Conversation
26397e2
to
cb79183
Compare
Admittedly this is lot of API for a relatively simple change. I'm curious what others think about using the |
I reduced the size of the API from eight to the three functions seen below: extends TabContainer
func _ready():
var color = get_tab_bar().get_font_color_override(BaseButton.DRAW_DISABLED, 3)
get_tab_bar().set_font_color_override(BaseButton.DRAW_PRESSED, 0, Color.DEEP_PINK)
get_tab_bar().set_font_color_override_all(2, Color.YELLOW) This should hopefully make it easier to use, and behind the scenes it is neater, using an array of Colors instead of individual variables. Feedback is welcome on the specific enum used. Another option would be to have a |
d1d04b9
to
4c302b0
Compare
4c302b0
to
26ea808
Compare
I updated to use a extends TabContainer
func _ready():
var color = get_tab_bar().get_font_color_override(0, TabBar.DRAW_DISABLED)
get_tab_bar().set_font_color_override(1, TabBar.DRAW_PRESSED, Color.DEEP_PINK)
get_tab_bar().set_font_color_override_all(2, Color.YELLOW) |
While I somewhat like the new API, for the purpose of coloring bottom panel you only need Also, since the user will not have access to the tabs directly, it does not even need to be exposed. If you want to set color of a dock's tab, it can be exposed as a property of EditorDock. Docks aside, the proposal you linked does not mention tab colors, only italics text. |
I can hide these so they are just for internal use for now. I can't gauge community interest in this specific feature, its creation was motivated by compatibility for the bottom panel. |
scene/gui/tab_bar.cpp
Outdated
@@ -521,13 +521,13 @@ void TabBar::_notification(int p_what) { | |||
|
|||
if (tabs[i].disabled) { | |||
sb = theme_cache.tab_disabled_style; | |||
col = theme_cache.font_disabled_color; | |||
col = tabs[i].font_color_overrides[DrawMode::DRAW_DISABLED].a > 0 ? tabs[i].font_color_overrides[DrawMode::DRAW_DISABLED] : theme_cache.font_disabled_color; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be replaced by a method, like _select_color(tabs[i].font_color_overrides[DrawMode::DRAW_DISABLED], theme_cache.font_disabled_color)
. More readable and less repetitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to make that a macro instead, as the logic is just one line? Or would an inline function make more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods are better than macros. You can make a static function in cpp file, we use them sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is primarily made for #106164, however there is some extra stuff that likely won't be needed. Though if it's internal we can easily remove it I guess. Overall looks ok.
fbb9801
to
59a4e4c
Compare
Could you confirm that the static function has the right qualifiers? Copied below:
|
Partially Addresses: godotengine/godot-proposals#9161
Related: #88709, #106164
The inspiration for this PR was #106164 and the desire to set a custom color for the
Output
andDebugger
tabs now that they are within a TabBar, but there is a desire to do such, as evidenced by the previous proposal.Currently it is impossible to set colors individually for tabs in a TabBar. This PR adds support to set custom overrides for the selected, unselected, hovered, and disabled colors on a per tab basis.