mirror of
https://github.com/danbulant/cushy
synced 2026-06-19 06:21:15 +00:00
parent
8a9fb24fe0
commit
f85b2f988b
7 changed files with 83 additions and 27 deletions
|
|
@ -3,7 +3,12 @@
|
|||
[](https://gooey.rs/main/docs/gooey/)
|
||||
|
||||
Gooey is an experimental Graphical User Interface (GUI) crate for the Rust
|
||||
programming language. It is powered by:
|
||||
programming language. It features a reactive data model and aims to enable
|
||||
easily creating responsive, efficient user interfaces. To enable easy
|
||||
cross-platform development, Gooey uses its own collection of consistently-styled
|
||||
[`Widget`s][widget].
|
||||
|
||||
Gooey is powered by:
|
||||
|
||||
- [`Kludgine`][kludgine], a 2d graphics library powered by:
|
||||
- [`winit`][winit] for windowing/input
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@
|
|||
[]($docs$)
|
||||
|
||||
Gooey is an experimental Graphical User Interface (GUI) crate for the Rust
|
||||
programming language. It is powered by:
|
||||
programming language. It features a reactive data model and aims to enable
|
||||
easily creating responsive, efficient user interfaces. To enable easy
|
||||
cross-platform development, Gooey uses its own collection of consistently-styled
|
||||
[`Widget`s][widget].
|
||||
|
||||
Gooey is powered by:
|
||||
|
||||
- [`Kludgine`][kludgine], a 2d graphics library powered by:
|
||||
- [`winit`][winit] for windowing/input
|
||||
|
|
|
|||
|
|
@ -72,6 +72,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `PendingWindow` is a new type that can return a `WindowHandle` for a window
|
||||
that hasn't opened yet. This can be used to allow a widget on a window to
|
||||
close the window.
|
||||
- Style components for customizing default widget colors have been added:
|
||||
- `DefaultForegroundColor`
|
||||
- `DefaultBackgroundColor`
|
||||
- `DefaultHoveredForegroundColor`
|
||||
- `DefaultHoveredBackgroundColor`
|
||||
- `DefaultActiveForegroundColor`
|
||||
- `DefaultActiveBackgroundColor`
|
||||
- `DefaultDisabledForegroundColor`
|
||||
- `DefaultDisabledBackgroundColor`
|
||||
|
||||
[91]: https://github.com/khonsulabs/gooey/issues/91
|
||||
[92]: https://github.com/khonsulabs/gooey/issues/92
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@
|
|||
[](https://gooey.rs/main/docs/gooey/)
|
||||
|
||||
Gooey is an experimental Graphical User Interface (GUI) crate for the Rust
|
||||
programming language. It is powered by:
|
||||
programming language. It features a reactive data model and aims to enable
|
||||
easily creating responsive, efficient user interfaces. To enable easy
|
||||
cross-platform development, Gooey uses its own collection of consistently-styled
|
||||
[`Widget`s][widget].
|
||||
|
||||
Gooey is powered by:
|
||||
|
||||
- [`Kludgine`][kludgine], a 2d graphics library powered by:
|
||||
- [`winit`][winit] for windowing/input
|
||||
|
|
|
|||
|
|
@ -154,6 +154,32 @@ define_components! {
|
|||
TertiaryColor(Color, "tertiary_color", .tertiary.color)
|
||||
/// The error color from the current theme.
|
||||
ErrorColor(Color, "error_color", .error.color)
|
||||
/// The foreground color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default).
|
||||
DefaultForegroundColor(Color, "default_foreground_color", .primary.on_color)
|
||||
/// The background color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default).
|
||||
DefaultBackgroundColor(Color, "default_background_color", .primary.color)
|
||||
/// The foreground color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is hovered by
|
||||
/// the cursor.
|
||||
DefaultHoveredForegroundColor(Color, "default_hovered_foreground_color", @DefaultForegroundColor)
|
||||
/// The background color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is hovered by
|
||||
/// the cursor.
|
||||
DefaultHoveredBackgroundColor(Color, "default_hovered_background_color", .primary.color_bright)
|
||||
/// The foreground color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is activated.
|
||||
DefaultActiveForegroundColor(Color, "default_active_foreground_color", .primary.on_color)
|
||||
/// The background color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is activated.
|
||||
DefaultActiveBackgroundColor(Color, "default_active_background_color", .primary.color_dim)
|
||||
/// The foreground color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is disabled.
|
||||
DefaultDisabledForegroundColor(Color, "default_disabled_foreground_color", .primary.on_color)
|
||||
/// The background color to use when drawing a [default
|
||||
/// widget](crate::widget::MakeWidget::into_default) that is disabled.
|
||||
DefaultDisabledBackgroundColor(Color, "default_disabled_background_color", .primary.color_dim)
|
||||
/// Intrinsic, uniform padding for a widget.
|
||||
///
|
||||
/// This component is opt-in and does not automatically work for all widgets.
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@ use crate::context::{
|
|||
AsEventContext, EventContext, GraphicsContext, LayoutContext, WidgetCacheKey, WidgetContext,
|
||||
};
|
||||
use crate::styles::components::{
|
||||
AutoFocusableControls, Easing, HighlightColor, IntrinsicPadding, OpaqueWidgetColor,
|
||||
OutlineColor, SurfaceColor, TextColor,
|
||||
AutoFocusableControls, DefaultActiveBackgroundColor, DefaultActiveForegroundColor,
|
||||
DefaultBackgroundColor, DefaultDisabledBackgroundColor, DefaultDisabledForegroundColor,
|
||||
DefaultForegroundColor, DefaultHoveredBackgroundColor, DefaultHoveredForegroundColor, Easing,
|
||||
HighlightColor, IntrinsicPadding, OpaqueWidgetColor, OutlineColor, SurfaceColor, TextColor,
|
||||
};
|
||||
use crate::styles::{ColorExt, Styles};
|
||||
use crate::utils::ModifiersExt;
|
||||
|
|
@ -69,46 +71,46 @@ impl ButtonKind {
|
|||
match self {
|
||||
ButtonKind::Solid => match visual_state {
|
||||
VisualState::Normal => ButtonColors {
|
||||
background: context.theme().primary.color,
|
||||
foreground: context.theme().primary.on_color,
|
||||
background: context.get(&DefaultBackgroundColor),
|
||||
foreground: context.get(&DefaultForegroundColor),
|
||||
outline: context.get(&ButtonOutline),
|
||||
},
|
||||
VisualState::Hovered => ButtonColors {
|
||||
background: context.theme().primary.color_bright,
|
||||
foreground: context.theme().primary.on_color,
|
||||
background: context.get(&DefaultHoveredBackgroundColor),
|
||||
foreground: context.get(&DefaultHoveredForegroundColor),
|
||||
outline: context.get(&ButtonHoverOutline),
|
||||
},
|
||||
VisualState::Active => ButtonColors {
|
||||
background: context.theme().primary.color_dim,
|
||||
foreground: context.theme().primary.on_color,
|
||||
background: context.get(&DefaultActiveBackgroundColor),
|
||||
foreground: context.get(&DefaultActiveForegroundColor),
|
||||
outline: context.get(&ButtonActiveOutline),
|
||||
},
|
||||
VisualState::Disabled => ButtonColors {
|
||||
background: context.theme().primary.color_dim,
|
||||
foreground: context.theme().primary.on_color,
|
||||
background: context.get(&DefaultDisabledBackgroundColor),
|
||||
foreground: context.get(&DefaultDisabledForegroundColor),
|
||||
outline: context.get(&ButtonDisabledOutline),
|
||||
},
|
||||
},
|
||||
ButtonKind::Outline | ButtonKind::Transparent => match visual_state {
|
||||
VisualState::Normal => ButtonColors {
|
||||
background: context.get(&ButtonOutline),
|
||||
foreground: context.theme().primary.color,
|
||||
outline: context.theme().primary.color,
|
||||
foreground: context.get(&DefaultBackgroundColor),
|
||||
outline: context.get(&DefaultBackgroundColor),
|
||||
},
|
||||
VisualState::Hovered => ButtonColors {
|
||||
background: context.get(&ButtonHoverOutline),
|
||||
foreground: context.theme().primary.color,
|
||||
outline: context.theme().primary.color_bright,
|
||||
foreground: context.get(&DefaultHoveredBackgroundColor),
|
||||
outline: context.get(&DefaultHoveredBackgroundColor),
|
||||
},
|
||||
VisualState::Active => ButtonColors {
|
||||
background: context.get(&ButtonActiveOutline),
|
||||
foreground: context.theme().primary.color,
|
||||
outline: context.theme().surface.color,
|
||||
foreground: context.get(&DefaultActiveBackgroundColor),
|
||||
outline: context.get(&DefaultActiveBackgroundColor),
|
||||
},
|
||||
VisualState::Disabled => ButtonColors {
|
||||
background: context.get(&ButtonDisabledOutline),
|
||||
foreground: context.theme().primary.on_color,
|
||||
outline: context.theme().primary.color_dim,
|
||||
foreground: context.get(&DefaultDisabledBackgroundColor),
|
||||
outline: context.get(&DefaultDisabledBackgroundColor),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use std::error::Error;
|
|||
use std::fmt::Display;
|
||||
use std::ops::Not;
|
||||
|
||||
use kludgine::figures::units::{Lp, Px};
|
||||
use kludgine::figures::{Point, Rect, ScreenScale, Size};
|
||||
use kludgine::figures::units::Lp;
|
||||
use kludgine::figures::{Point, Rect, Round, ScreenScale, Size};
|
||||
use kludgine::shapes::{PathBuilder, Shape, StrokeOptions};
|
||||
|
||||
use crate::context::{GraphicsContext, LayoutContext};
|
||||
|
|
@ -183,15 +183,19 @@ impl Widget for CheckboxOrnament {
|
|||
.width
|
||||
.min(context.gfx.region().size.height);
|
||||
|
||||
let stroke_options =
|
||||
StrokeOptions::px_wide(Lp::points(2).into_px(context.gfx.scale()).round());
|
||||
|
||||
let half_line = stroke_options.line_width / 2;
|
||||
|
||||
let checkbox_rect = Rect::new(
|
||||
Point::new(
|
||||
Px::ZERO,
|
||||
(context.gfx.region().size.height - checkbox_size) / 2,
|
||||
half_line,
|
||||
(context.gfx.region().size.height - checkbox_size) / 2 + half_line,
|
||||
),
|
||||
Size::squared(checkbox_size),
|
||||
Size::squared(checkbox_size - stroke_options.line_width),
|
||||
);
|
||||
|
||||
let stroke_options = StrokeOptions::lp_wide(Lp::points(2)).into_px(context.gfx.scale());
|
||||
match self.value.get_tracking_redraw(context) {
|
||||
state @ (CheckboxState::Checked | CheckboxState::Indeterminant) => {
|
||||
let color = context.get(&WidgetAccentColor);
|
||||
|
|
|
|||
Loading…
Reference in a new issue