mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 12:08:11 +08:00
Rename PropertyHolder to LayoutHolder
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use super::simple_dialogs::{self, AboutGraphiteDialog, ComingSoonDialog};
|
||||
use crate::messages::layout::utility_types::layout_widget::PropertyHolder;
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
@@ -24,7 +23,7 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
|
||||
DialogMessage::CloseAllDocumentsWithConfirmation => {
|
||||
let dialog = simple_dialogs::CloseAllDocumentsDialog;
|
||||
dialog.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
dialog.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Copy".to_string() });
|
||||
}
|
||||
DialogMessage::CloseDialogAndThen { followups } => {
|
||||
@@ -35,7 +34,7 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
}
|
||||
DialogMessage::DisplayDialogError { title, description } => {
|
||||
let dialog = simple_dialogs::ErrorDialog { title, description };
|
||||
dialog.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
dialog.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Warning".to_string() });
|
||||
}
|
||||
DialogMessage::RequestAboutGraphiteDialog => {
|
||||
@@ -46,12 +45,12 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
DialogMessage::RequestAboutGraphiteDialogWithLocalizedCommitDate { localized_commit_date } => {
|
||||
let about_graphite = AboutGraphiteDialog { localized_commit_date };
|
||||
|
||||
about_graphite.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
about_graphite.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "GraphiteLogo".to_string() });
|
||||
}
|
||||
DialogMessage::RequestComingSoonDialog { issue } => {
|
||||
let coming_soon = ComingSoonDialog { issue };
|
||||
coming_soon.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
coming_soon.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Warning".to_string() });
|
||||
}
|
||||
DialogMessage::RequestExportDialog => {
|
||||
@@ -84,7 +83,7 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
has_selection: document.selected_layers().next().is_some(),
|
||||
..Default::default()
|
||||
};
|
||||
self.export_dialog.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
self.export_dialog.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "File".to_string() });
|
||||
}
|
||||
}
|
||||
@@ -94,12 +93,12 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
infinite: false,
|
||||
dimensions: glam::UVec2::new(1920, 1080),
|
||||
};
|
||||
self.new_document_dialog.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
self.new_document_dialog.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "File".to_string() });
|
||||
}
|
||||
DialogMessage::RequestPreferencesDialog => {
|
||||
self.preferences_dialog = PreferencesDialogMessageHandler {};
|
||||
self.preferences_dialog.register_properties(responses, LayoutTarget::DialogDetails, preferences);
|
||||
self.preferences_dialog.send_layout(responses, LayoutTarget::DialogDetails, preferences);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Settings".to_string() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::messages::frontend::utility_types::{ExportBounds, FileType};
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
@@ -35,14 +34,14 @@ impl MessageHandler<ExportDialogMessage, ()> for ExportDialogMessageHandler {
|
||||
}),
|
||||
}
|
||||
|
||||
self.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
self.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
}
|
||||
|
||||
advertise_actions! {ExportDialogUpdate;}
|
||||
}
|
||||
|
||||
impl PropertyHolder for ExportDialogMessageHandler {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for ExportDialogMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let file_name = vec![
|
||||
TextLabel::new("File Name").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Handles modal dialogs that appear as floating menus in the center of the editor window.
|
||||
//!
|
||||
//! Dialogs are represented as structs that implement the `PropertyHolder` trait.
|
||||
//! Dialogs are represented as structs that implement the `LayoutHolder` trait.
|
||||
//!
|
||||
//! To open a dialog, call the function `register_properties` on the dialog struct with `responses` and the `LayoutTarget::DialogDetails` enum variant.
|
||||
//! Then dialog can be opened by sending the `FrontendMessage::DisplayDialog` message;
|
||||
|
||||
+3
-4
@@ -1,4 +1,3 @@
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
@@ -43,14 +42,14 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
|
||||
}
|
||||
}
|
||||
|
||||
self.register_properties(responses, LayoutTarget::DialogDetails);
|
||||
self.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
}
|
||||
|
||||
advertise_actions! {NewDocumentDialogUpdate;}
|
||||
}
|
||||
|
||||
impl PropertyHolder for NewDocumentDialogMessageHandler {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let title = vec![TextLabel::new("New document").bold(true).widget_holder()];
|
||||
|
||||
let name = vec![
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
@@ -12,21 +11,21 @@ impl MessageHandler<PreferencesDialogMessage, &PreferencesMessageHandler> for Pr
|
||||
PreferencesDialogMessage::Confirm => {}
|
||||
}
|
||||
|
||||
self.register_properties(responses, LayoutTarget::DialogDetails, preferences);
|
||||
self.send_layout(responses, LayoutTarget::DialogDetails, preferences);
|
||||
}
|
||||
|
||||
advertise_actions! {PreferencesDialogUpdate;}
|
||||
}
|
||||
|
||||
impl PreferencesDialogMessageHandler {
|
||||
pub fn register_properties(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
||||
pub fn send_layout(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: self.properties(preferences),
|
||||
layout: self.layout(preferences),
|
||||
layout_target,
|
||||
})
|
||||
}
|
||||
|
||||
fn properties(&self, preferences: &PreferencesMessageHandler) -> Layout {
|
||||
fn layout(&self, preferences: &PreferencesMessageHandler) -> Layout {
|
||||
let zoom_with_scroll = vec![
|
||||
TextLabel::new("Input").min_width(60).italic(true).widget_holder(),
|
||||
TextLabel::new("Zoom with Scroll").table_align(true).widget_holder(),
|
||||
|
||||
@@ -7,8 +7,8 @@ pub struct AboutGraphiteDialog {
|
||||
pub localized_commit_date: String,
|
||||
}
|
||||
|
||||
impl PropertyHolder for AboutGraphiteDialog {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for AboutGraphiteDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let links = [
|
||||
("Website", "https://graphite.rs"),
|
||||
("Credits", "https://github.com/GraphiteEditor/Graphite/graphs/contributors"),
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::messages::prelude::*;
|
||||
/// A dialog for confirming the closing of all documents viewable via `file -> close all` in the menu bar.
|
||||
pub struct CloseAllDocumentsDialog;
|
||||
|
||||
impl PropertyHolder for CloseAllDocumentsDialog {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for CloseAllDocumentsDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let discard = TextButton::new("Discard All")
|
||||
.min_width(96)
|
||||
.on_update(|_| {
|
||||
|
||||
@@ -8,8 +8,8 @@ pub struct CloseDocumentDialog {
|
||||
pub document_id: u64,
|
||||
}
|
||||
|
||||
impl PropertyHolder for CloseDocumentDialog {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for CloseDocumentDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let document_id = self.document_id;
|
||||
|
||||
let button_widgets = vec![
|
||||
|
||||
@@ -8,8 +8,8 @@ pub struct ComingSoonDialog {
|
||||
pub issue: Option<i32>,
|
||||
}
|
||||
|
||||
impl PropertyHolder for ComingSoonDialog {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for ComingSoonDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let mut details = "This feature is not implemented yet".to_string();
|
||||
|
||||
let mut buttons = vec![TextButton::new("OK")
|
||||
|
||||
@@ -7,8 +7,8 @@ pub struct ErrorDialog {
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
impl PropertyHolder for ErrorDialog {
|
||||
fn properties(&self) -> Layout {
|
||||
impl LayoutHolder for ErrorDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(&self.title).bold(true).widget_holder()],
|
||||
|
||||
Reference in New Issue
Block a user