From c4e63db0a3ab836e3251f00f8f78e985dba9fdb6 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 10:31:37 +0000 Subject: [PATCH 1/8] Rename app::AppState -> State and make private to the app module --- crates/kas-core/src/app/app.rs | 6 +++--- crates/kas-core/src/app/event_loop.rs | 6 +++--- crates/kas-core/src/app/mod.rs | 3 ++- crates/kas-core/src/app/shared.rs | 6 +++--- crates/kas-core/src/app/window.rs | 28 ++++++++++++--------------- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index e60bf4d42..f9632daf2 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -5,7 +5,7 @@ //! [`Application`] and supporting elements -use super::{AppData, AppGraphicsBuilder, AppState, Platform, ProxyAction, Result}; +use super::{AppData, AppGraphicsBuilder, Platform, ProxyAction, Result, State}; use crate::config::{Config, Options}; use crate::draw::{DrawShared, DrawSharedImpl}; use crate::theme::{self, Theme}; @@ -18,7 +18,7 @@ use winit::event_loop::{EventLoop, EventLoopProxy}; pub struct Application> { el: EventLoop, windows: Vec>>, - state: AppState, + state: State, } impl_scope! { @@ -89,7 +89,7 @@ impl_scope! { draw_shared.set_raster_config(config.borrow().font.raster()); let pw = PlatformWrapper(&el); - let state = AppState::new(data, pw, draw_shared, self.theme, options, config)?; + let state = State::new(data, pw, draw_shared, self.theme, options, config)?; Ok(Application { el, diff --git a/crates/kas-core/src/app/event_loop.rs b/crates/kas-core/src/app/event_loop.rs index 48d826300..a53382016 100644 --- a/crates/kas-core/src/app/event_loop.rs +++ b/crates/kas-core/src/app/event_loop.rs @@ -5,7 +5,7 @@ //! Event loop and handling -use super::{AppData, AppGraphicsBuilder, AppState, Pending}; +use super::{AppData, AppGraphicsBuilder, Pending, State}; use super::{ProxyAction, Window}; use crate::theme::Theme; use crate::{Action, WindowId}; @@ -29,7 +29,7 @@ where /// Translates our WindowId to winit's id_map: HashMap, /// Application state passed from Toolkit - state: AppState, + state: State, /// Timer resumes: (time, window identifier) resumes: Vec<(Instant, WindowId)>, } @@ -168,7 +168,7 @@ impl> Loop where T::Window: kas::theme::Window, { - pub(super) fn new(mut windows: Vec>>, state: AppState) -> Self { + pub(super) fn new(mut windows: Vec>>, state: State) -> Self { Loop { suspended: true, windows: windows.drain(..).map(|w| (w.window_id, w)).collect(), diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index c685bf798..71359ad37 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -15,7 +15,8 @@ use crate::messages::MessageStack; #[cfg(winit)] use crate::WindowId; #[cfg(winit)] use app::PlatformWrapper; #[cfg(winit)] use event_loop::Loop; -#[cfg(winit)] pub(crate) use shared::{AppShared, AppState}; +#[cfg(winit)] pub(crate) use shared::AppShared; +#[cfg(winit)] use shared::State; #[cfg(winit)] pub(crate) use window::{Window, WindowDataErased}; diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/app/shared.rs index 80be36ec9..c64ef258b 100644 --- a/crates/kas-core/src/app/shared.rs +++ b/crates/kas-core/src/app/shared.rs @@ -34,14 +34,14 @@ pub(crate) struct AppSharedState> { +pub(super) struct State> { pub(super) shared: AppSharedState, pub(super) data: Data, /// Estimated scale factor (from last window constructed or available screens) options: Options, } -impl> AppState +impl> State where T::Window: kas::theme::Window, { @@ -67,7 +67,7 @@ where } }; - Ok(AppState { + Ok(State { shared: AppSharedState { platform, config, diff --git a/crates/kas-core/src/app/window.rs b/crates/kas-core/src/app/window.rs index cd57e98b1..78f55e07c 100644 --- a/crates/kas-core/src/app/window.rs +++ b/crates/kas-core/src/app/window.rs @@ -6,7 +6,7 @@ //! Window types use super::common::WindowSurface; -use super::shared::{AppSharedState, AppState}; +use super::shared::{AppSharedState, State}; use super::{AppData, AppGraphicsBuilder}; use crate::cast::{Cast, Conv}; use crate::config::WindowConfig; @@ -73,7 +73,7 @@ impl> Window { /// Open (resume) a window pub(super) fn resume( &mut self, - state: &mut AppState, + state: &mut State, el: &ActiveEventLoop, ) -> super::Result { let time = Instant::now(); @@ -212,11 +212,7 @@ impl> Window { /// Handle an event /// /// Returns `true` to force polling temporarily. - pub(super) fn handle_event( - &mut self, - state: &mut AppState, - event: WindowEvent, - ) -> bool { + pub(super) fn handle_event(&mut self, state: &mut State, event: WindowEvent) -> bool { let Some(ref mut window) = self.window else { return false; }; @@ -269,7 +265,7 @@ impl> Window { /// Handle all pending items before event loop sleeps pub(super) fn flush_pending( &mut self, - state: &mut AppState, + state: &mut State, ) -> (Action, Option) { let Some(ref window) = self.window else { return (Action::empty(), None); @@ -306,7 +302,7 @@ impl> Window { } /// Handle an action (excludes handling of CLOSE and EXIT) - pub(super) fn handle_action(&mut self, state: &mut AppState, mut action: Action) { + pub(super) fn handle_action(&mut self, state: &mut State, mut action: Action) { if action.contains(Action::EVENT_CONFIG) { if let Some(ref mut window) = self.window { self.ev_state.update_config(window.scale_factor() as f32); @@ -350,7 +346,7 @@ impl> Window { } } - pub(super) fn update_timer(&mut self, state: &mut AppState) -> Option { + pub(super) fn update_timer(&mut self, state: &mut State) -> Option { let window = self.window.as_ref()?; let widget = self.widget.as_node(&state.data); @@ -365,7 +361,7 @@ impl> Window { pub(super) fn add_popup( &mut self, - state: &mut AppState, + state: &mut State, id: WindowId, popup: kas::PopupDescriptor, ) { @@ -385,7 +381,7 @@ impl> Window { self.ev_state.action(Id::ROOT, action); } - pub(super) fn send_close(&mut self, state: &mut AppState, id: WindowId) { + pub(super) fn send_close(&mut self, state: &mut State, id: WindowId) { if id == self.window_id { self.ev_state.action(Id::ROOT, Action::CLOSE); } else if let Some(window) = self.window.as_ref() { @@ -402,7 +398,7 @@ impl> Window { // Internal functions impl> Window { - fn reconfigure(&mut self, state: &AppState) { + fn reconfigure(&mut self, state: &State) { let time = Instant::now(); let Some(ref mut window) = self.window else { return; @@ -418,7 +414,7 @@ impl> Window { log::trace!(target: "kas_perf::wgpu::window", "reconfigure: {}µs", time.elapsed().as_micros()); } - fn update(&mut self, state: &AppState) { + fn update(&mut self, state: &State) { let time = Instant::now(); let Some(ref mut window) = self.window else { return; @@ -431,7 +427,7 @@ impl> Window { log::trace!(target: "kas_perf::wgpu::window", "update: {}µs", time.elapsed().as_micros()); } - fn apply_size(&mut self, state: &AppState, first: bool) { + fn apply_size(&mut self, state: &State, first: bool) { let time = Instant::now(); let Some(ref mut window) = self.window else { return; @@ -470,7 +466,7 @@ impl> Window { /// /// Returns an error when drawing is aborted and further event handling may /// be needed before a redraw. - pub(super) fn do_draw(&mut self, state: &mut AppState) -> Result<(), ()> { + pub(super) fn do_draw(&mut self, state: &mut State) -> Result<(), ()> { let start = Instant::now(); let Some(ref mut window) = self.window else { return Ok(()); From 53c4e30942c79887a8d5103f03b413ad3c9066c8 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 10:33:06 +0000 Subject: [PATCH 2/8] Rename app::AppSharedState -> SharedState and make private to the app module --- crates/kas-core/src/app/shared.rs | 10 +++++----- crates/kas-core/src/app/window.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/app/shared.rs index c64ef258b..44c2e4ce7 100644 --- a/crates/kas-core/src/app/shared.rs +++ b/crates/kas-core/src/app/shared.rs @@ -21,7 +21,7 @@ use std::task::Waker; #[cfg(feature = "clipboard")] use arboard::Clipboard; /// Application state used by [`AppShared`] -pub(crate) struct AppSharedState> { +pub(super) struct SharedState> { pub(super) platform: Platform, pub(super) config: Rc>, #[cfg(feature = "clipboard")] @@ -35,7 +35,7 @@ pub(crate) struct AppSharedState> { - pub(super) shared: AppSharedState, + pub(super) shared: SharedState, pub(super) data: Data, /// Estimated scale factor (from last window constructed or available screens) options: Options, @@ -68,7 +68,7 @@ where }; Ok(State { - shared: AppSharedState { + shared: SharedState { platform, config, #[cfg(feature = "clipboard")] @@ -105,7 +105,7 @@ where } } -impl> AppSharedState { +impl> SharedState { /// Return the next window identifier /// /// TODO(opt): this should recycle used identifiers since Id does not @@ -197,7 +197,7 @@ pub(crate) trait AppShared { } impl> AppShared - for AppSharedState + for SharedState { fn add_popup(&mut self, parent_id: WindowId, popup: kas::PopupDescriptor) -> WindowId { let id = self.next_window_id(); diff --git a/crates/kas-core/src/app/window.rs b/crates/kas-core/src/app/window.rs index 78f55e07c..9b944acb8 100644 --- a/crates/kas-core/src/app/window.rs +++ b/crates/kas-core/src/app/window.rs @@ -6,7 +6,7 @@ //! Window types use super::common::WindowSurface; -use super::shared::{AppSharedState, State}; +use super::shared::{SharedState, State}; use super::{AppData, AppGraphicsBuilder}; use crate::cast::{Cast, Conv}; use crate::config::WindowConfig; @@ -56,7 +56,7 @@ pub struct Window> { impl> Window { /// Construct window state (widget) pub(super) fn new( - shared: &AppSharedState, + shared: &SharedState, window_id: WindowId, widget: kas::Window, ) -> Self { From d17f4f839a104a5d46fab12580b6aae1ca7ca78c Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 10:36:26 +0000 Subject: [PATCH 3/8] Rename app::AppShared -> RunnerT --- crates/kas-core/src/app/mod.rs | 2 +- crates/kas-core/src/app/shared.rs | 8 ++++---- crates/kas-core/src/event/cx/cx_pub.rs | 18 +++++++++--------- crates/kas-core/src/event/cx/mod.rs | 4 ++-- crates/kas-core/src/event/cx/platform.rs | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index 71359ad37..7f22223e7 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -15,7 +15,7 @@ use crate::messages::MessageStack; #[cfg(winit)] use crate::WindowId; #[cfg(winit)] use app::PlatformWrapper; #[cfg(winit)] use event_loop::Loop; -#[cfg(winit)] pub(crate) use shared::AppShared; +#[cfg(winit)] pub(crate) use shared::RunnerT; #[cfg(winit)] use shared::State; #[cfg(winit)] pub(crate) use window::{Window, WindowDataErased}; diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/app/shared.rs index 44c2e4ce7..445df615c 100644 --- a/crates/kas-core/src/app/shared.rs +++ b/crates/kas-core/src/app/shared.rs @@ -20,7 +20,7 @@ use std::task::Waker; #[cfg(feature = "clipboard")] use arboard::Clipboard; -/// Application state used by [`AppShared`] +/// Application state used by [`RunnerT`] pub(super) struct SharedState> { pub(super) platform: Platform, pub(super) config: Rc>, @@ -119,8 +119,8 @@ impl> SharedState &std::task::Waker; } -impl> AppShared +impl> RunnerT for SharedState { fn add_popup(&mut self, parent_id: WindowId, popup: kas::PopupDescriptor) -> WindowId { diff --git a/crates/kas-core/src/event/cx/cx_pub.rs b/crates/kas-core/src/event/cx/cx_pub.rs index 78de08977..766d00b50 100644 --- a/crates/kas-core/src/event/cx/cx_pub.rs +++ b/crates/kas-core/src/event/cx/cx_pub.rs @@ -808,7 +808,7 @@ impl<'a> EventCx<'a> { log::trace!(target: "kas_core::event", "add_popup: {popup:?}"); let parent_id = self.window.window_id(); - let id = self.shared.add_popup(parent_id, popup.clone()); + let id = self.runner.add_popup(parent_id, popup.clone()); let nav_focus = self.nav_focus.clone(); self.popups.push((id, popup, nav_focus)); self.clear_nav_focus(); @@ -832,7 +832,7 @@ impl<'a> EventCx<'a> { let data_type_id = std::any::TypeId::of::(); unsafe { let window: Window<()> = std::mem::transmute(window); - self.shared.add_window(window, data_type_id) + self.runner.add_window(window, data_type_id) } } @@ -849,7 +849,7 @@ impl<'a> EventCx<'a> { { let (wid, popup, onf) = self.popups.remove(index); self.popup_removed.push((popup.id, wid)); - self.shared.close_window(wid); + self.runner.close_window(wid); if let Some(id) = onf { self.set_nav_focus(id, FocusSource::Synthetic); @@ -857,7 +857,7 @@ impl<'a> EventCx<'a> { return; } - self.shared.close_window(id); + self.runner.close_window(id); } /// Enable window dragging for current click @@ -901,7 +901,7 @@ impl<'a> EventCx<'a> { }; } - self.shared.get_clipboard() + self.runner.get_clipboard() } /// Attempt to set clipboard contents @@ -913,7 +913,7 @@ impl<'a> EventCx<'a> { return; } - self.shared.set_clipboard(content) + self.runner.set_clipboard(content) } /// True if the primary buffer is enabled @@ -945,7 +945,7 @@ impl<'a> EventCx<'a> { }; } - self.shared.get_primary() + self.runner.get_primary() } /// Set contents of primary buffer @@ -960,7 +960,7 @@ impl<'a> EventCx<'a> { return; } - self.shared.set_primary(content) + self.runner.set_primary(content) } /// Get a [`SizeCx`] @@ -981,7 +981,7 @@ impl<'a> EventCx<'a> { /// Get a [`DrawShared`] pub fn draw_shared(&mut self) -> &mut dyn DrawShared { - self.shared.draw_shared() + self.runner.draw_shared() } /// Directly access Winit Window diff --git a/crates/kas-core/src/event/cx/mod.rs b/crates/kas-core/src/event/cx/mod.rs index e2b1dddf7..bbdc1148f 100644 --- a/crates/kas-core/src/event/cx/mod.rs +++ b/crates/kas-core/src/event/cx/mod.rs @@ -17,7 +17,7 @@ use std::pin::Pin; use std::time::Instant; use super::*; -use crate::app::{AppShared, Platform, WindowDataErased}; +use crate::app::{Platform, RunnerT, WindowDataErased}; use crate::cast::Cast; use crate::config::WindowConfig; use crate::geom::Coord; @@ -420,7 +420,7 @@ impl EventState { #[must_use] pub struct EventCx<'a> { state: &'a mut EventState, - shared: &'a mut dyn AppShared, + runner: &'a mut dyn RunnerT, window: &'a dyn WindowDataErased, messages: &'a mut MessageStack, pub(crate) target_is_disabled: bool, diff --git a/crates/kas-core/src/event/cx/platform.rs b/crates/kas-core/src/event/cx/platform.rs index 8e33fe5fe..fd2bcb12c 100644 --- a/crates/kas-core/src/event/cx/platform.rs +++ b/crates/kas-core/src/event/cx/platform.rs @@ -108,14 +108,14 @@ impl EventState { #[inline] pub(crate) fn with<'a, F: FnOnce(&mut EventCx)>( &'a mut self, - shared: &'a mut dyn AppShared, + runner: &'a mut dyn RunnerT, window: &'a dyn WindowDataErased, messages: &'a mut MessageStack, f: F, ) { let mut cx = EventCx { state: self, - shared, + runner, window, messages, target_is_disabled: false, @@ -128,13 +128,13 @@ impl EventState { /// Handle all pending items before event loop sleeps pub(crate) fn flush_pending<'a, A>( &'a mut self, - shared: &'a mut dyn AppShared, + runner: &'a mut dyn RunnerT, window: &'a dyn WindowDataErased, messages: &'a mut MessageStack, win: &mut Window, data: &A, ) -> Action { - self.with(shared, window, messages, |cx| { + self.with(runner, window, messages, |cx| { while let Some((id, wid)) = cx.popup_removed.pop() { cx.send_event(win.as_node(data), id, Event::PopupClosed(wid)); } @@ -309,7 +309,7 @@ impl<'a> EventCx<'a> { let mut i = 0; while i < self.state.fut_messages.len() { let (_, fut) = &mut self.state.fut_messages[i]; - let mut cx = std::task::Context::from_waker(self.shared.waker()); + let mut cx = std::task::Context::from_waker(self.runner.waker()); match fut.as_mut().poll(&mut cx) { Poll::Pending => { i += 1; From c48034ab30aad860f2081e797d5f420592fa8e5c Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 10:48:02 +0000 Subject: [PATCH 4/8] =?UTF-8?q?Rename=20Application=20=E2=86=92=20Runner,?= =?UTF-8?q?=20ApplicationInherent=20=E2=86=92=20RunnerInherent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ crates/kas-core/src/action.rs | 2 +- crates/kas-core/src/app/app.rs | 28 +++++++++++++------------- crates/kas-core/src/app/common.rs | 4 ++-- crates/kas-core/src/app/mod.rs | 4 ++-- crates/kas-core/src/app/shared.rs | 8 ++++---- crates/kas-core/src/draw/draw.rs | 4 ++-- crates/kas-core/src/event/cx/cx_pub.rs | 2 +- crates/kas-core/src/theme/mod.rs | 4 ++-- crates/kas-wgpu/src/draw/custom.rs | 4 ++-- crates/kas-wgpu/src/draw/draw_pipe.rs | 2 +- crates/kas-wgpu/src/lib.rs | 2 +- examples/clock.rs | 8 ++++---- examples/proxy.rs | 2 +- src/lib.rs | 16 +++++++-------- 15 files changed, 49 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e06ea521..d4a8af6b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Rename `Application` → `Runner` + ## [0.14.2] — 2023-12-12 - Add `kas-widgets::edit::InstantParseGuard` (#427) diff --git a/crates/kas-core/src/action.rs b/crates/kas-core/src/action.rs index 71eaa85c7..8f58758c6 100644 --- a/crates/kas-core/src/action.rs +++ b/crates/kas-core/src/action.rs @@ -15,7 +15,7 @@ bitflags! { /// An `Action` produced at run-time should be passed to a context: /// `cx.action(self.id(), action)` (assuming `self` is a widget). /// An `Action` produced before starting the GUI may be discarded, for - /// example: `let _ = app.config_mut().font.set_size(24.0);`. + /// example: `let _ = runner.config_mut().font.set_size(24.0);`. /// /// Two `Action` values may be combined via bit-or (`a | b`). #[must_use] diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index f9632daf2..5ca7c57b9 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -3,7 +3,7 @@ // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENSE-2.0 -//! [`Application`] and supporting elements +//! [`Runner`] and supporting elements use super::{AppData, AppGraphicsBuilder, Platform, ProxyAction, Result, State}; use crate::config::{Config, Options}; @@ -15,7 +15,7 @@ use std::cell::{Ref, RefCell, RefMut}; use std::rc::Rc; use winit::event_loop::{EventLoop, EventLoopProxy}; -pub struct Application> { +pub struct Runner> { el: EventLoop, windows: Vec>>, state: State, @@ -71,7 +71,7 @@ impl_scope! { } /// Build with `data` - pub fn build(self, data: Data) -> Result> { + pub fn build(self, data: Data) -> Result> { let options = self.options.unwrap_or_else(Options::from_env); let config = self.config.unwrap_or_else(|| match options.read_config() { @@ -91,7 +91,7 @@ impl_scope! { let pw = PlatformWrapper(&el); let state = State::new(data, pw, draw_shared, self.theme, options, config)?; - Ok(Application { + Ok(Runner { el, windows: vec![], state, @@ -100,15 +100,15 @@ impl_scope! { } } -/// Inherenet associated types of [`Application`] +/// Inherenet associated types of [`Runner`] /// -/// Note: these could be inherent associated types of [`Application`] when Rust#8995 is stable. -pub trait ApplicationInherent { +/// Note: these could be inherent associated types of [`Runner`] when Rust#8995 is stable. +pub trait RunnerInherent { /// Shared draw state type type DrawShared: DrawSharedImpl; } -impl ApplicationInherent for Application +impl RunnerInherent for Runner where T: Theme + 'static, T::Window: theme::Window, @@ -116,7 +116,7 @@ where type DrawShared = G::Shared; } -impl Application +impl Runner where G: AppGraphicsBuilder + Default, { @@ -140,7 +140,7 @@ where } } -impl Application<(), G, T> +impl Runner<(), G, T> where G: AppGraphicsBuilder + Default, T: Theme, @@ -152,7 +152,7 @@ where } } -impl Application +impl Runner where T: Theme + 'static, T::Window: theme::Window, @@ -309,14 +309,14 @@ impl<'a> PlatformWrapper<'a> { } } -/// A proxy allowing control of an application from another thread. +/// A proxy allowing control of a UI from another thread. /// -/// Created by [`Application::create_proxy`]. +/// Created by [`Runner::create_proxy`]. pub struct Proxy(EventLoopProxy); /// Error type returned by [`Proxy`] functions. /// -/// This error occurs only if the application already terminated. +/// This error occurs only if the [`Runner`] already terminated. pub struct ClosedError; impl Proxy { diff --git a/crates/kas-core/src/app/common.rs b/crates/kas-core/src/app/common.rs index 8652a2586..0f22464a8 100644 --- a/crates/kas-core/src/app/common.rs +++ b/crates/kas-core/src/app/common.rs @@ -13,7 +13,7 @@ use raw_window_handle as rwh; use std::time::Instant; use thiserror::Error; -/// Possible failures from constructing an [`Application`](super::Application) +/// Possible failures from constructing a [`Runner`](super::Runner) /// /// Some variants are undocumented. Users should not match these variants since /// they are not considered part of the public API. @@ -174,7 +174,7 @@ impl Platform { /// Builder for a graphics backend /// -/// See also [`Application`](super::Application). +/// See also [`Runner`](super::Runner). pub trait AppGraphicsBuilder { /// The default theme type DefaultTheme: Default + Theme; diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index 7f22223e7..cb7274645 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -3,7 +3,7 @@ // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENSE-2.0 -//! Application, platforms and backends +//! Runner, platforms and backends #[cfg(winit)] mod app; mod common; @@ -21,7 +21,7 @@ use crate::messages::MessageStack; pub(crate) use window::{Window, WindowDataErased}; #[cfg(winit)] -pub use app::{AppBuilder, Application, ApplicationInherent, ClosedError, Proxy}; +pub use app::{AppBuilder, ClosedError, Proxy, Runner, RunnerInherent}; pub use common::{Error, Platform, Result}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/app/shared.rs index 445df615c..b407fd2eb 100644 --- a/crates/kas-core/src/app/shared.rs +++ b/crates/kas-core/src/app/shared.rs @@ -20,7 +20,7 @@ use std::task::Waker; #[cfg(feature = "clipboard")] use arboard::Clipboard; -/// Application state used by [`RunnerT`] +/// Runner state used by [`RunnerT`] pub(super) struct SharedState> { pub(super) platform: Platform, pub(super) config: Rc>, @@ -33,7 +33,7 @@ pub(super) struct SharedState> { pub(super) shared: SharedState, pub(super) data: Data, @@ -117,7 +117,7 @@ impl> SharedState` to `Window<()>` and pass in diff --git a/crates/kas-core/src/draw/draw.rs b/crates/kas-core/src/draw/draw.rs index e72e0653c..fa82b180d 100644 --- a/crates/kas-core/src/draw/draw.rs +++ b/crates/kas-core/src/draw/draw.rs @@ -39,8 +39,8 @@ use std::time::Instant; /// } /// ``` /// -/// Note that this object is little more than a mutable reference to application -/// shared draw state. As such, it is normal to pass *a new copy* created +/// This object is effectively a fat pointer to draw state (both window-local +/// and shared components). As such, it is normal to pass *a new copy* created /// via [`DrawIface::re`] as a method argument. (Note that Rust automatically /// "reborrows" reference types passed as method arguments, but cannot do so /// automatically for structs containing references.) diff --git a/crates/kas-core/src/event/cx/cx_pub.rs b/crates/kas-core/src/event/cx/cx_pub.rs index 766d00b50..2c7b618fc 100644 --- a/crates/kas-core/src/event/cx/cx_pub.rs +++ b/crates/kas-core/src/event/cx/cx_pub.rs @@ -822,7 +822,7 @@ impl<'a> EventCx<'a> { /// available to a running UI. This method may be used instead. /// /// Requirement: the type `Data` must match the type of data passed to the - /// [`Application`](crate::app::Application) and used by other windows. + /// [`Runner`](crate::app::Runner) and used by other windows. /// If not, a run-time error will result. /// /// Caveat: if an error occurs opening the new window it will not be diff --git a/crates/kas-core/src/theme/mod.rs b/crates/kas-core/src/theme/mod.rs index 38a1788ef..065c843b5 100644 --- a/crates/kas-core/src/theme/mod.rs +++ b/crates/kas-core/src/theme/mod.rs @@ -8,8 +8,8 @@ //! Widgets expect the theme to provide an implementation of [`SizeCx`] and of //! [`DrawCx`]. //! -//! Constructing an application requires a [`Theme`]. Two implementations are -//! provided here: [`SimpleTheme`] and [`FlatTheme`]. +//! Constructing a [`Runner`](crate::app::Runner) requires a [`Theme`]. Two +//! implementations are provided here: [`SimpleTheme`] and [`FlatTheme`]. //! An adapter, [`MultiTheme`], is also provided. mod anim; diff --git a/crates/kas-wgpu/src/draw/custom.rs b/crates/kas-wgpu/src/draw/custom.rs index f15067afd..ad708eb1b 100644 --- a/crates/kas-wgpu/src/draw/custom.rs +++ b/crates/kas-wgpu/src/draw/custom.rs @@ -12,7 +12,7 @@ use kas::geom::{Rect, Size}; /// Allows use of the low-level graphics API /// /// To use this, write an implementation of [`CustomPipe`], then pass the -/// corresponding [`CustomPipeBuilder`] to `Application::new_custom`. +/// corresponding [`CustomPipeBuilder`] to `Runner::new_custom`. pub trait DrawCustom { /// Call a custom draw pipe fn custom(&mut self, pass: PassId, rect: Rect, param: CW::Param); @@ -52,7 +52,7 @@ pub trait CustomPipeBuilder { /// A custom pipe allows direct use of the `wgpu` graphics stack. /// /// To use this, pass the corresponding [`CustomPipeBuilder`] to -/// `Application::new_custom`. +/// `Runner::new_custom`. /// /// Note that `kas-wgpu` accepts only a single custom pipe. To use more than /// one custom graphics pipeline, you must implement your own multiplexer. diff --git a/crates/kas-wgpu/src/draw/draw_pipe.rs b/crates/kas-wgpu/src/draw/draw_pipe.rs index d653c94a9..646c061e0 100644 --- a/crates/kas-wgpu/src/draw/draw_pipe.rs +++ b/crates/kas-wgpu/src/draw/draw_pipe.rs @@ -20,7 +20,7 @@ use kas::draw::*; use kas::geom::{Quad, Size, Vec2}; use kas::text::{Effect, TextDisplay}; -/// Failure while constructing an [`Application`]: no graphics adapter found +/// Failure while constructing a [`Runner`]: no graphics adapter found #[non_exhaustive] #[derive(thiserror::Error, Debug)] #[error("no graphics adapter found")] diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index 7b340257f..f5e867d41 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -36,7 +36,7 @@ pub use options::Options; pub use shaded_theme::ShadedTheme; pub extern crate wgpu; -/// Builder for a KAS application using WGPU +/// Builder for a [`kas::app::Runner`] using WGPU pub struct WgpuBuilder { custom: CB, options: Options, diff --git a/examples/clock.rs b/examples/clock.rs index e168ca82a..82e0a0a44 100644 --- a/examples/clock.rs +++ b/examples/clock.rs @@ -17,14 +17,14 @@ use chrono::prelude::*; use std::f32::consts::PI; use std::time::Duration; -use kas::app::ApplicationInherent; +use kas::app::RunnerInherent; use kas::draw::color::{Rgba, Rgba8Srgb}; use kas::draw::{Draw, DrawRounded}; use kas::geom::{Quad, Vec2}; use kas::prelude::*; use kas::text::Text; -type Application = kas::app::Default<(), kas::theme::SimpleTheme>; +type Runner = kas::app::Default<(), kas::theme::SimpleTheme>; impl_scope! { #[derive(Clone)] @@ -79,7 +79,7 @@ impl_scope! { // We use the low-level draw device to draw our clock. This means it is // not themeable, but gives us much more flexible draw routines. - let mut draw = draw.draw_iface::<::DrawShared>().unwrap(); + let mut draw = draw.draw_iface::<::DrawShared>().unwrap(); let rect = self.core.rect; let quad = Quad::conv(rect); @@ -175,7 +175,7 @@ fn main() -> kas::app::Result<()> { .with_decorations(kas::decorations::Decorations::None) .with_transparent(true); - Application::with_theme(Default::default()) + Runner::with_theme(Default::default()) .build(())? .with(window) .run() diff --git a/examples/proxy.rs b/examples/proxy.rs index 53c45bb55..fca944697 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -6,7 +6,7 @@ //! Asynchronous events using a proxy //! //! This is a copy-cat of Druid's async event example, demonstrating usage of -//! `Application::create_proxy()`. For a more integrated approach to async, see +//! `Runner::create_proxy()`. For a more integrated approach to async, see //! `EventState::push_async()` and `push_spawn()`. use std::thread; diff --git a/src/lib.rs b/src/lib.rs index 207319337..6b08a2bc3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,17 +63,17 @@ pub mod resvg { } pub mod app { - //! Application, platforms and backends + //! [`Runner`], platforms and backends //! - //! Start by constructing an [`Application`] or its [`Default`](type@Default) + //! Start by constructing a [`Runner`] or its [`Default`](type@Default) //! type-def (requires a backend be enabled, e.g. "wgpu"). - /// Application pre-launch state + /// Runner pre-launch state /// /// Suggested construction patterns: /// - /// - kas::app::[Default](type@Default)::[new](Application::new)(data)? - /// - kas::app::[Default](type@Default)::[with_theme](Application::with_theme)(theme).[build](AppBuilder::build)(data)? + /// - kas::app::[Default](type@Default)::[new](Runner::new)(data)? + /// - kas::app::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](AppBuilder::build)(data)? /// - kas::app::[WgpuBuilder]::[new](WgpuBuilder::new)(custom_wgpu_pipe).[with_theme](WgpuBuilder::with_theme)(theme).[build](AppBuilder::build)(data)? /// /// Where: @@ -82,16 +82,16 @@ pub mod app { /// - `theme` is some object implementing [`Theme`](crate::theme::Theme) /// - `custom_wgpu_pipe` is a custom WGPU graphics pipeline #[doc(inline)] - pub use kas_core::app::Application; + pub use kas_core::app::Runner; pub use kas_core::app::*; #[cfg(feature = "wgpu")] pub use kas_wgpu::WgpuBuilder; - /// Application pre-launch state, configured with the default graphics backend + /// Runner pre-launch state, configured with the default graphics backend #[cfg(feature = "wgpu")] pub type Default = - Application, T>; + Runner, T>; } #[cfg(feature = "dynamic")] From 274b4189ad8b893319caaa94acfbdff8d95f20dc Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 11:01:00 +0000 Subject: [PATCH 5/8] Rename app::AppBuilder -> Builder --- crates/kas-core/src/app/app.rs | 14 +++++++------- crates/kas-core/src/app/mod.rs | 2 +- crates/kas-wgpu/src/lib.rs | 20 ++++++++++---------- src/lib.rs | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index 5ca7c57b9..2138841ad 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -22,7 +22,7 @@ pub struct Runner> { } impl_scope! { - pub struct AppBuilder> { + pub struct Builder> { graphical: G, theme: T, options: Option, @@ -34,7 +34,7 @@ impl_scope! { #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(graphical: G, theme: T) -> Self { - AppBuilder { + Builder { graphical, theme, options: None, @@ -77,7 +77,7 @@ impl_scope! { let config = self.config.unwrap_or_else(|| match options.read_config() { Ok(config) => Rc::new(RefCell::new(config)), Err(error) => { - warn_about_error("AppBuilder::build: failed to read config", &error); + warn_about_error("kas::app::Builder::build: failed to read config", &error); Default::default() } }); @@ -135,8 +135,8 @@ where /// Construct a builder with the default theme #[inline] - pub fn with_default_theme() -> AppBuilder { - AppBuilder::new(G::default(), G::DefaultTheme::default()) + pub fn with_default_theme() -> Builder { + Builder::new(G::default(), G::DefaultTheme::default()) } } @@ -147,8 +147,8 @@ where { /// Construct a builder with the given `theme` #[inline] - pub fn with_theme(theme: T) -> AppBuilder { - AppBuilder::new(G::default(), theme) + pub fn with_theme(theme: T) -> Builder { + Builder::new(G::default(), theme) } } diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index cb7274645..7792b0404 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -21,7 +21,7 @@ use crate::messages::MessageStack; pub(crate) use window::{Window, WindowDataErased}; #[cfg(winit)] -pub use app::{AppBuilder, ClosedError, Proxy, Runner, RunnerInherent}; +pub use app::{Builder, ClosedError, Proxy, Runner, RunnerInherent}; pub use common::{Error, Platform, Result}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index f5e867d41..3715294ee 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -27,7 +27,7 @@ mod shaded_theme; mod surface; use crate::draw::{CustomPipeBuilder, DrawPipe}; -use kas::app::{AppBuilder, AppGraphicsBuilder, Result}; +use kas::app as runner; use kas::theme::{FlatTheme, Theme}; use wgpu::rwh; @@ -43,14 +43,14 @@ pub struct WgpuBuilder { read_env_vars: bool, } -impl AppGraphicsBuilder for WgpuBuilder { +impl runner::AppGraphicsBuilder for WgpuBuilder { type DefaultTheme = FlatTheme; type Shared = DrawPipe; type Surface<'a> = surface::Surface<'a, CB::Pipe>; - fn build(self) -> Result { + fn build(self) -> runner::Result { let mut options = self.options; if self.read_env_vars { options.load_from_env(); @@ -62,7 +62,7 @@ impl AppGraphicsBuilder for WgpuBuilder { shared: &mut Self::Shared, window: W, transparent: bool, - ) -> Result> + ) -> runner::Result> where W: rwh::HasWindowHandle + rwh::HasDisplayHandle + Send + Sync + 'window, Self: Sized, @@ -110,15 +110,15 @@ impl WgpuBuilder { self } - /// Convert to a [`AppBuilder`] using the default theme + /// Convert to a [`runner::Builder`] using the default theme #[inline] - pub fn with_default_theme(self) -> AppBuilder { - AppBuilder::new(self, FlatTheme::new()) + pub fn with_default_theme(self) -> runner::Builder { + runner::Builder::new(self, FlatTheme::new()) } - /// Convert to a [`AppBuilder`] using the specified `theme` + /// Convert to a [`runner::Builder`] using the specified `theme` #[inline] - pub fn with_theme>>(self, theme: T) -> AppBuilder { - AppBuilder::new(self, theme) + pub fn with_theme>>(self, theme: T) -> runner::Builder { + runner::Builder::new(self, theme) } } diff --git a/src/lib.rs b/src/lib.rs index 6b08a2bc3..baa73a666 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,8 +73,8 @@ pub mod app { /// Suggested construction patterns: /// /// - kas::app::[Default](type@Default)::[new](Runner::new)(data)? - /// - kas::app::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](AppBuilder::build)(data)? - /// - kas::app::[WgpuBuilder]::[new](WgpuBuilder::new)(custom_wgpu_pipe).[with_theme](WgpuBuilder::with_theme)(theme).[build](AppBuilder::build)(data)? + /// - kas::app::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](Builder::build)(data)? + /// - kas::app::[WgpuBuilder]::[new](WgpuBuilder::new)(custom_wgpu_pipe).[with_theme](WgpuBuilder::with_theme)(theme).[build](Builder::build)(data)? /// /// Where: /// From 299bb17db13c442a1ba470d03bb449e6e5378c35 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 11:09:32 +0000 Subject: [PATCH 6/8] Rename kas_wgpu::WgpuBuilder -> Builder; remove kas::app::WgpuBuilder --- crates/kas-wgpu/src/lib.rs | 12 ++++++------ examples/mandlebrot/mandlebrot.rs | 2 +- src/lib.rs | 6 +----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index 3715294ee..ffe68816b 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -37,13 +37,13 @@ pub use shaded_theme::ShadedTheme; pub extern crate wgpu; /// Builder for a [`kas::app::Runner`] using WGPU -pub struct WgpuBuilder { +pub struct Builder { custom: CB, options: Options, read_env_vars: bool, } -impl runner::AppGraphicsBuilder for WgpuBuilder { +impl runner::AppGraphicsBuilder for Builder { type DefaultTheme = FlatTheme; type Shared = DrawPipe; @@ -71,19 +71,19 @@ impl runner::AppGraphicsBuilder for WgpuBuilder { } } -impl Default for WgpuBuilder<()> { +impl Default for Builder<()> { fn default() -> Self { - WgpuBuilder::new(()) + Builder::new(()) } } -impl WgpuBuilder { +impl Builder { /// Construct with the given pipe builder /// /// Pass `()` or use [`Self::default`] when not using a custom pipe. #[inline] pub fn new(cb: CB) -> Self { - WgpuBuilder { + Builder { custom: cb, options: Options::default(), read_env_vars: true, diff --git a/examples/mandlebrot/mandlebrot.rs b/examples/mandlebrot/mandlebrot.rs index 73845c2b5..0ea21a562 100644 --- a/examples/mandlebrot/mandlebrot.rs +++ b/examples/mandlebrot/mandlebrot.rs @@ -499,7 +499,7 @@ fn main() -> kas::app::Result<()> { let window = Window::new(MandlebrotUI::new(), "Mandlebrot").with_decorations(Decorations::Border); let theme = kas::theme::FlatTheme::new(); - let mut app = kas::app::WgpuBuilder::new(PipeBuilder) + let mut app = kas_wgpu::Builder::new(PipeBuilder) .with_theme(theme) .build(())?; let _ = app.config_mut().theme.set_active_scheme("dark"); diff --git a/src/lib.rs b/src/lib.rs index baa73a666..cf9e1d9cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,6 @@ pub mod app { /// /// - kas::app::[Default](type@Default)::[new](Runner::new)(data)? /// - kas::app::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](Builder::build)(data)? - /// - kas::app::[WgpuBuilder]::[new](WgpuBuilder::new)(custom_wgpu_pipe).[with_theme](WgpuBuilder::with_theme)(theme).[build](Builder::build)(data)? /// /// Where: /// @@ -86,12 +85,9 @@ pub mod app { pub use kas_core::app::*; - #[cfg(feature = "wgpu")] pub use kas_wgpu::WgpuBuilder; - /// Runner pre-launch state, configured with the default graphics backend #[cfg(feature = "wgpu")] - pub type Default = - Runner, T>; + pub type Default = Runner, T>; } #[cfg(feature = "dynamic")] From 93cc1f411d666ff184bf7554262653274ee2d596 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 11:14:04 +0000 Subject: [PATCH 7/8] Rename app::AppGraphicsBuilder -> GraphicsBuilder --- crates/kas-core/src/app/app.rs | 14 +++++++------- crates/kas-core/src/app/common.rs | 2 +- crates/kas-core/src/app/event_loop.rs | 8 ++++---- crates/kas-core/src/app/mod.rs | 6 +++--- crates/kas-core/src/app/shared.rs | 14 ++++++-------- crates/kas-core/src/app/window.rs | 12 ++++++------ crates/kas-wgpu/src/lib.rs | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index 2138841ad..aaadb9763 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -5,7 +5,7 @@ //! [`Runner`] and supporting elements -use super::{AppData, AppGraphicsBuilder, Platform, ProxyAction, Result, State}; +use super::{AppData, GraphicsBuilder, Platform, ProxyAction, Result, State}; use crate::config::{Config, Options}; use crate::draw::{DrawShared, DrawSharedImpl}; use crate::theme::{self, Theme}; @@ -15,14 +15,14 @@ use std::cell::{Ref, RefCell, RefMut}; use std::rc::Rc; use winit::event_loop::{EventLoop, EventLoopProxy}; -pub struct Runner> { +pub struct Runner> { el: EventLoop, windows: Vec>>, state: State, } impl_scope! { - pub struct Builder> { + pub struct Builder> { graphical: G, theme: T, options: Option, @@ -108,7 +108,7 @@ pub trait RunnerInherent { type DrawShared: DrawSharedImpl; } -impl RunnerInherent for Runner +impl RunnerInherent for Runner where T: Theme + 'static, T::Window: theme::Window, @@ -118,7 +118,7 @@ where impl Runner where - G: AppGraphicsBuilder + Default, + G: GraphicsBuilder + Default, { /// Construct a new instance with default options and theme /// @@ -142,7 +142,7 @@ where impl Runner<(), G, T> where - G: AppGraphicsBuilder + Default, + G: GraphicsBuilder + Default, T: Theme, { /// Construct a builder with the given `theme` @@ -152,7 +152,7 @@ where } } -impl Runner +impl Runner where T: Theme + 'static, T::Window: theme::Window, diff --git a/crates/kas-core/src/app/common.rs b/crates/kas-core/src/app/common.rs index 0f22464a8..b2ef17f48 100644 --- a/crates/kas-core/src/app/common.rs +++ b/crates/kas-core/src/app/common.rs @@ -175,7 +175,7 @@ impl Platform { /// Builder for a graphics backend /// /// See also [`Runner`](super::Runner). -pub trait AppGraphicsBuilder { +pub trait GraphicsBuilder { /// The default theme type DefaultTheme: Default + Theme; diff --git a/crates/kas-core/src/app/event_loop.rs b/crates/kas-core/src/app/event_loop.rs index a53382016..77ee81b01 100644 --- a/crates/kas-core/src/app/event_loop.rs +++ b/crates/kas-core/src/app/event_loop.rs @@ -5,7 +5,7 @@ //! Event loop and handling -use super::{AppData, AppGraphicsBuilder, Pending, State}; +use super::{AppData, GraphicsBuilder, Pending, State}; use super::{ProxyAction, Window}; use crate::theme::Theme; use crate::{Action, WindowId}; @@ -17,7 +17,7 @@ use winit::event_loop::{ActiveEventLoop, ControlFlow}; use winit::window as ww; /// Event-loop data structure (i.e. all run-time state) -pub(super) struct Loop> +pub(super) struct Loop> where T::Window: kas::theme::Window, { @@ -36,7 +36,7 @@ where impl ApplicationHandler for Loop where - G: AppGraphicsBuilder, + G: GraphicsBuilder, T: Theme, T::Window: kas::theme::Window, { @@ -164,7 +164,7 @@ where } } -impl> Loop +impl> Loop where T::Window: kas::theme::Window, { diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index 7792b0404..1f6f2fc94 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -26,7 +26,7 @@ pub use common::{Error, Platform, Result}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] #[cfg_attr(docsrs, doc(cfg(internal_doc)))] -pub use common::{AppGraphicsBuilder, WindowSurface}; +pub use common::{GraphicsBuilder, WindowSurface}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] #[cfg_attr(docsrs, doc(cfg(internal_doc)))] @@ -54,7 +54,7 @@ impl AppData for () { #[crate::autoimpl(Debug)] #[cfg(winit)] -enum Pending> { +enum Pending> { AddPopup(WindowId, WindowId, kas::PopupDescriptor), // NOTE: we don't need G, T here if we construct the Window later. // But this way we can pass a single boxed value. @@ -277,7 +277,7 @@ mod test { } struct AGB; - impl AppGraphicsBuilder for AGB { + impl GraphicsBuilder for AGB { type DefaultTheme = crate::theme::SimpleTheme; type Shared = DrawShared; diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/app/shared.rs index b407fd2eb..18fc27aed 100644 --- a/crates/kas-core/src/app/shared.rs +++ b/crates/kas-core/src/app/shared.rs @@ -5,7 +5,7 @@ //! Shared state -use super::{AppData, AppGraphicsBuilder, Error, Pending, Platform}; +use super::{AppData, Error, GraphicsBuilder, Pending, Platform}; use crate::config::{Config, Options}; use crate::draw::DrawShared; use crate::theme::Theme; @@ -21,7 +21,7 @@ use std::task::Waker; #[cfg(feature = "clipboard")] use arboard::Clipboard; /// Runner state used by [`RunnerT`] -pub(super) struct SharedState> { +pub(super) struct SharedState> { pub(super) platform: Platform, pub(super) config: Rc>, #[cfg(feature = "clipboard")] @@ -34,14 +34,14 @@ pub(super) struct SharedState> { +pub(super) struct State> { pub(super) shared: SharedState, pub(super) data: Data, /// Estimated scale factor (from last window constructed or available screens) options: Options, } -impl> State +impl> State where T::Window: kas::theme::Window, { @@ -105,7 +105,7 @@ where } } -impl> SharedState { +impl> SharedState { /// Return the next window identifier /// /// TODO(opt): this should recycle used identifiers since Id does not @@ -196,9 +196,7 @@ pub(crate) trait RunnerT { fn waker(&self) -> &std::task::Waker; } -impl> RunnerT - for SharedState -{ +impl> RunnerT for SharedState { fn add_popup(&mut self, parent_id: WindowId, popup: kas::PopupDescriptor) -> WindowId { let id = self.next_window_id(); self.pending diff --git a/crates/kas-core/src/app/window.rs b/crates/kas-core/src/app/window.rs index 9b944acb8..76db43a91 100644 --- a/crates/kas-core/src/app/window.rs +++ b/crates/kas-core/src/app/window.rs @@ -7,7 +7,7 @@ use super::common::WindowSurface; use super::shared::{SharedState, State}; -use super::{AppData, AppGraphicsBuilder}; +use super::{AppData, GraphicsBuilder}; use crate::cast::{Cast, Conv}; use crate::config::WindowConfig; use crate::decorations::Decorations; @@ -26,7 +26,7 @@ use winit::window::WindowAttributes; /// Window fields requiring a frame or surface #[crate::autoimpl(Deref, DerefMut using self.window)] -struct WindowData> { +struct WindowData> { window: Arc, #[cfg(all(wayland_platform, feature = "clipboard"))] wayland_clipboard: Option, @@ -44,7 +44,7 @@ struct WindowData> { /// Per-window data #[autoimpl(Debug ignore self._data, self.widget, self.ev_state, self.window)] -pub struct Window> { +pub struct Window> { _data: std::marker::PhantomData, pub(super) widget: kas::Window, pub(super) window_id: WindowId, @@ -53,7 +53,7 @@ pub struct Window> { } // Public functions, for use by the toolkit -impl> Window { +impl> Window { /// Construct window state (widget) pub(super) fn new( shared: &SharedState, @@ -397,7 +397,7 @@ impl> Window { } // Internal functions -impl> Window { +impl> Window { fn reconfigure(&mut self, state: &State) { let time = Instant::now(); let Some(ref mut window) = self.window else { @@ -569,7 +569,7 @@ pub(crate) trait WindowDataErased { fn winit_window(&self) -> Option<&winit::window::Window>; } -impl> WindowDataErased for WindowData { +impl> WindowDataErased for WindowData { fn window_id(&self) -> WindowId { self.window_id } diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index ffe68816b..72d826393 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -43,7 +43,7 @@ pub struct Builder { read_env_vars: bool, } -impl runner::AppGraphicsBuilder for Builder { +impl runner::GraphicsBuilder for Builder { type DefaultTheme = FlatTheme; type Shared = DrawPipe; From 25001ed50dfec74ff930bc95d576c22a25777901 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 30 Nov 2024 11:23:25 +0000 Subject: [PATCH 8/8] Rename kas::app -> runner --- crates/kas-core/src/event/cx/cx_pub.rs | 2 +- crates/kas-core/src/event/cx/mod.rs | 2 +- crates/kas-core/src/event/mod.rs | 2 +- crates/kas-core/src/lib.rs | 2 +- crates/kas-core/src/{app => runner}/common.rs | 0 crates/kas-core/src/{app => runner}/event_loop.rs | 0 crates/kas-core/src/{app => runner}/mod.rs | 8 ++++---- crates/kas-core/src/{app/app.rs => runner/runner.rs} | 0 crates/kas-core/src/{app => runner}/shared.rs | 0 crates/kas-core/src/{app => runner}/window.rs | 0 crates/kas-core/src/theme/mod.rs | 2 +- crates/kas-wgpu/src/draw/draw_pipe.rs | 2 +- crates/kas-wgpu/src/lib.rs | 4 ++-- crates/kas-wgpu/src/surface.rs | 2 +- examples/calculator.rs | 4 ++-- examples/clock.rs | 6 +++--- examples/counter.rs | 4 ++-- examples/cursors.rs | 4 ++-- examples/data-list-view.rs | 4 ++-- examples/data-list.rs | 4 ++-- examples/gallery.rs | 10 +++++----- examples/hello.rs | 4 ++-- examples/layout.rs | 4 ++-- examples/mandlebrot/mandlebrot.rs | 8 ++++---- examples/proxy.rs | 8 ++++---- examples/splitter.rs | 4 ++-- examples/stopwatch.rs | 4 ++-- examples/sync-counter.rs | 11 ++++++----- examples/times-tables.rs | 4 ++-- src/lib.rs | 10 +++++----- 30 files changed, 60 insertions(+), 59 deletions(-) rename crates/kas-core/src/{app => runner}/common.rs (100%) rename crates/kas-core/src/{app => runner}/event_loop.rs (100%) rename crates/kas-core/src/{app => runner}/mod.rs (98%) rename crates/kas-core/src/{app/app.rs => runner/runner.rs} (100%) rename crates/kas-core/src/{app => runner}/shared.rs (100%) rename crates/kas-core/src/{app => runner}/window.rs (100%) diff --git a/crates/kas-core/src/event/cx/cx_pub.rs b/crates/kas-core/src/event/cx/cx_pub.rs index 2c7b618fc..36af21e76 100644 --- a/crates/kas-core/src/event/cx/cx_pub.rs +++ b/crates/kas-core/src/event/cx/cx_pub.rs @@ -822,7 +822,7 @@ impl<'a> EventCx<'a> { /// available to a running UI. This method may be used instead. /// /// Requirement: the type `Data` must match the type of data passed to the - /// [`Runner`](crate::app::Runner) and used by other windows. + /// [`Runner`](crate::runner::Runner) and used by other windows. /// If not, a run-time error will result. /// /// Caveat: if an error occurs opening the new window it will not be diff --git a/crates/kas-core/src/event/cx/mod.rs b/crates/kas-core/src/event/cx/mod.rs index bbdc1148f..f6fe95d69 100644 --- a/crates/kas-core/src/event/cx/mod.rs +++ b/crates/kas-core/src/event/cx/mod.rs @@ -17,11 +17,11 @@ use std::pin::Pin; use std::time::Instant; use super::*; -use crate::app::{Platform, RunnerT, WindowDataErased}; use crate::cast::Cast; use crate::config::WindowConfig; use crate::geom::Coord; use crate::messages::{Erased, MessageStack}; +use crate::runner::{Platform, RunnerT, WindowDataErased}; use crate::util::WidgetHierarchy; use crate::{Action, Id, NavAdvance, Node, WindowId}; diff --git a/crates/kas-core/src/event/mod.rs b/crates/kas-core/src/event/mod.rs index 48408f49e..5ec4f7f74 100644 --- a/crates/kas-core/src/event/mod.rs +++ b/crates/kas-core/src/event/mod.rs @@ -37,7 +37,7 @@ //! - If the message stack is non-empty (see [`EventCx::push`]), //! call [`Events::handle_messages`]. //! 7. If the message stack is not empty, call -//! [`AppData::handle_messages`](crate::app::AppData::handle_messages). +//! [`AppData::handle_messages`](crate::runner::AppData::handle_messages). //! 8. Clear any messages still on the message stack, printing a warning to the //! log. Messages *should* be handled during unwinding, though not doing so //! is safe (and possibly useful during development). diff --git a/crates/kas-core/src/lib.rs b/crates/kas-core/src/lib.rs index 7114a7f4b..b93b45700 100644 --- a/crates/kas-core/src/lib.rs +++ b/crates/kas-core/src/lib.rs @@ -38,7 +38,6 @@ pub use kas_macros::{cell_collection, collection, impl_anon, impl_scope, widget_ pub use root::{Window, WindowCommand, WindowId}; // public implementations: -pub mod app; pub mod classes; pub mod config; pub mod dir; @@ -51,6 +50,7 @@ pub mod hidden; pub mod layout; pub mod messages; pub mod prelude; +pub mod runner; pub mod text; pub mod theme; pub mod util; diff --git a/crates/kas-core/src/app/common.rs b/crates/kas-core/src/runner/common.rs similarity index 100% rename from crates/kas-core/src/app/common.rs rename to crates/kas-core/src/runner/common.rs diff --git a/crates/kas-core/src/app/event_loop.rs b/crates/kas-core/src/runner/event_loop.rs similarity index 100% rename from crates/kas-core/src/app/event_loop.rs rename to crates/kas-core/src/runner/event_loop.rs diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/runner/mod.rs similarity index 98% rename from crates/kas-core/src/app/mod.rs rename to crates/kas-core/src/runner/mod.rs index 1f6f2fc94..d8733f558 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/runner/mod.rs @@ -5,24 +5,24 @@ //! Runner, platforms and backends -#[cfg(winit)] mod app; mod common; #[cfg(winit)] mod event_loop; +#[cfg(winit)] mod runner; #[cfg(winit)] mod shared; #[cfg(winit)] mod window; use crate::messages::MessageStack; #[cfg(winit)] use crate::WindowId; -#[cfg(winit)] use app::PlatformWrapper; #[cfg(winit)] use event_loop::Loop; +#[cfg(winit)] use runner::PlatformWrapper; #[cfg(winit)] pub(crate) use shared::RunnerT; #[cfg(winit)] use shared::State; #[cfg(winit)] pub(crate) use window::{Window, WindowDataErased}; -#[cfg(winit)] -pub use app::{Builder, ClosedError, Proxy, Runner, RunnerInherent}; pub use common::{Error, Platform, Result}; +#[cfg(winit)] +pub use runner::{Builder, ClosedError, Proxy, Runner, RunnerInherent}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] #[cfg_attr(docsrs, doc(cfg(internal_doc)))] diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/runner/runner.rs similarity index 100% rename from crates/kas-core/src/app/app.rs rename to crates/kas-core/src/runner/runner.rs diff --git a/crates/kas-core/src/app/shared.rs b/crates/kas-core/src/runner/shared.rs similarity index 100% rename from crates/kas-core/src/app/shared.rs rename to crates/kas-core/src/runner/shared.rs diff --git a/crates/kas-core/src/app/window.rs b/crates/kas-core/src/runner/window.rs similarity index 100% rename from crates/kas-core/src/app/window.rs rename to crates/kas-core/src/runner/window.rs diff --git a/crates/kas-core/src/theme/mod.rs b/crates/kas-core/src/theme/mod.rs index 065c843b5..12ef80043 100644 --- a/crates/kas-core/src/theme/mod.rs +++ b/crates/kas-core/src/theme/mod.rs @@ -8,7 +8,7 @@ //! Widgets expect the theme to provide an implementation of [`SizeCx`] and of //! [`DrawCx`]. //! -//! Constructing a [`Runner`](crate::app::Runner) requires a [`Theme`]. Two +//! Constructing a [`Runner`](crate::runner::Runner) requires a [`Theme`]. Two //! implementations are provided here: [`SimpleTheme`] and [`FlatTheme`]. //! An adapter, [`MultiTheme`], is also provided. diff --git a/crates/kas-wgpu/src/draw/draw_pipe.rs b/crates/kas-wgpu/src/draw/draw_pipe.rs index 646c061e0..825210ce6 100644 --- a/crates/kas-wgpu/src/draw/draw_pipe.rs +++ b/crates/kas-wgpu/src/draw/draw_pipe.rs @@ -12,12 +12,12 @@ use wgpu::util::DeviceExt; use super::*; use crate::DrawShadedImpl; use crate::Options; -use kas::app::Error; use kas::cast::traits::*; use kas::config::RasterConfig; use kas::draw::color::Rgba; use kas::draw::*; use kas::geom::{Quad, Size, Vec2}; +use kas::runner::Error; use kas::text::{Effect, TextDisplay}; /// Failure while constructing a [`Runner`]: no graphics adapter found diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index 72d826393..38fdf2cdc 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -27,7 +27,7 @@ mod shaded_theme; mod surface; use crate::draw::{CustomPipeBuilder, DrawPipe}; -use kas::app as runner; +use kas::runner; use kas::theme::{FlatTheme, Theme}; use wgpu::rwh; @@ -36,7 +36,7 @@ pub use options::Options; pub use shaded_theme::ShadedTheme; pub extern crate wgpu; -/// Builder for a [`kas::app::Runner`] using WGPU +/// Builder for a [`kas::runner::Runner`] using WGPU pub struct Builder { custom: CB, options: Options, diff --git a/crates/kas-wgpu/src/surface.rs b/crates/kas-wgpu/src/surface.rs index 997af090a..6df091453 100644 --- a/crates/kas-wgpu/src/surface.rs +++ b/crates/kas-wgpu/src/surface.rs @@ -6,11 +6,11 @@ //! WGPU window surface use crate::draw::{CustomPipe, DrawPipe, DrawWindow}; -use kas::app::{raw_window_handle as rwh, Error, WindowSurface}; use kas::cast::Cast; use kas::draw::color::Rgba; use kas::draw::{DrawIface, DrawSharedImpl, WindowCommon}; use kas::geom::Size; +use kas::runner::{raw_window_handle as rwh, Error, WindowSurface}; use std::time::Instant; /// Per-window data diff --git a/examples/calculator.rs b/examples/calculator.rs index f5d934370..bf0241dcc 100644 --- a/examples/calculator.rs +++ b/examples/calculator.rs @@ -69,11 +69,11 @@ fn calc_ui() -> Window<()> { Window::new(ui, "Calculator") } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let theme = kas_wgpu::ShadedTheme::new(); - let mut app = kas::app::Default::with_theme(theme).build(())?; + let mut app = kas::runner::Default::with_theme(theme).build(())?; let _ = app.config_mut().font.set_size(24.0); app.with(calc_ui()).run() } diff --git a/examples/clock.rs b/examples/clock.rs index 82e0a0a44..523bb3f65 100644 --- a/examples/clock.rs +++ b/examples/clock.rs @@ -17,14 +17,14 @@ use chrono::prelude::*; use std::f32::consts::PI; use std::time::Duration; -use kas::app::RunnerInherent; use kas::draw::color::{Rgba, Rgba8Srgb}; use kas::draw::{Draw, DrawRounded}; use kas::geom::{Quad, Vec2}; use kas::prelude::*; +use kas::runner::RunnerInherent; use kas::text::Text; -type Runner = kas::app::Default<(), kas::theme::SimpleTheme>; +type Runner = kas::runner::Default<(), kas::theme::SimpleTheme>; impl_scope! { #[derive(Clone)] @@ -168,7 +168,7 @@ impl_scope! { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let window = Window::new(Clock::new(), "Clock") diff --git a/examples/counter.rs b/examples/counter.rs index 8fbefc54a..bb9390af5 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -24,11 +24,11 @@ fn counter() -> impl Widget { Adapt::new(tree, 0).on_message(|_, count, Increment(add)| *count += add) } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let theme = kas::theme::SimpleTheme::new(); - let mut app = kas::app::Default::with_theme(theme).build(())?; + let mut app = kas::runner::Default::with_theme(theme).build(())?; let _ = app.config_mut().font.set_size(24.0); app.with(Window::new(counter(), "Counter")).run() } diff --git a/examples/cursors.rs b/examples/cursors.rs index af89caf6d..0a00938fe 100644 --- a/examples/cursors.rs +++ b/examples/cursors.rs @@ -40,7 +40,7 @@ macro_rules! cursor { }; } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); // These are winit::window::CursorIcon enum variants @@ -82,5 +82,5 @@ fn main() -> kas::app::Result<()> { ]); let window = Window::new(column, "Cursor gallery"); - kas::app::Default::new(())?.with(window).run() + kas::runner::Default::new(())?.with(window).run() } diff --git a/examples/data-list-view.rs b/examples/data-list-view.rs index 7295f5949..6daff8f6f 100644 --- a/examples/data-list-view.rs +++ b/examples/data-list-view.rs @@ -183,7 +183,7 @@ impl Driver for MyDriver { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let controls = row![ @@ -218,5 +218,5 @@ fn main() -> kas::app::Result<()> { let window = Window::new(ui, "Dynamic widget demo"); - kas::app::Default::new(())?.with(window).run() + kas::runner::Default::new(())?.with(window).run() } diff --git a/examples/data-list.rs b/examples/data-list.rs index 54ebf4deb..a9ac8cafe 100644 --- a/examples/data-list.rs +++ b/examples/data-list.rs @@ -139,7 +139,7 @@ impl_scope! { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let controls = row![ @@ -183,5 +183,5 @@ fn main() -> kas::app::Result<()> { let window = Window::new(ui, "Dynamic widget demo"); - kas::app::Default::new(())?.with(window).run() + kas::runner::Default::new(())?.with(window).run() } diff --git a/examples/gallery.rs b/examples/gallery.rs index 9611a0183..86565134f 100644 --- a/examples/gallery.rs +++ b/examples/gallery.rs @@ -532,7 +532,7 @@ KAS_CONFIG_MODE=readwrite Box::new(ui) } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let theme = kas::theme::MultiTheme::builder() @@ -540,7 +540,7 @@ fn main() -> kas::app::Result<()> { .add("simple", kas::theme::SimpleTheme::new()) .add("shaded", kas_wgpu::ShadedTheme::new()) .build(); - let mut app = kas::app::Default::with_theme(theme).build(())?; + let mut runner = kas::runner::Default::with_theme(theme).build(())?; // TODO: use as logo of tab // let img_gallery = Svg::new(include_bytes!("../res/gallery-line.svg")); @@ -565,7 +565,7 @@ fn main() -> kas::app::Result<()> { .menu("&Style", |menu| { menu.submenu("&Colours", |mut menu| { // Enumerate colour schemes. - for (name, _) in app.config().theme.color_schemes() { + for (name, _) in runner.config().theme.color_schemes() { let mut title = String::with_capacity(name.len() + 1); match name { "dark" => title.push_str("Dar&k"), @@ -630,6 +630,6 @@ fn main() -> kas::app::Result<()> { } }); - app.add(Window::new(ui, "Gallery — Widgets")); - app.run() + runner.add(Window::new(ui, "Gallery — Widgets")); + runner.run() } diff --git a/examples/hello.rs b/examples/hello.rs index f19d6ab30..85d0b81ed 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -7,8 +7,8 @@ use kas::widgets::dialog::MessageBox; -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { let window = MessageBox::new("Message").into_window("Hello world"); - kas::app::Default::new(())?.with(window).run() + kas::runner::Default::new(())?.with(window).run() } diff --git a/examples/layout.rs b/examples/layout.rs index a7ea31eec..0caef2b1d 100644 --- a/examples/layout.rs +++ b/examples/layout.rs @@ -12,7 +12,7 @@ use kas::Window; const LIPSUM: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nunc mi, consequat eget urna ut, auctor luctus mi. Sed molestie mi est. Sed non ligula ante. Curabitur ac molestie ante, nec sodales eros. In non arcu at turpis euismod bibendum ut tincidunt eros. Suspendisse blandit maximus nisi, viverra hendrerit elit efficitur et. Morbi ut facilisis eros. Vivamus dignissim, sapien sed mattis consectetur, libero leo imperdiet turpis, ac pulvinar libero purus eu lorem. Etiam quis sollicitudin urna. Integer vitae erat vel neque gravida blandit ac non quam."; const CRASIT: &str = "Cras sit amet justo ipsum. Aliquam in nunc posuere leo egestas laoreet convallis eu libero. Nullam ut massa ante. Cras vitae velit pharetra, euismod nisl suscipit, feugiat nulla. Aenean consectetur, diam non tristique iaculis, nisl lectus hendrerit sapien, nec rhoncus mi sem non odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla a lorem eu ipsum faucibus placerat ac quis quam. Curabitur justo ligula, laoreet nec ultrices eu, scelerisque non metus. Mauris sit amet est enim. Mauris risus eros, accumsan ut iaculis sit amet, sagittis facilisis neque. Nunc venenatis risus nec purus malesuada, a tristique arcu efficitur. Nulla suscipit arcu nibh. Cras facilisis nibh a gravida aliquet. Praesent fringilla felis a tristique luctus."; -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let ui = grid! { @@ -25,5 +25,5 @@ fn main() -> kas::app::Result<()> { }; let window = Window::new(ui, "Layout demo"); - kas::app::Default::new(())?.with(window).run() + kas::runner::Default::new(())?.with(window).run() } diff --git a/examples/mandlebrot/mandlebrot.rs b/examples/mandlebrot/mandlebrot.rs index 0ea21a562..f210a306c 100644 --- a/examples/mandlebrot/mandlebrot.rs +++ b/examples/mandlebrot/mandlebrot.rs @@ -493,15 +493,15 @@ impl_scope! { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let window = Window::new(MandlebrotUI::new(), "Mandlebrot").with_decorations(Decorations::Border); let theme = kas::theme::FlatTheme::new(); - let mut app = kas_wgpu::Builder::new(PipeBuilder) + let mut runner = kas_wgpu::Builder::new(PipeBuilder) .with_theme(theme) .build(())?; - let _ = app.config_mut().theme.set_active_scheme("dark"); - app.with(window).run() + let _ = runner.config_mut().theme.set_active_scheme("dark"); + runner.with(window).run() } diff --git a/examples/proxy.rs b/examples/proxy.rs index fca944697..8d43f5c1d 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -23,7 +23,7 @@ struct AppData { color: Option, } -impl kas::app::AppData for AppData { +impl kas::runner::AppData for AppData { fn handle_messages(&mut self, messages: &mut kas::messages::MessageStack) { if let Some(SetColor(color)) = messages.try_pop() { self.color = Some(color); @@ -31,11 +31,11 @@ impl kas::app::AppData for AppData { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let data = AppData { color: None }; - let app = kas::app::Default::new(data)?; + let app = kas::runner::Default::new(data)?; // We construct a proxy from the app to enable cross-thread communication. let proxy = app.create_proxy(); @@ -99,7 +99,7 @@ impl_scope! { } } -fn generate_colors(mut proxy: kas::app::Proxy) { +fn generate_colors(mut proxy: kas::runner::Proxy) { // Loading takes time: thread::sleep(Duration::from_secs(1)); diff --git a/examples/splitter.rs b/examples/splitter.rs index de2b928b0..87d9a7ddb 100644 --- a/examples/splitter.rs +++ b/examples/splitter.rs @@ -14,7 +14,7 @@ enum Message { Incr, } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let ui = column![ @@ -38,7 +38,7 @@ fn main() -> kas::app::Result<()> { let window = Window::new(adapt, "Slitter panes"); let theme = kas_wgpu::ShadedTheme::new(); - kas::app::Default::with_theme(theme) + kas::runner::Default::with_theme(theme) .build(())? .with(window) .run() diff --git a/examples/stopwatch.rs b/examples/stopwatch.rs index 522541d6d..b42b02a54 100644 --- a/examples/stopwatch.rs +++ b/examples/stopwatch.rs @@ -51,7 +51,7 @@ fn make_window() -> impl Widget { }) } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let window = Window::new(make_window(), "Stopwatch") @@ -60,7 +60,7 @@ fn main() -> kas::app::Result<()> { .with_restrictions(true, true); let theme = kas_wgpu::ShadedTheme::new(); - let mut app = kas::app::Default::with_theme(theme).build(())?; + let mut app = kas::runner::Default::with_theme(theme).build(())?; let _ = app.config_mut().font.set_size(24.0); let _ = app.config_mut().theme.set_active_scheme("dark"); app.with(window).run() diff --git a/examples/sync-counter.rs b/examples/sync-counter.rs index 3538e175d..bd0b2d4c8 100644 --- a/examples/sync-counter.rs +++ b/examples/sync-counter.rs @@ -15,7 +15,7 @@ struct Increment(i32); #[derive(Clone, Copy, Debug)] struct Count(i32); -impl kas::app::AppData for Count { +impl kas::runner::AppData for Count { fn handle_messages(&mut self, messages: &mut MessageStack) { if let Some(Increment(add)) = messages.try_pop() { self.0 += add; @@ -52,15 +52,16 @@ fn counter(title: &str) -> Window { Window::new(ui, title) } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let count = Count(0); let theme = kas_wgpu::ShadedTheme::new(); - let mut app = kas::app::Default::with_theme(theme).build(count)?; - let _ = app.config_mut().font.set_size(24.0); - app.with(counter("Counter 1")) + let mut runner = kas::runner::Default::with_theme(theme).build(count)?; + let _ = runner.config_mut().font.set_size(24.0); + runner + .with(counter("Counter 1")) .with(counter("Counter 2")) .run() } diff --git a/examples/times-tables.rs b/examples/times-tables.rs index 9436d265e..1bfbfd7c2 100644 --- a/examples/times-tables.rs +++ b/examples/times-tables.rs @@ -45,7 +45,7 @@ impl MatrixData for TableSize { } } -fn main() -> kas::app::Result<()> { +fn main() -> kas::runner::Result<()> { env_logger::init(); let table = MatrixView::new(driver::NavView) @@ -75,7 +75,7 @@ fn main() -> kas::app::Result<()> { let window = Window::new(ui, "Times-Tables"); let theme = kas::theme::SimpleTheme::new(); - kas::app::Default::with_theme(theme) + kas::runner::Default::with_theme(theme) .build(())? .with(window) .run() diff --git a/src/lib.rs b/src/lib.rs index cf9e1d9cc..7a4a31276 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,7 @@ pub mod resvg { pub use kas_resvg::*; } -pub mod app { +pub mod runner { //! [`Runner`], platforms and backends //! //! Start by constructing a [`Runner`] or its [`Default`](type@Default) @@ -72,8 +72,8 @@ pub mod app { /// /// Suggested construction patterns: /// - /// - kas::app::[Default](type@Default)::[new](Runner::new)(data)? - /// - kas::app::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](Builder::build)(data)? + /// - kas::runner::[Default](type@Default)::[new](Runner::new)(data)? + /// - kas::runner::[Default](type@Default)::[with_theme](Runner::with_theme)(theme).[build](Builder::build)(data)? /// /// Where: /// @@ -81,9 +81,9 @@ pub mod app { /// - `theme` is some object implementing [`Theme`](crate::theme::Theme) /// - `custom_wgpu_pipe` is a custom WGPU graphics pipeline #[doc(inline)] - pub use kas_core::app::Runner; + pub use kas_core::runner::Runner; - pub use kas_core::app::*; + pub use kas_core::runner::*; /// Runner pre-launch state, configured with the default graphics backend #[cfg(feature = "wgpu")]