fltk-rs / fltk-theme

A theming crate for fltk-rs
MIT License
94 stars 7 forks source link

Use native theme in KDE #5

Open RangerMauve opened 1 year ago

RangerMauve commented 1 year ago

Hey, is there a way to get the app to use the OS's theming in KDE (or even in GTK?).

It seems that out of the box it's using the default GTK theme rather than the one configured by the user. As a result any apps built with fltk will look off.

MoAlyousef commented 1 year ago

Hi You can try FLTK's app::get_system_colors() , which will attempt to get X11 colormap settings, usually set by the DE. This will only affect the colors though. The shape of widgets follows the app::scheme, or in fltk-theme, is custom drawn by overriding some drawing functions.

RangerMauve commented 1 year ago

Hmm, it doesn't seem to have changed anything. I tried calling that API before creating any UI elements and just before calling app.run() and neither option had a visible effect. It just had the default grey theme.

MoAlyousef commented 1 year ago

I’m interested to know what environment you’re using. I tried it on a kubuntu machine on X11, the color becomes nearly white.
Are you perhaps using KDE on wayland?

RangerMauve commented 1 year ago

This is with KDE Plasma 5.26.4 with X11 on Manjaro Linux.

It's on a 10th generation Intel core if that makes a difference. 🤔

use fltk_theme::{ColorTheme, color_themes};
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};

fn main() -> Result<(), Box<dyn Error>> {
    let app = app::App::default();
    app::get_system_colors();

    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
    let mut frame = Frame::new(0, 0, 400, 200, "");
    let mut but = Button::new(160, 210, 80, 40, "Click me!");
    wind.end();
    wind.show();

    println!("Wow OK we exited!");

    Ok(())
}

Screenshot_20230108_170251

RangerMauve commented 1 year ago

This is what my GTK theme should look like according to the preview thingie in Plasma:

Screenshot_20230108_170507

MoAlyousef commented 1 year ago

It seems KDE plasma stores themes in $HOME/.local/share/plasma/desktoptheme//. The colors are in a colors subdirectory of the theme. I'm not sure where the current global theme is set in the system though. Maybe adding a light/dark Oxygen (or breeze) theme to this crate might give a less out of touch UI on KDE desktops. But I think adding logic to check system files to determine which is the current theme and the theme's details would be too much for this crate.