mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 08:18:12 +08:00
Switch to the widget builder pattern on all remaining layouts (#1346)
* Prefer widget builder pattern * Nits --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
40f9a7d051
commit
de27f2c006
@@ -452,6 +452,7 @@ pub struct WidgetHolder {
|
||||
}
|
||||
|
||||
impl WidgetHolder {
|
||||
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_holder()")]
|
||||
pub fn new(widget: Widget) -> Self {
|
||||
Self { widget_id: generate_uuid(), widget }
|
||||
}
|
||||
|
||||
@@ -4,16 +4,27 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, Serialize, Deserialize, specta::Type)]
|
||||
#[repr(u8)]
|
||||
pub enum LayoutTarget {
|
||||
/// Contains the contents of the dialog, including the title and action buttons. Must be shown with the `FrontendMessage::DisplayDialog` message.
|
||||
DialogDetails,
|
||||
/// Contains the widgets located directly above the canvas to the right, for example the zoom in and out buttons.
|
||||
DocumentBar,
|
||||
/// Contains the dropdown for design / select / guide mode found on the top left of the canvas.
|
||||
DocumentMode,
|
||||
/// Options for opacity seen at the top of the Layers panel.
|
||||
LayerTreeOptions,
|
||||
/// The dropdown menu at the very top of the application: File, Edit, etc.
|
||||
MenuBar,
|
||||
/// Bar at the top of the node graph containing the location and the 'preview' and 'hide' buttons.
|
||||
NodeGraphBar,
|
||||
/// The bar at the top of the Properties panel containing the layer name and icon.
|
||||
PropertiesOptions,
|
||||
/// The body of the Properties panel containing many collapsable sections.
|
||||
PropertiesSections,
|
||||
/// The bar directly above the canvas, left-aligned and to the right of the document mode dropdown.
|
||||
ToolOptions,
|
||||
/// The vertical buttons for all of the tools on the left of the canvas.
|
||||
ToolShelf,
|
||||
/// The color swatch for the working colors and a flip and reset button found at the bottom of the tool shelf.
|
||||
WorkingColors,
|
||||
|
||||
// KEEP THIS ENUM LAST
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
|
||||
use crate::messages::layout::utility_types::layout_widget::WidgetHolder;
|
||||
use crate::messages::layout::utility_types::layout_widget::{Widget, WidgetCallback};
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -51,9 +50,7 @@ impl MenuBarEntry {
|
||||
}
|
||||
|
||||
pub fn create_action(callback: impl Fn(&()) -> Message + 'static + Send + Sync) -> WidgetHolder {
|
||||
WidgetHolder::new(Widget::InvisibleStandinInput(InvisibleStandinInput {
|
||||
on_update: WidgetCallback::new(callback),
|
||||
}))
|
||||
InvisibleStandinInput::new().on_update(callback).widget_holder()
|
||||
}
|
||||
|
||||
pub fn no_action() -> WidgetHolder {
|
||||
|
||||
Reference in New Issue
Block a user