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

Added dark mode support for Linux #4415

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

calvindo95
Copy link

@calvindo95 calvindo95 commented Jul 1, 2024

Spent a couple days learning about wxWidgets/GTK/BambuStudio and added the ability to enable/disable dark mode for Linux, which potentially resolves #3542

Linux dark mode uses the existing settings.conf variable "dark_color_mode".

This feature uses GTK's gtk-theme-name setting to change themes from dark <--> light mode, but it has some undocumented behaviors that need testing from other Linux users.

  1. When setting gtk-theme-name, an invalid theme will result in GTK using the default theme of Adwaita (light mode). In my feature to set light mode I use an invalid theme of " ", which defaults to Adwaita.
  2. For dark mode, I supply an empty theme of "", which is not in GTK's documentation and probably need other users to test this to make sure it actually activates dark mode.

This has been tested on my system:
Kubuntu 24.04
KDE Plasma Breeze-Dark

This feature needs people using different Distros and GTK themes to test this

UPDATE: I've now added a fix for illegible text in dark and light mode which resolves #3538 and resolves #2731

@calvindo95
Copy link
Author

calvindo95 commented Jul 4, 2024

I've now added a fix for illegible text in dark and light mode which resolves #3538 and resolves #2731

The GUI uses a map of predetermined color values to use when switching from dark <--> light mode. After lots of debugging, in dark mode it uses {"#FFFFFF", "#2D2D31"} and {"#A6A9AA", "#2D2D29"} to switch light to dark mode of the background and foreground(text) respectively.

In RGB values the map would look like {"(255, 255, 255)", "(45, 45, 45)"} for the background and {"(166, 169, 170)", "(45, 45, 41)"} for the foreground. Based on this light to dark mode conversion, background is set to (45, 45, 45) and foreground is (45, 45, 41) making it basically impossible to read the text.

Light mode is a similar issue, but there seems to still be a slight issue where the text is a bit light (an issue where there is no predefined conversion in the color map). However, it's still very much readable after my fix.

I've now added logic if the background and foreground colors are similar (FG is within +/-10 of BG RGB values), invert the foreground color to make the text legible.

@NattieGit
Copy link

Hi there @lanewei120 @walterwongbbl,

Thank you for all your hard work on this project. I'm really looking forward to this fix! I understand maintaining an open-source project can be time-consuming. Do you have any idea when PRs like this usually get reviewed, merged, and released? It would be greatly appreciated by me and other Linux users who are affected by this issue.

Thanks again!

@MackBambu
Copy link
Contributor

@calvindo95 hi, I repackaged the code to test on ubuntu 24.04 and it doesn't work.
https://github.com/MackBambu/BambuStudio/actions/runs/10142071008

图片
图片

@cmeans
Copy link

cmeans commented Sep 6, 2024

Hey!

I just switched to a Fedora 40 Gnome laptop, and installed BambuStudio 19.5.51 (flatpak). Still no Dark Mode. Would be happy to test if you need it.

-Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants