wgui: use dark mode

This commit is contained in:
Aleksander
2025-09-20 13:32:07 +02:00
parent 0f82fb4144
commit aadf11590e
8 changed files with 23 additions and 7 deletions

View File

@@ -52,6 +52,7 @@ impl Frontend {
let globals = WguiGlobals::new(
Box::new(assets::Asset {}),
wgui::globals::Defaults {
dark_mode: true,
text_color: drawing::Color::new(1.0, 1.0, 1.0, 1.0),
},
)?;

View File

@@ -1,7 +1,7 @@
<layout>
<elements>
<rectangle
color="#AAAAAA"
color="#888888"
width="1000" height="500" min_width="1000" min_height="500"
gap="4" flex_direction="column"
overflow_y="scroll">
@@ -24,7 +24,7 @@
<CheckBox text="i'm checked by default" checked="1" />
</div>
<label text="custom attrib test, you should see size rectangles below, each of them in R, G and B (if TESTBED is generic)" />
<label text="custom attrib test, you should see size rectangles below, each of them in R, G and B (if TESTBED is not set)" />
<div flex_direction="row" gap="8">
<label text="lighter:" />

View File

@@ -21,7 +21,13 @@ impl TestbedAny {
pub fn new(name: &str, listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
let path = format!("gui/{name}.xml");
let globals = WguiGlobals::new(Box::new(assets::Asset {}), Default::default())?;
let globals = WguiGlobals::new(
Box::new(assets::Asset {}),
wgui::globals::Defaults {
dark_mode: true,
text_color: wgui::drawing::Color::new(1.0, 1.0, 1.0, 1.0),
},
)?;
let (layout, state) = wgui::parser::new_layout_from_assets(
listeners,

View File

@@ -59,7 +59,13 @@ impl TestbedGeneric {
pub fn new(listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
const XML_PATH: &str = "gui/various_widgets.xml";
let globals = WguiGlobals::new(Box::new(assets::Asset {}), Default::default())?;
let globals = WguiGlobals::new(
Box::new(assets::Asset {}),
wgui::globals::Defaults {
text_color: wgui::drawing::Color::new(1.0, 1.0, 1.0, 1.0),
dark_mode: true,
},
)?;
let extra = ParseDocumentExtra {
on_custom_attribs: Some(Box::new(move |par| {

View File

@@ -386,6 +386,7 @@ pub fn construct<U1, U2>(
WidgetLabelParams {
content: Translation::default(),
style: TextStyle {
color: Some(drawing::Color::new(0.0, 0.0, 0.0, 0.75)), // always black
weight: Some(FontWeight::Bold),
align: Some(HorizontalAlign::Center),
..Default::default()

View File

@@ -6,12 +6,14 @@ use std::{
use crate::{assets::AssetProvider, drawing, i18n::I18n};
pub struct Defaults {
pub dark_mode: bool,
pub text_color: drawing::Color,
}
impl Default for Defaults {
fn default() -> Self {
Self {
dark_mode: true,
text_color: drawing::Color::new(0.0, 0.0, 0.0, 1.0),
}
}

View File

@@ -22,8 +22,7 @@
<rectangle padding="8" gap="8" round="100%" color="~bg_color_active" justify_content="center" align_items="center">
<label size="18" translation="BAR.OPACITY" color="~text_color" />
<Slider width="150" height="24" min_value="0" max_value="100" value="100" />
<label size="18" translation="BAR.ADDITIVE" color="~text_color" />
<sprite color="~device_color" width="20" height="20" src="bar/checkbox-checked.svg" />
<CheckBox translation="BAR.ADDITIVE" color="~text_color" />
</rectangle>
</div>
</elements>

View File

@@ -1,7 +1,7 @@
use glam::Affine3A;
use idmap::IdMap;
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
use std::sync::Arc;
use wgui::{
gfx::WGfx, globals::WguiGlobals, renderer_vk::context::SharedContext as WSharedContext,
@@ -97,6 +97,7 @@ impl AppState {
wgui_globals: WguiGlobals::new(
Box::new(gui::asset::GuiAsset {}),
wgui::globals::Defaults {
dark_mode: true,
text_color: wgui::drawing::Color::new(1.0, 1.0, 1.0, 1.0),
},
)?,