diff options
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/container.rs | 40 | ||||
-rw-r--r-- | widget/src/image/viewer.rs | 5 | ||||
-rw-r--r-- | widget/src/lib.rs | 2 | ||||
-rw-r--r-- | widget/src/scrollable.rs | 2 |
4 files changed, 45 insertions, 4 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs index 82dc3141..86c1c7a8 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -26,6 +26,7 @@ use crate::core::layout; use crate::core::mouse; use crate::core::overlay; use crate::core::renderer; +use crate::core::theme; use crate::core::widget::tree::{self, Tree}; use crate::core::widget::{self, Operation}; use crate::core::{ @@ -714,9 +715,44 @@ pub fn bordered_box(theme: &Theme) -> Style { /// A [`Container`] with a dark background and white text. pub fn dark(_theme: &Theme) -> Style { + style(theme::palette::Pair { + color: color!(0x111111), + text: Color::WHITE, + }) +} + +/// A [`Container`] with a primary background color. +pub fn primary(theme: &Theme) -> Style { + let palette = theme.extended_palette(); + + style(palette.primary.base) +} + +/// A [`Container`] with a secondary background color. +pub fn secondary(theme: &Theme) -> Style { + let palette = theme.extended_palette(); + + style(palette.secondary.base) +} + +/// A [`Container`] with a success background color. +pub fn success(theme: &Theme) -> Style { + let palette = theme.extended_palette(); + + style(palette.success.base) +} + +/// A [`Container`] with a danger background color. +pub fn danger(theme: &Theme) -> Style { + let palette = theme.extended_palette(); + + style(palette.danger.base) +} + +fn style(pair: theme::palette::Pair) -> Style { Style { - background: Some(color!(0x111111).into()), - text_color: Some(Color::WHITE), + background: Some(pair.color.into()), + text_color: Some(pair.text), border: border::rounded(2), ..Style::default() } diff --git a/widget/src/image/viewer.rs b/widget/src/image/viewer.rs index 06652ff7..811241a9 100644 --- a/widget/src/image/viewer.rs +++ b/widget/src/image/viewer.rs @@ -215,6 +215,7 @@ where } } + shell.request_redraw(); shell.capture_event(); } Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => { @@ -226,6 +227,8 @@ where state.cursor_grabbed_at = Some(cursor_position); state.starting_offset = state.current_offset; + + shell.request_redraw(); shell.capture_event(); } Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => { @@ -233,6 +236,7 @@ where if state.cursor_grabbed_at.is_some() { state.cursor_grabbed_at = None; + shell.request_redraw(); shell.capture_event(); } } @@ -273,6 +277,7 @@ where }; state.current_offset = Vector::new(x, y); + shell.request_redraw(); shell.capture_event(); } } diff --git a/widget/src/lib.rs b/widget/src/lib.rs index b8cfa98f..31dcc205 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -12,7 +12,6 @@ mod action; mod column; mod mouse_area; mod pin; -mod row; mod space; mod stack; mod themer; @@ -28,6 +27,7 @@ pub mod pick_list; pub mod pop; pub mod progress_bar; pub mod radio; +pub mod row; pub mod rule; pub mod scrollable; pub mod slider; diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 8adf5136..fe71fd6b 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -753,7 +753,7 @@ where if let InputMethod::Open { position, .. } = shell.input_method_mut() { - *position = *position + translation; + *position = *position - translation; } } }; |