summaryrefslogtreecommitdiffstats
path: root/src/application.rs
diff options
context:
space:
mode:
authorLibravatar Gigas002 <24297712+Gigas002@users.noreply.github.com>2024-03-27 19:47:48 +0900
committerLibravatar GitHub <noreply@github.com>2024-03-27 19:47:48 +0900
commit19afc66cadfc7ea230d4d749b0d7b0197e29cf93 (patch)
treed012dff84003f2d7d18a1e6bc4bdac62df73b322 /src/application.rs
parent4334e63ba1dd88b367f3b7f2790b7869d11d12c0 (diff)
parent1df1cf82f4c9485533f2566c8490cfe188b4ae6a (diff)
downloadiced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.tar.gz
iced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.tar.bz2
iced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.zip
Merge branch 'master' into viewer_content_fit
Diffstat (limited to 'src/application.rs')
-rw-r--r--src/application.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/application.rs b/src/application.rs
index 8317abcb..9197834b 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -1,4 +1,6 @@
//! Build interactive cross-platform applications.
+use crate::core::text;
+use crate::graphics::compositor;
use crate::shell::application;
use crate::{Command, Element, Executor, Settings, Subscription};
@@ -60,7 +62,7 @@ pub use application::{Appearance, DefaultStyle};
/// ```no_run
/// use iced::advanced::Application;
/// use iced::executor;
-/// use iced::{Command, Element, Settings, Theme};
+/// use iced::{Command, Element, Settings, Theme, Renderer};
///
/// pub fn main() -> iced::Result {
/// Hello::run(Settings::default())
@@ -73,6 +75,7 @@ pub use application::{Appearance, DefaultStyle};
/// type Flags = ();
/// type Message = ();
/// type Theme = Theme;
+/// type Renderer = Renderer;
///
/// fn new(_flags: ()) -> (Hello, Command<Self::Message>) {
/// (Hello, Command::none())
@@ -109,6 +112,9 @@ where
/// The theme of your [`Application`].
type Theme: Default;
+ /// The renderer of your [`Application`].
+ type Renderer: text::Renderer + compositor::Default;
+
/// The data needed to initialize your [`Application`].
type Flags;
@@ -142,7 +148,7 @@ where
/// Returns the widgets to display in the [`Application`].
///
/// These widgets can produce __messages__ based on user interaction.
- fn view(&self) -> Element<'_, Self::Message, Self::Theme, crate::Renderer>;
+ fn view(&self) -> Element<'_, Self::Message, Self::Theme, Self::Renderer>;
/// Returns the current [`Theme`] of the [`Application`].
///
@@ -195,7 +201,7 @@ where
Self: 'static,
{
#[allow(clippy::needless_update)]
- let renderer_settings = crate::renderer::Settings {
+ let renderer_settings = crate::graphics::Settings {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
antialiasing: if settings.antialiasing {
@@ -203,13 +209,13 @@ where
} else {
None
},
- ..crate::renderer::Settings::default()
+ ..crate::graphics::Settings::default()
};
let run = crate::shell::application::run::<
Instance<Self>,
Self::Executor,
- crate::renderer::Compositor,
+ <Self::Renderer as compositor::Default>::Compositor,
>(settings.into(), renderer_settings);
#[cfg(target_arch = "wasm32")]
@@ -241,7 +247,7 @@ where
{
type Message = A::Message;
type Theme = A::Theme;
- type Renderer = crate::Renderer;
+ type Renderer = A::Renderer;
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
self.0.update(message)