Skip to content

Workaround to fix text colour not changing in status bar#635

Open
Micheus wants to merge 2 commits intodgud:masterfrom
Micheus:mv/v2.4-fix-themes-colours-issue
Open

Workaround to fix text colour not changing in status bar#635
Micheus wants to merge 2 commits intodgud:masterfrom
Micheus:mv/v2.4-fix-themes-colours-issue

Conversation

@Micheus
Copy link
Copy Markdown
Collaborator

@Micheus Micheus commented Jan 20, 2026

It was noticed that the text color in the status bar doesn't change according
to the theme settings. Looking for info I found that it's an know issue in
wxWidgets which setting the color of native controls is not always possible.

Considering we use the wxFLAT style, drawing the status bar ourselves is the
easiest and most effective way to work around this issue. I included a grip
icon similar to the Windows version, since no system resource is available
for use (as with other system icons).

NOTE:
Fixed a theme issue that was preventing the status bar text from using
its setting in the theme color. Thanks to Nova711 (at Discord).

It was noticed that the text color in the status bar doesn't change according
to the theme settings. Looking for info I found that it's an know issue in
wxWidgets which setting the color of native controls is not always possible.

Considering we use the wxFLAT style, drawing the status bar ourselves is the
easiest and most effective way to work around this issue. I included a grip
icon similar to the Windows version, since no system resource is available
for use (as with other system icons).

NOTE:
Fixed a theme issue that was preventing the status bar text from using
its setting in the theme color. Thanks to Nova711 (on Discord).
@Micheus Micheus force-pushed the mv/v2.4-fix-themes-colours-issue branch from 907f492 to 2e63145 Compare January 20, 2026 23:00
@Micheus
Copy link
Copy Markdown
Collaborator Author

Micheus commented Jan 20, 2026

Here is the current issue:
image

Here after the workaround:
image

@dgud
Copy link
Copy Markdown
Owner

dgud commented Apr 23, 2026

Same here I don't know how this looks on mac, but have no mac to test it with :-/

Ping @bjorng

@dgud
Copy link
Copy Markdown
Owner

dgud commented Apr 23, 2026

Issues

  1. Text colour is never set on the DC — the title bug isn't actually fixed

The PR title says "fix text colour not changing" but custom_draw never calls wxDC:setTextForeground/2. The text will
be drawn in whatever the DC's default foreground colour is (typically black or the system default). So:

  • On a dark theme with light text preference (info_line_text), the text will still be black/default.
  • The background is correctly painted with info_line_bg.

The fix needs a line like:

SFG = wings_color:rgb4bv(wings_pref:get_value(info_line_text)),
wxDC:setTextForeground(DC, SFG),

before the drawText calls. Without this, the PR only fixes the background, not the text colour.

  1. Font is never set on the DC

wxDC:drawText uses the DC's current font, which defaults to the system font. The original wxStatusBar may use a
different font (platform-specific status bar font). The custom draw should call:

wxDC:setFont(DC, wxWindow:getFont(Obj)),

to inherit the status bar's font. Otherwise text may render in a different size/face than expected.

  1. BufferedDC variable is unbound on non-Windows in the cleanup branch

DC = case os:type() of
{win32, _} ->
BufferedDC = wxBufferedPaintDC:new(Obj),
wx:typeCast(BufferedDC, wxPaintDC);
_ ->
BufferedDC = none, %% <-- binds to 'none'
wxPaintDC:new(Obj)
end,
...
case os:type() of
{win32, _} ->
wxBufferedPaintDC:destroy(BufferedDC); %% OK
_ ->
wxPaintDC:destroy(DC) %% OK
end.

This actually works because BufferedDC is bound to none in the non-Windows branch and that branch of the cleanup
doesn't use it. But it's fragile — the variable BufferedDC is bound in both branches of the first case but only used
in one branch of the second case. If someone refactors the cleanup to not duplicate the os:type() check, they could
accidentally call wxBufferedPaintDC:destroy(none).

A cleaner pattern (used elsewhere in Wings, e.g. wings_help.erl:464):

DC = case os:type() of
{win32, _} ->
wx:typeCast(wxBufferedPaintDC:new(Obj), wxPaintDC);
_ ->
wxPaintDC:new(Obj)
end,
%% ... drawing ...
wxPaintDC:destroy(DC). %% works for both since typeCast preserves ref

Actually, looking at wings_help.erl and wings_image_viewer.erl, they all use wxPaintDC:destroy on the typeCast'd DC.
The double os:type() check with separate destroy paths is unnecessary.

  1. Grip is always drawn, even on platforms that don't show one

The resize grip (bottom-right corner dots) is drawn unconditionally. On macOS, the native status bar grip looks
different. On some Linux WMs, there's no grip at all. Drawing a Windows-style grip on all platforms may look out of
place. Consider:

case os:type() of
{win32, _} -> draw_grip(DC, Size, ?GRIP_ROWS);
_ -> ok
end,

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.

2 participants