first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -8,7 +8,7 @@ license.workspace = true
|
||||
[dependencies]
|
||||
pathfinder_color.workspace = true
|
||||
pathfinder_geometry.workspace = true
|
||||
galaxyui.workspace = true
|
||||
galaxyui_core.workspace = true
|
||||
galaxy_core.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -16,4 +16,5 @@ anyhow.workspace = true
|
||||
asset_cache.workspace = true
|
||||
rust-embed.workspace = true
|
||||
rustls.workspace = true
|
||||
galaxyui.workspace = true
|
||||
galaxy_core = { workspace = true, features = ["test-util"] }
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
use std::{borrow::Cow, sync::Arc, time::Duration};
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use galaxy_core::ui::{Icon, appearance::Appearance, theme::color::internal_colors};
|
||||
use galaxyui::{
|
||||
AssetProvider, SingletonEntity, Tracked,
|
||||
assets::asset_cache::{AssetCache, AssetSource, AssetState},
|
||||
r#async::Timer,
|
||||
elements::Stack,
|
||||
image_cache::ImageType,
|
||||
keymap::FixedBinding,
|
||||
platform,
|
||||
prelude::*,
|
||||
};
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
use rust_embed::RustEmbed;
|
||||
use ui_components::{
|
||||
Component as _, Options, button, dialog,
|
||||
lightbox::{self, LightboxImage, LightboxImageSource, NavigationDirection},
|
||||
switch, tooltip,
|
||||
};
|
||||
use ui_components::lightbox::{self, LightboxImage, LightboxImageSource, NavigationDirection};
|
||||
use ui_components::{Component as _, Options, button, dialog, switch, tooltip};
|
||||
use galaxy_core::ui::Icon;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::theme::color::internal_colors;
|
||||
use galaxyui_core::assets::asset_cache::{AssetCache, AssetSource, AssetState};
|
||||
use galaxyui_core::r#async::Timer;
|
||||
use galaxyui_core::elements::Stack;
|
||||
use galaxyui_core::image_cache::ImageType;
|
||||
use galaxyui_core::keymap::FixedBinding;
|
||||
use galaxyui_core::prelude::*;
|
||||
use galaxyui_core::{AssetProvider, SingletonEntity, Tracked, platform};
|
||||
|
||||
#[derive(Clone, Copy, RustEmbed)]
|
||||
#[folder = "../../app/assets"]
|
||||
@@ -37,14 +35,17 @@ impl AssetProvider for Assets {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> galaxyui::platform::app::TerminationResult {
|
||||
fn main() -> galaxyui_core::platform::app::TerminationResult {
|
||||
// Initialize the TLS provider so reqwest can make HTTPS requests.
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("must be able to initialize crypto provider for TLS support");
|
||||
|
||||
let app_builder =
|
||||
platform::AppBuilder::new(platform::AppCallbacks::default(), Box::new(ASSETS), None);
|
||||
let app_builder = warpui::platform::AppBuilder::new(
|
||||
platform::AppCallbacks::default(),
|
||||
Box::new(ASSETS),
|
||||
None,
|
||||
);
|
||||
app_builder.run(move |ctx| {
|
||||
let font_name = if cfg!(target_os = "macos") {
|
||||
".AppleSystemUIFont".to_string()
|
||||
@@ -54,7 +55,7 @@ fn main() -> galaxyui::platform::app::TerminationResult {
|
||||
"Noto Sans".to_string()
|
||||
};
|
||||
|
||||
let font_family = galaxyui::fonts::Cache::handle(ctx).update(ctx, |cache, _ctx| {
|
||||
let font_family = galaxyui_core::fonts::Cache::handle(ctx).update(ctx, |cache, _ctx| {
|
||||
cache.load_system_font(&font_name).unwrap()
|
||||
});
|
||||
ctx.add_singleton_model(|ctx| {
|
||||
@@ -64,7 +65,7 @@ fn main() -> galaxyui::platform::app::TerminationResult {
|
||||
});
|
||||
|
||||
{
|
||||
use galaxyui::keymap::macros::*;
|
||||
use galaxyui_core::keymap::macros::*;
|
||||
let lightbox_open = id!("RootView") & id!("RootView_LightboxOpen");
|
||||
ctx.register_fixed_bindings([
|
||||
FixedBinding::new(
|
||||
@@ -82,7 +83,7 @@ fn main() -> galaxyui::platform::app::TerminationResult {
|
||||
]);
|
||||
}
|
||||
|
||||
ctx.add_window(galaxyui::AddWindowOptions::default(), RootView::new);
|
||||
ctx.add_window(galaxyui_core::AddWindowOptions::default(), RootView::new);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -174,7 +175,7 @@ impl View for RootView {
|
||||
"RootView"
|
||||
}
|
||||
|
||||
fn keymap_context(&self, _: &AppContext) -> galaxyui::keymap::Context {
|
||||
fn keymap_context(&self, _: &AppContext) -> galaxyui_core::keymap::Context {
|
||||
let mut context = Self::default_keymap_context();
|
||||
if *self.dialog_open {
|
||||
context.set.insert("RootView_DialogOpen");
|
||||
@@ -240,7 +241,7 @@ impl RootView {
|
||||
options: switch::Options {
|
||||
hover_border_size: Some(10.),
|
||||
label: Some(Box::new(move |appearance: &Appearance| {
|
||||
galaxyui::elements::Text::new(
|
||||
galaxyui_core::elements::Text::new(
|
||||
"Switch",
|
||||
appearance.ui_font_family(),
|
||||
appearance.ui_font_size(),
|
||||
@@ -260,7 +261,7 @@ impl RootView {
|
||||
tooltip::Params {
|
||||
label: "Tooltip label".into(),
|
||||
options: tooltip::Options {
|
||||
keyboard_shortcut: Some(galaxyui::keymap::Keystroke {
|
||||
keyboard_shortcut: Some(galaxyui_core::keymap::Keystroke {
|
||||
ctrl: true,
|
||||
key: "k".to_string(),
|
||||
..Default::default()
|
||||
@@ -282,7 +283,7 @@ impl RootView {
|
||||
content: button::Content::Label("Primary".into()),
|
||||
theme: &button::themes::Primary,
|
||||
options: button::Options {
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
ctrl: true,
|
||||
key: "k".to_string(),
|
||||
..Default::default()
|
||||
@@ -304,7 +305,7 @@ impl RootView {
|
||||
content: button::Content::Label("Secondary".into()),
|
||||
theme: &button::themes::Secondary,
|
||||
options: button::Options {
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
cmd: true,
|
||||
key: "enter".to_string(),
|
||||
..Default::default()
|
||||
@@ -327,7 +328,7 @@ impl RootView {
|
||||
theme: &button::themes::Primary,
|
||||
options: button::Options {
|
||||
disabled: true,
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
shift: true,
|
||||
key: "d".to_string(),
|
||||
..Default::default()
|
||||
@@ -368,7 +369,7 @@ impl RootView {
|
||||
theme: &button::themes::Primary,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
ctrl: true,
|
||||
key: "k".to_string(),
|
||||
..Default::default()
|
||||
@@ -391,7 +392,7 @@ impl RootView {
|
||||
theme: &button::themes::Secondary,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
cmd: true,
|
||||
key: "enter".to_string(),
|
||||
..Default::default()
|
||||
@@ -415,7 +416,7 @@ impl RootView {
|
||||
options: button::Options {
|
||||
disabled: true,
|
||||
size: button::Size::Small,
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
shift: true,
|
||||
key: "d".to_string(),
|
||||
..Default::default()
|
||||
@@ -438,7 +439,7 @@ impl RootView {
|
||||
theme: &button::themes::Secondary,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
key: "escape".to_string(),
|
||||
..Default::default()
|
||||
}),
|
||||
@@ -498,7 +499,7 @@ impl RootView {
|
||||
on_dismiss: Some(Arc::new(|ctx, _app| {
|
||||
ctx.dispatch_typed_action(Action::CloseDialog);
|
||||
})),
|
||||
dismiss_keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
dismiss_keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
key: "escape".to_string(),
|
||||
..Default::default()
|
||||
}),
|
||||
@@ -564,7 +565,7 @@ impl RootView {
|
||||
}),
|
||||
current_image_native_size,
|
||||
options: lightbox::Options {
|
||||
dismiss_keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
dismiss_keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
key: "escape".to_string(),
|
||||
..Default::default()
|
||||
}),
|
||||
@@ -597,7 +598,7 @@ impl RootView {
|
||||
}),
|
||||
current_image_native_size,
|
||||
options: lightbox::Options {
|
||||
dismiss_keystroke: Some(galaxyui::keymap::Keystroke {
|
||||
dismiss_keystroke: Some(galaxyui_core::keymap::Keystroke {
|
||||
key: "escape".to_string(),
|
||||
..Default::default()
|
||||
}),
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
mod params;
|
||||
pub mod themes;
|
||||
|
||||
use galaxy_core::ui::{
|
||||
appearance::Appearance,
|
||||
color::{ContrastingColor as _, contrast::MinimumAllowedContrast},
|
||||
};
|
||||
use galaxyui::{
|
||||
elements::{MouseState, MouseStateHandle},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub use params::*;
|
||||
pub use themes::Theme;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::color::ContrastingColor as _;
|
||||
use galaxy_core::ui::color::contrast::MinimumAllowedContrast;
|
||||
use galaxyui_core::elements::{MouseState, MouseStateHandle};
|
||||
use galaxyui_core::prelude::*;
|
||||
|
||||
use crate::{keyboard_shortcut, tooltip};
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ use std::borrow::Cow;
|
||||
|
||||
use galaxy_core::ui::Icon;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxyui::{fonts, keymap::Keystroke, prelude::stack};
|
||||
|
||||
use crate::{keyboard_shortcut, tooltip};
|
||||
use galaxyui_core::fonts;
|
||||
use galaxyui_core::keymap::Keystroke;
|
||||
use galaxyui_core::prelude::stack;
|
||||
|
||||
use super::Theme;
|
||||
use crate::{keyboard_shortcut, tooltip};
|
||||
|
||||
/// The parameters for rendering a button.
|
||||
pub struct Params<'a> {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use galaxy_core::ui::{
|
||||
appearance::Appearance, color::coloru_with_opacity, theme::Fill, theme::color::internal_colors,
|
||||
};
|
||||
use pathfinder_color::ColorU;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::color::coloru_with_opacity;
|
||||
use galaxy_core::ui::theme::Fill;
|
||||
use galaxy_core::ui::theme::color::internal_colors;
|
||||
|
||||
/// Theming delegate for a button.
|
||||
pub trait Theme {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use galaxy_core::ui::{Icon, appearance::Appearance, theme::color::internal_colors};
|
||||
use galaxyui::{
|
||||
AppContext, EventContext,
|
||||
elements::{
|
||||
Border, ConstrainedBox, Container, CornerRadius, CrossAxisAlignment, Dismiss, Element,
|
||||
Flex, ParentElement, Radius, Shrinkable,
|
||||
},
|
||||
fonts::{Properties, Weight},
|
||||
keymap::Keystroke,
|
||||
prelude::{MainAxisAlignment, MainAxisSize, Text},
|
||||
use galaxy_core::ui::Icon;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::theme::color::internal_colors;
|
||||
use galaxyui_core::elements::{
|
||||
Border, ConstrainedBox, Container, CornerRadius, CrossAxisAlignment, Dismiss, Element, Flex,
|
||||
ParentElement, Radius, Shrinkable,
|
||||
};
|
||||
use galaxyui_core::fonts::{Properties, Weight};
|
||||
use galaxyui_core::keymap::Keystroke;
|
||||
use galaxyui_core::prelude::{MainAxisAlignment, MainAxisSize, Text};
|
||||
use galaxyui_core::{AppContext, EventContext};
|
||||
|
||||
use crate::{Component, Options as _, Renderable, button};
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use galaxy_core::ui::{appearance::Appearance, icons::Icon};
|
||||
use galaxyui::{keymap::Keystroke, platform::OperatingSystem, prelude::*};
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::icons::Icon;
|
||||
use galaxyui_core::keymap::Keystroke;
|
||||
use galaxyui_core::platform::OperatingSystem;
|
||||
use galaxyui_core::prelude::*;
|
||||
|
||||
use crate::Component;
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ pub mod switch;
|
||||
pub mod tooltip;
|
||||
|
||||
pub use keyboard_shortcut::KeyboardShortcut;
|
||||
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxyui::Element;
|
||||
use galaxyui_core::Element;
|
||||
|
||||
/// A reusable UI component that can be rendered with configurable parameters.
|
||||
///
|
||||
@@ -32,7 +31,7 @@ use galaxyui::Element;
|
||||
/// ```rust
|
||||
/// use ui_components::{Component, Options, button};
|
||||
/// use galaxy_core::ui::appearance::Appearance;
|
||||
/// use galaxyui::prelude::*;
|
||||
/// use galaxyui_core::prelude::*;
|
||||
///
|
||||
/// // Store component as a field in your view.
|
||||
/// struct MyView {
|
||||
@@ -40,7 +39,7 @@ use galaxyui::Element;
|
||||
/// }
|
||||
///
|
||||
/// impl MyView {
|
||||
/// fn render_button(&self, appearance: &Appearance) -> Box<dyn galaxyui::Element> {
|
||||
/// fn render_button(&self, appearance: &Appearance) -> Box<dyn galaxyui_core::Element> {
|
||||
/// self.my_button.render(
|
||||
/// appearance,
|
||||
/// button::Params {
|
||||
@@ -63,7 +62,7 @@ use galaxyui::Element;
|
||||
/// ```rust
|
||||
/// use ui_components::Component;
|
||||
/// use galaxy_core::ui::appearance::Appearance;
|
||||
/// use galaxyui::prelude::*;
|
||||
/// use galaxyui_core::prelude::*;
|
||||
///
|
||||
/// // 1. Define the component struct with any persistent state.
|
||||
/// #[derive(Default)]
|
||||
@@ -233,7 +232,7 @@ pub trait Options {
|
||||
/// ```rust
|
||||
/// use ui_components::{Renderable, Options};
|
||||
/// use galaxy_core::ui::appearance::Appearance;
|
||||
/// use galaxyui::prelude::*;
|
||||
/// use galaxyui_core::prelude::*;
|
||||
///
|
||||
/// pub struct SwitchOptions<'a> {
|
||||
/// pub disabled: bool,
|
||||
@@ -283,8 +282,8 @@ where
|
||||
/// A function that handles mouse events.
|
||||
pub type MouseEventHandler = Box<
|
||||
dyn FnMut(
|
||||
&mut galaxyui::EventContext,
|
||||
&galaxyui::AppContext,
|
||||
&mut galaxyui_core::EventContext,
|
||||
&galaxyui_core::AppContext,
|
||||
pathfinder_geometry::vector::Vector2F,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use galaxy_core::ui::{Icon, appearance::Appearance};
|
||||
use galaxyui::{
|
||||
assets::asset_cache::AssetSource,
|
||||
elements::{CacheOption, Dismiss, DispatchEventResult, EventHandler, Image, Shrinkable},
|
||||
keymap::Keystroke,
|
||||
prelude::{stack::*, *},
|
||||
};
|
||||
use pathfinder_geometry::vector::{Vector2F, vec2f};
|
||||
use galaxy_core::ui::Icon;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxyui_core::assets::asset_cache::AssetSource;
|
||||
use galaxyui_core::elements::{
|
||||
CacheOption, Dismiss, DispatchEventResult, EventHandler, Image, Shrinkable,
|
||||
};
|
||||
use galaxyui_core::keymap::Keystroke;
|
||||
use galaxyui_core::prelude::stack::*;
|
||||
use galaxyui_core::prelude::*;
|
||||
|
||||
use crate::{Component, Options as _, button};
|
||||
|
||||
@@ -130,7 +132,7 @@ impl Component for Lightbox {
|
||||
appearance,
|
||||
button::Params {
|
||||
content: button::Content::Icon(Icon::X),
|
||||
theme: &button::themes::Secondary,
|
||||
theme: &ButtonTheme,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
on_click: Some(Box::new(move |ctx, app, _| {
|
||||
@@ -151,6 +153,7 @@ impl Component for Lightbox {
|
||||
let image = ConstrainedBox::new(
|
||||
Image::new(asset_source.clone(), CacheOption::Original)
|
||||
.contain()
|
||||
.layout_using_paint_bounds()
|
||||
.before_load(Align::new(loading_element(appearance)).finish())
|
||||
.finish(),
|
||||
)
|
||||
@@ -225,7 +228,7 @@ impl Component for Lightbox {
|
||||
appearance,
|
||||
button::Params {
|
||||
content: button::Content::Icon(Icon::ChevronLeft),
|
||||
theme: &button::themes::Secondary,
|
||||
theme: &ButtonTheme,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
on_click: Some(Box::new(move |ctx, app, _| {
|
||||
@@ -253,7 +256,7 @@ impl Component for Lightbox {
|
||||
appearance,
|
||||
button::Params {
|
||||
content: button::Content::Icon(Icon::ChevronRight),
|
||||
theme: &button::themes::Secondary,
|
||||
theme: &ButtonTheme,
|
||||
options: button::Options {
|
||||
size: button::Size::Small,
|
||||
on_click: Some(Box::new(move |ctx, app, _| {
|
||||
@@ -294,3 +297,38 @@ fn loading_element(appearance: &Appearance) -> Box<dyn Element> {
|
||||
fn lightbox_text_size(appearance: &Appearance) -> f32 {
|
||||
appearance.ui_font_size() + LIGHTBOX_TEXT_SIZE_DELTA
|
||||
}
|
||||
|
||||
/// A custom button theme for lightbox buttons to force colors to match
|
||||
/// a Dark theme button, as these buttons always appear on top of a near-black
|
||||
/// scrim, independent of application theme.
|
||||
struct ButtonTheme;
|
||||
|
||||
impl button::Theme for ButtonTheme {
|
||||
fn background(
|
||||
&self,
|
||||
button_state: button::State,
|
||||
_appearance: &Appearance,
|
||||
) -> Option<galaxy_core::ui::theme::Fill> {
|
||||
match button_state {
|
||||
button::State::Default => None,
|
||||
button::State::Hovered => Some(galaxy_core::ui::theme::Fill::white().with_opacity(10)),
|
||||
button::State::Pressed => Some(galaxy_core::ui::theme::Fill::white().with_opacity(15)),
|
||||
}
|
||||
}
|
||||
|
||||
fn text_color(
|
||||
&self,
|
||||
_background: Option<galaxy_core::ui::theme::Fill>,
|
||||
_appearance: &Appearance,
|
||||
) -> ColorU {
|
||||
ColorU::new(255, 255, 255, 255)
|
||||
}
|
||||
|
||||
fn border(&self, _appearance: &Appearance) -> Option<ColorU> {
|
||||
Some(ColorU::new(51, 51, 51, 255))
|
||||
}
|
||||
|
||||
fn keyboard_shortcut_background(&self, _appearance: &Appearance) -> Option<ColorU> {
|
||||
Some(ColorU::new(38, 38, 38, 255))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxyui::{
|
||||
elements::{MouseStateHandle, Rect},
|
||||
prelude::{stack::*, *},
|
||||
};
|
||||
use galaxyui_core::elements::{MouseStateHandle, Rect};
|
||||
use galaxyui_core::prelude::stack::*;
|
||||
use galaxyui_core::prelude::*;
|
||||
|
||||
use crate::{Component, MouseEventHandler, Renderable};
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use galaxy_core::ui::{appearance::Appearance, theme::color::internal_colors};
|
||||
use galaxyui::{keymap::Keystroke, prelude::*};
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::theme::color::internal_colors;
|
||||
use galaxyui_core::keymap::Keystroke;
|
||||
use galaxyui_core::prelude::*;
|
||||
|
||||
use crate::{Component, keyboard_shortcut};
|
||||
|
||||
@@ -39,7 +41,7 @@ impl Component for Tooltip {
|
||||
&self,
|
||||
appearance: &Appearance,
|
||||
params: Self::Params<'a>,
|
||||
) -> Box<dyn galaxyui::Element> {
|
||||
) -> Box<dyn galaxyui_core::Element> {
|
||||
let font_family = appearance.ui_font_family();
|
||||
let font_size = appearance.ui_font_size() + UI_FONT_SIZE_ADJUSTMENT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user