Unify Program definition in iced_program subcrate
This commit is contained in:
parent
ebfcb65841
commit
fd1101bd5f
66 changed files with 1862 additions and 1935 deletions
|
|
@ -26,9 +26,7 @@ unconditional-rendering = []
|
|||
|
||||
[dependencies]
|
||||
iced_debug.workspace = true
|
||||
iced_futures.workspace = true
|
||||
iced_graphics.workspace = true
|
||||
iced_runtime.workspace = true
|
||||
iced_program.workspace = true
|
||||
|
||||
log.workspace = true
|
||||
rustc-hash.workspace = true
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl From<graphics::Error> for Error {
|
||||
fn from(error: iced_graphics::Error) -> Error {
|
||||
fn from(error: graphics::Error) -> Error {
|
||||
Error::GraphicsCreationFailed(error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1495
winit/src/lib.rs
1495
winit/src/lib.rs
File diff suppressed because it is too large
Load diff
1599
winit/src/program.rs
1599
winit/src/program.rs
File diff suppressed because it is too large
Load diff
|
|
@ -1,26 +0,0 @@
|
|||
//! Configure your application.
|
||||
use crate::core;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// The settings of an application.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Settings {
|
||||
/// The identifier of the application.
|
||||
///
|
||||
/// If provided, this identifier may be used to identify the application or
|
||||
/// communicate with it through the windowing system.
|
||||
pub id: Option<String>,
|
||||
|
||||
/// The fonts to load on boot.
|
||||
pub fonts: Vec<Cow<'static, [u8]>>,
|
||||
}
|
||||
|
||||
impl From<core::Settings> for Settings {
|
||||
fn from(settings: core::Settings) -> Self {
|
||||
Self {
|
||||
id: settings.id,
|
||||
fonts: settings.fonts,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
mod state;
|
||||
|
||||
use state::State;
|
||||
|
||||
pub use crate::core::window::{Event, Id, RedrawRequest, Settings};
|
||||
|
||||
use crate::conversion;
|
||||
use crate::core::alignment;
|
||||
use crate::core::input_method;
|
||||
|
|
@ -6,12 +12,11 @@ use crate::core::renderer;
|
|||
use crate::core::text;
|
||||
use crate::core::theme;
|
||||
use crate::core::time::Instant;
|
||||
use crate::core::window::{Id, RedrawRequest};
|
||||
use crate::core::{
|
||||
Color, InputMethod, Padding, Point, Rectangle, Size, Text, Vector,
|
||||
};
|
||||
use crate::graphics::Compositor;
|
||||
use crate::program::{Program, State};
|
||||
use crate::program::{self, Program};
|
||||
|
||||
use winit::dpi::{LogicalPosition, LogicalSize};
|
||||
use winit::monitor::MonitorHandle;
|
||||
|
|
@ -47,11 +52,11 @@ where
|
|||
&mut self,
|
||||
id: Id,
|
||||
window: Arc<winit::window::Window>,
|
||||
application: &P,
|
||||
program: &program::Instance<P>,
|
||||
compositor: &mut C,
|
||||
exit_on_close_request: bool,
|
||||
) -> &mut Window<P, C> {
|
||||
let state = State::new(application, id, &window);
|
||||
let state = State::new(program, id, &window);
|
||||
let viewport_version = state.viewport_version();
|
||||
let physical_size = state.physical_size();
|
||||
let surface = compositor.create_surface(
|
||||
|
|
@ -2,7 +2,7 @@ use crate::conversion;
|
|||
use crate::core::{Color, Size};
|
||||
use crate::core::{mouse, theme, window};
|
||||
use crate::graphics::Viewport;
|
||||
use crate::program::Program;
|
||||
use crate::program::{self, Program};
|
||||
|
||||
use winit::event::{Touch, WindowEvent};
|
||||
use winit::window::Window;
|
||||
|
|
@ -46,14 +46,14 @@ where
|
|||
{
|
||||
/// Creates a new [`State`] for the provided [`Program`]'s `window`.
|
||||
pub fn new(
|
||||
application: &P,
|
||||
program: &program::Instance<P>,
|
||||
window_id: window::Id,
|
||||
window: &Window,
|
||||
) -> Self {
|
||||
let title = application.title(window_id);
|
||||
let scale_factor = application.scale_factor(window_id);
|
||||
let theme = application.theme(window_id);
|
||||
let style = application.style(&theme);
|
||||
let title = program.title(window_id);
|
||||
let scale_factor = program.scale_factor(window_id);
|
||||
let theme = program.theme(window_id);
|
||||
let style = program.style(&theme);
|
||||
|
||||
let viewport = {
|
||||
let physical_size = window.inner_size();
|
||||
|
|
@ -185,12 +185,12 @@ where
|
|||
/// and window after calling [`State::update`].
|
||||
pub fn synchronize(
|
||||
&mut self,
|
||||
application: &P,
|
||||
program: &program::Instance<P>,
|
||||
window_id: window::Id,
|
||||
window: &Window,
|
||||
) {
|
||||
// Update window title
|
||||
let new_title = application.title(window_id);
|
||||
let new_title = program.title(window_id);
|
||||
|
||||
if self.title != new_title {
|
||||
window.set_title(&new_title);
|
||||
|
|
@ -198,7 +198,7 @@ where
|
|||
}
|
||||
|
||||
// Update scale factor and size
|
||||
let new_scale_factor = application.scale_factor(window_id);
|
||||
let new_scale_factor = program.scale_factor(window_id);
|
||||
let new_size = window.inner_size();
|
||||
let current_size = self.viewport.physical_size();
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ where
|
|||
}
|
||||
|
||||
// Update theme and appearance
|
||||
self.theme = application.theme(window_id);
|
||||
self.style = application.style(&self.theme);
|
||||
self.theme = program.theme(window_id);
|
||||
self.style = program.style(&self.theme);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue