theme: store colors in linear space
This commit is contained in:
parent
b7f93b37a6
commit
135f37dbcd
27 changed files with 221 additions and 135 deletions
|
|
@ -67,18 +67,18 @@ fn create_accept_gui(surface: &Rc<SelectionGuiSurface>) -> Rc<dyn GuiElement> {
|
|||
let accept_button = static_button(surface, ButtonRole::Accept, "Allow");
|
||||
let reject_button = static_button(surface, ButtonRole::Reject, "Reject");
|
||||
for button in [&accept_button, &reject_button] {
|
||||
button.border_color.set(Color::from_gray(100));
|
||||
button.border_color.set(Color::from_gray_srgb(100));
|
||||
button.border.set(2.0);
|
||||
button.padding.set(5.0);
|
||||
}
|
||||
accept_button.bg_color.set(Color::from_rgb(170, 200, 170));
|
||||
accept_button.bg_color.set(Color::from_srgb(170, 200, 170));
|
||||
accept_button
|
||||
.bg_hover_color
|
||||
.set(Color::from_rgb(170, 255, 170));
|
||||
reject_button.bg_color.set(Color::from_rgb(200, 170, 170));
|
||||
.set(Color::from_srgb(170, 255, 170));
|
||||
reject_button.bg_color.set(Color::from_srgb(200, 170, 170));
|
||||
reject_button
|
||||
.bg_hover_color
|
||||
.set(Color::from_rgb(255, 170, 170));
|
||||
.set(Color::from_srgb(255, 170, 170));
|
||||
let flow = Rc::new(Flow::default());
|
||||
flow.orientation.set(Orientation::Vertical);
|
||||
flow.cross_align.set(Align::Center);
|
||||
|
|
|
|||
|
|
@ -87,22 +87,22 @@ fn create_accept_gui(surface: &Rc<SelectionGuiSurface>, for_restore: bool) -> Rc
|
|||
&window_button,
|
||||
&reject_button,
|
||||
] {
|
||||
button.border_color.set(Color::from_gray(100));
|
||||
button.border_color.set(Color::from_gray_srgb(100));
|
||||
button.border.set(2.0);
|
||||
button.padding.set(5.0);
|
||||
}
|
||||
restore_button.bg_color.set(Color::from_rgb(170, 170, 200));
|
||||
restore_button.bg_color.set(Color::from_srgb(170, 170, 200));
|
||||
restore_button
|
||||
.bg_hover_color
|
||||
.set(Color::from_rgb(170, 170, 255));
|
||||
.set(Color::from_srgb(170, 170, 255));
|
||||
for button in [&accept_button, &workspace_button, &window_button] {
|
||||
button.bg_color.set(Color::from_rgb(170, 200, 170));
|
||||
button.bg_hover_color.set(Color::from_rgb(170, 255, 170));
|
||||
button.bg_color.set(Color::from_srgb(170, 200, 170));
|
||||
button.bg_hover_color.set(Color::from_srgb(170, 255, 170));
|
||||
}
|
||||
reject_button.bg_color.set(Color::from_rgb(200, 170, 170));
|
||||
reject_button.bg_color.set(Color::from_srgb(200, 170, 170));
|
||||
reject_button
|
||||
.bg_hover_color
|
||||
.set(Color::from_rgb(255, 170, 170));
|
||||
.set(Color::from_srgb(255, 170, 170));
|
||||
let flow = Rc::new(Flow::default());
|
||||
flow.orientation.set(Orientation::Vertical);
|
||||
flow.cross_align.set(Align::Center);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
consts::{CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE},
|
||||
},
|
||||
rect::Rect,
|
||||
theme::Color,
|
||||
theme::{Color, TransferFunction},
|
||||
},
|
||||
std::{ops::Neg, rc::Rc, sync::Arc},
|
||||
};
|
||||
|
|
@ -78,9 +78,9 @@ pub fn render(
|
|||
let data = create_data(font, width, height, scale)?;
|
||||
data.layout.set_text(text);
|
||||
let font_height = data.layout.pixel_size().1;
|
||||
let [r, g, b, a] = color.to_array(TransferFunction::Srgb);
|
||||
data.cctx.set_operator(CAIRO_OPERATOR_SOURCE);
|
||||
data.cctx
|
||||
.set_source_rgba(color.r as _, color.g as _, color.b as _, color.a as _);
|
||||
data.cctx.set_source_rgba(r as _, g as _, b as _, a as _);
|
||||
let y = y.unwrap_or((height - font_height) / 2);
|
||||
data.cctx.move_to(x as f64, y as f64);
|
||||
data.layout.show_layout();
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ impl Default for Button {
|
|||
hover: Default::default(),
|
||||
padding: Default::default(),
|
||||
border: Default::default(),
|
||||
border_color: Cell::new(Color::from_gray(0)),
|
||||
bg_color: Cell::new(Color::from_gray(255)),
|
||||
bg_hover_color: Cell::new(Color::from_gray(255)),
|
||||
border_color: Cell::new(Color::from_gray_srgb(0)),
|
||||
bg_color: Cell::new(Color::from_gray_srgb(255)),
|
||||
bg_hover_color: Cell::new(Color::from_gray_srgb(255)),
|
||||
text: Default::default(),
|
||||
font: Arc::new(DEFAULT_FONT.to_string()),
|
||||
tex: Default::default(),
|
||||
|
|
@ -172,7 +172,7 @@ impl GuiElement for Button {
|
|||
None,
|
||||
&self.font,
|
||||
&text,
|
||||
Color::from_gray(0),
|
||||
Color::from_gray_srgb(0),
|
||||
Some(scale as _),
|
||||
true,
|
||||
);
|
||||
|
|
@ -296,7 +296,7 @@ impl GuiElement for Label {
|
|||
None,
|
||||
&self.font,
|
||||
&text,
|
||||
Color::from_gray(255),
|
||||
Color::from_gray_srgb(255),
|
||||
Some(scale as _),
|
||||
false,
|
||||
);
|
||||
|
|
@ -635,7 +635,7 @@ impl WindowData {
|
|||
AcquireSync::Implicit,
|
||||
ReleaseSync::Implicit,
|
||||
self.scale.get(),
|
||||
Some(&Color::from_gray(0)),
|
||||
Some(&Color::from_gray_srgb(0)),
|
||||
None,
|
||||
&mut |r| {
|
||||
if let Some(content) = self.content.get() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue