Rename WidgetHolder to WidgetInstance
This commit is contained in:
parent
810ce40e9b
commit
4581689d9c
|
|
@ -72,8 +72,8 @@ impl DialogLayoutHolder for ExportDialogMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
@ -92,14 +92,14 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
|||
.collect();
|
||||
|
||||
let export_type = vec![
|
||||
TextLabel::new("File Type").table_align(true).min_width("100px").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
RadioInput::new(entries).selected_index(Some(self.file_type as u32)).widget_holder(),
|
||||
TextLabel::new("File Type").table_align(true).min_width("100px").widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
RadioInput::new(entries).selected_index(Some(self.file_type as u32)).widget_instance(),
|
||||
];
|
||||
|
||||
let resolution = vec![
|
||||
TextLabel::new("Scale Factor").table_align(true).min_width("100px").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Scale Factor").table_align(true).min_width("100px").widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(self.scale_factor))
|
||||
.unit("")
|
||||
.min(0.)
|
||||
|
|
@ -107,7 +107,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
|||
.disabled(self.file_type == FileType::Svg)
|
||||
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor { factor: number_input.value.unwrap() }.into())
|
||||
.min_width(200)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let standard_bounds = vec![
|
||||
|
|
@ -144,20 +144,20 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
|||
}
|
||||
|
||||
let export_area = vec![
|
||||
TextLabel::new("Bounds").table_align(true).min_width("100px").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
DropdownInput::new(entries).selected_index(Some(index as u32)).widget_holder(),
|
||||
TextLabel::new("Bounds").table_align(true).min_width("100px").widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
DropdownInput::new(entries).selected_index(Some(index as u32)).widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let transparent_background = vec![
|
||||
TextLabel::new("Transparency").table_align(true).min_width("100px").for_checkbox(checkbox_id).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Transparency").table_align(true).min_width("100px").for_checkbox(checkbox_id).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(self.transparent_background)
|
||||
.disabled(self.file_type == FileType::Jpg)
|
||||
.on_update(move |value: &CheckboxInput| ExportDialogMessage::TransparentBackground { transparent: value.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
@ -73,27 +73,27 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler {
|
|||
impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let name = vec![
|
||||
TextLabel::new("Name").table_align(true).min_width("90px").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Name").table_align(true).min_width("90px").widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextInput::new(&self.name)
|
||||
.on_update(|text_input: &TextInput| NewDocumentDialogMessage::Name { name: text_input.value.clone() }.into())
|
||||
.min_width(204) // Matches the 100px of both NumberInputs below + the 4px of the Unrelated-type separator
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let infinite = vec![
|
||||
TextLabel::new("Infinite Canvas").table_align(true).min_width("90px").for_checkbox(checkbox_id).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Infinite Canvas").table_align(true).min_width("90px").for_checkbox(checkbox_id).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(self.infinite)
|
||||
.on_update(|checkbox_input: &CheckboxInput| NewDocumentDialogMessage::Infinite { infinite: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let scale = vec![
|
||||
TextLabel::new("Dimensions").table_align(true).min_width("90px").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Dimensions").table_align(true).min_width("90px").widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(self.dimensions.x as f64))
|
||||
.label("W")
|
||||
.unit(" px")
|
||||
|
|
@ -103,8 +103,8 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
|||
.disabled(self.infinite)
|
||||
.min_width(100)
|
||||
.on_update(|number_input: &NumberInput| NewDocumentDialogMessage::DimensionsX { width: number_input.value.unwrap() }.into())
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(self.dimensions.y as f64))
|
||||
.label("H")
|
||||
.unit(" px")
|
||||
|
|
@ -114,7 +114,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
|||
.disabled(self.infinite)
|
||||
.min_width(100)
|
||||
.on_update(|number_input: &NumberInput| NewDocumentDialogMessage::DimensionsY { height: number_input.value.unwrap() }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
|
|
|
|||
|
|
@ -40,17 +40,17 @@ impl PreferencesDialogMessageHandler {
|
|||
// NAVIGATION
|
||||
// ==========
|
||||
|
||||
let navigation_header = vec![TextLabel::new("Navigation").italic(true).widget_holder()];
|
||||
let navigation_header = vec![TextLabel::new("Navigation").italic(true).widget_instance()];
|
||||
|
||||
let zoom_rate_description = "Adjust how fast zooming occurs when using the scroll wheel or pinch gesture (relative to a default of 50).";
|
||||
let zoom_rate_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Zoom Rate").tooltip_label("Zoom Rate").tooltip_description(zoom_rate_description).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Zoom Rate").tooltip_label("Zoom Rate").tooltip_description(zoom_rate_description).widget_instance(),
|
||||
];
|
||||
let zoom_rate = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(map_zoom_rate_to_display(preferences.viewport_zoom_wheel_rate)))
|
||||
.tooltip_label("Zoom Rate")
|
||||
.tooltip_description(zoom_rate_description)
|
||||
|
|
@ -66,14 +66,14 @@ impl PreferencesDialogMessageHandler {
|
|||
PreferencesMessage::ViewportZoomWheelRate { rate: VIEWPORT_ZOOM_WHEEL_RATE }.into()
|
||||
}
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let zoom_with_scroll_description = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads).";
|
||||
let zoom_with_scroll = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.zoom_with_scroll)
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
|
|
@ -84,25 +84,25 @@ impl PreferencesDialogMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Zoom with Scroll")
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.table_align(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
// =======
|
||||
// EDITING
|
||||
// =======
|
||||
|
||||
let editing_header = vec![TextLabel::new("Editing").italic(true).widget_holder()];
|
||||
let editing_header = vec![TextLabel::new("Editing").italic(true).widget_instance()];
|
||||
|
||||
let selection_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Selection").widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Selection").widget_instance(),
|
||||
];
|
||||
|
||||
let selection_mode = RadioInput::new(vec![
|
||||
|
|
@ -138,10 +138,10 @@ impl PreferencesDialogMessageHandler {
|
|||
}),
|
||||
])
|
||||
.selected_index(Some(preferences.selection_mode as u32))
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let selection_mode = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
selection_mode,
|
||||
];
|
||||
|
||||
|
|
@ -149,16 +149,16 @@ impl PreferencesDialogMessageHandler {
|
|||
// EXPERIMENTAL
|
||||
// ============
|
||||
|
||||
let experimental_header = vec![TextLabel::new("Experimental").italic(true).widget_holder()];
|
||||
let experimental_header = vec![TextLabel::new("Experimental").italic(true).widget_instance()];
|
||||
|
||||
let node_graph_section_description = "Appearance of the wires running between node connections in the graph.";
|
||||
let node_graph_wires_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Node Graph Wires")
|
||||
.tooltip_label("Node Graph Wires")
|
||||
.tooltip_description(node_graph_section_description)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
let graph_wire_style = RadioInput::new(vec![
|
||||
RadioEntryData::new(GraphWireStyle::Direct.to_string())
|
||||
|
|
@ -173,32 +173,32 @@ impl PreferencesDialogMessageHandler {
|
|||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
||||
])
|
||||
.selected_index(Some(preferences.graph_wire_style as u32))
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let graph_wire_style = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
graph_wire_style,
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vello_description = "Use the experimental Vello renderer. (Your browser must support WebGPU).";
|
||||
let use_vello = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vello Renderer")
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.for_checkbox(checkbox_id)
|
||||
.table_align(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
|
|
@ -208,20 +208,20 @@ impl PreferencesDialogMessageHandler {
|
|||
"
|
||||
.trim();
|
||||
let vector_meshes = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.vector_meshes)
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::VectorMeshes { enabled: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vector Meshes")
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.table_align(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
|
|
@ -268,8 +268,8 @@ impl PreferencesDialogMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
TextButton::new("Reset to Defaults").on_update(|_| PreferencesMessage::ResetToDefaults.into()).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Reset to Defaults").on_update(|_| PreferencesMessage::ResetToDefaults.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||
const TITLE: &'static str = "About Graphite";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||
.icon(Some(icon.into()))
|
||||
.flush(true)
|
||||
.on_update(|_| FrontendMessage::TriggerVisitLink { url: url.into() }.into())
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Column { widgets }]))
|
||||
|
|
@ -59,13 +59,13 @@ impl LayoutHolder for AboutGraphiteDialog {
|
|||
fn layout(&self) -> Layout {
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("About this release").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("About this release").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(commit_info_localized(&self.localized_commit_date)).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new(commit_info_localized(&self.localized_commit_date)).multiline(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("Copyright © {} Graphite contributors", self.localized_commit_year)).widget_holder()],
|
||||
widgets: vec![TextLabel::new(format!("Copyright © {} Graphite contributors", self.localized_commit_year)).widget_instance()],
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ impl DialogLayoutHolder for CloseAllDocumentsDialog {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
@ -34,10 +34,10 @@ impl LayoutHolder for CloseAllDocumentsDialog {
|
|||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("Documents with unsaved changes:\n{unsaved_list}")).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new(format!("Documents with unsaved changes:\n{unsaved_list}")).multiline(true).widget_instance()],
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl DialogLayoutHolder for CloseDocumentDialog {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Discard")
|
||||
.on_update(move |_| {
|
||||
DialogMessage::CloseDialogAndThen {
|
||||
|
|
@ -31,8 +31,8 @@ impl DialogLayoutHolder for CloseDocumentDialog {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
@ -53,10 +53,10 @@ impl LayoutHolder for CloseDocumentDialog {
|
|||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Save document before closing it?").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Save document before closing it?").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("\"{name}{ellipsis}\"{break_lines}has unsaved changes")).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new(format!("\"{name}{ellipsis}\"{break_lines}has unsaved changes")).multiline(true).widget_instance()],
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ impl DialogLayoutHolder for ComingSoonDialog {
|
|||
const TITLE: &'static str = "Coming Soon";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -19,13 +19,13 @@ impl DialogLayoutHolder for ComingSoonDialog {
|
|||
|
||||
impl LayoutHolder for ComingSoonDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let header = vec![TextLabel::new("You've stumbled upon a placeholder").bold(true).widget_holder()];
|
||||
let row1 = vec![TextLabel::new("This feature is not implemented yet.").widget_holder()];
|
||||
let header = vec![TextLabel::new("You've stumbled upon a placeholder").bold(true).widget_instance()];
|
||||
let row1 = vec![TextLabel::new("This feature is not implemented yet.").widget_instance()];
|
||||
|
||||
let mut rows = vec![LayoutGroup::Row { widgets: header }, LayoutGroup::Row { widgets: row1 }];
|
||||
|
||||
if let Some(issue) = self.issue {
|
||||
let row2 = vec![TextLabel::new("But you can help build it! Visit its issue:").widget_holder()];
|
||||
let row2 = vec![TextLabel::new("But you can help build it! Visit its issue:").widget_instance()];
|
||||
let row3 = vec![
|
||||
TextButton::new(format!("GitHub Issue #{issue}"))
|
||||
.icon(Some("Website".into()))
|
||||
|
|
@ -36,7 +36,7 @@ impl LayoutHolder for ComingSoonDialog {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
rows.push(LayoutGroup::Row { widgets: row2 });
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl DialogLayoutHolder for DemoArtworkDialog {
|
|||
const TITLE: &'static str = "Demo Artwork";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("Close").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("Close").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -46,12 +46,12 @@ impl LayoutHolder for DemoArtworkDialog {
|
|||
|
||||
let images = chunk
|
||||
.iter()
|
||||
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width(Some("256px".into())).on_update(|_| make_dialog(name, filename)).widget_holder())
|
||||
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width(Some("256px".into())).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.collect();
|
||||
|
||||
let buttons = chunk
|
||||
.iter()
|
||||
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_holder())
|
||||
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.collect();
|
||||
|
||||
vec![LayoutGroup::Row { widgets: images }, LayoutGroup::Row { widgets: buttons }, LayoutGroup::Row { widgets: vec![] }]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ impl DialogLayoutHolder for ErrorDialog {
|
|||
const TITLE: &'static str = "Error";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -22,10 +22,10 @@ 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()],
|
||||
widgets: vec![TextLabel::new(&self.title).bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(&self.description).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new(&self.description).multiline(true).widget_instance()],
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ impl DialogLayoutHolder for LicensesDialog {
|
|||
const TITLE: &'static str = "Licenses";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ impl DialogLayoutHolder for LicensesDialog {
|
|||
];
|
||||
let widgets = button_definitions
|
||||
.iter()
|
||||
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(Some((icon).into())).flush(true).on_update(move |_| message_factory()).widget_holder())
|
||||
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(Some((icon).into())).flush(true).on_update(move |_| message_factory()).widget_instance())
|
||||
.collect();
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Column { widgets }]))
|
||||
|
|
@ -65,10 +65,10 @@ impl LayoutHolder for LicensesDialog {
|
|||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(description).multiline(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new(description).multiline(true).widget_instance()],
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ impl DialogLayoutHolder for LicensesThirdPartyDialog {
|
|||
const TITLE: &'static str = "Third-Party Software License Notices";
|
||||
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_holder()];
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ impl LayoutHolder for LicensesThirdPartyDialog {
|
|||
.monospace(true)
|
||||
.multiline(true)
|
||||
.min_width(format!("{non_wrapping_column_width}ch"))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
}]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl MessageHandler<LayoutMessage, LayoutMessageContext<'_>> for LayoutMessageHa
|
|||
|
||||
impl LayoutMessageHandler {
|
||||
/// Get the widget path for the widget with the specified id
|
||||
fn get_widget_path(widget_layout: &WidgetLayout, widget_id: WidgetId) -> Option<(&WidgetHolder, Vec<usize>)> {
|
||||
fn get_widget_path(widget_layout: &WidgetLayout, widget_id: WidgetId) -> Option<(&WidgetInstance, Vec<usize>)> {
|
||||
let mut stack = widget_layout.layout.iter().enumerate().map(|(index, val)| (vec![index], val)).collect::<Vec<_>>();
|
||||
while let Some((mut widget_path, layout_group)) = stack.pop() {
|
||||
match layout_group {
|
||||
|
|
@ -119,12 +119,12 @@ impl LayoutMessageHandler {
|
|||
let mut layout_iter = match layout {
|
||||
Layout::WidgetLayout(widget_layout) => widget_layout.iter_mut(),
|
||||
};
|
||||
let Some(widget_holder) = layout_iter.find(|widget| widget.widget_id == widget_id) else {
|
||||
let Some(widget_instance) = layout_iter.find(|widget| widget.widget_id == widget_id) else {
|
||||
warn!("handle_widget_callback was called referencing an invalid widget ID, although the layout target was valid. `widget_id: {widget_id}`, `layout_target: {layout_target:?}`",);
|
||||
return;
|
||||
};
|
||||
|
||||
match &mut widget_holder.widget {
|
||||
match &mut widget_instance.widget {
|
||||
Widget::BreadcrumbTrailButtons(breadcrumb_trail_buttons) => {
|
||||
let callback_message = match action {
|
||||
WidgetValueAction::Commit => (breadcrumb_trail_buttons.on_commit.callback)(&()),
|
||||
|
|
|
|||
|
|
@ -169,12 +169,12 @@ impl WidgetLayout {
|
|||
#[derive(Debug, Default)]
|
||||
pub struct WidgetIter<'a> {
|
||||
pub stack: Vec<&'a LayoutGroup>,
|
||||
pub table: Vec<&'a WidgetHolder>,
|
||||
pub current_slice: Option<&'a [WidgetHolder]>,
|
||||
pub table: Vec<&'a WidgetInstance>,
|
||||
pub current_slice: Option<&'a [WidgetInstance]>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for WidgetIter<'a> {
|
||||
type Item = &'a WidgetHolder;
|
||||
type Item = &'a WidgetInstance;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let widget = self.table.pop().or_else(|| {
|
||||
|
|
@ -184,7 +184,7 @@ impl<'a> Iterator for WidgetIter<'a> {
|
|||
});
|
||||
|
||||
if let Some(item) = widget {
|
||||
if let WidgetHolder { widget: Widget::PopoverButton(p), .. } = item {
|
||||
if let WidgetInstance { widget: Widget::PopoverButton(p), .. } = item {
|
||||
self.stack.extend(p.popover_layout.iter());
|
||||
return self.next();
|
||||
}
|
||||
|
|
@ -219,12 +219,12 @@ impl<'a> Iterator for WidgetIter<'a> {
|
|||
#[derive(Debug, Default)]
|
||||
pub struct WidgetIterMut<'a> {
|
||||
pub stack: Vec<&'a mut LayoutGroup>,
|
||||
pub table: Vec<&'a mut WidgetHolder>,
|
||||
pub current_slice: Option<&'a mut [WidgetHolder]>,
|
||||
pub table: Vec<&'a mut WidgetInstance>,
|
||||
pub current_slice: Option<&'a mut [WidgetInstance]>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for WidgetIterMut<'a> {
|
||||
type Item = &'a mut WidgetHolder;
|
||||
type Item = &'a mut WidgetInstance;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let widget = self.table.pop().or_else(|| {
|
||||
|
|
@ -234,7 +234,7 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
|||
});
|
||||
|
||||
if let Some(widget) = widget {
|
||||
if let WidgetHolder { widget: Widget::PopoverButton(p), .. } = widget {
|
||||
if let WidgetInstance { widget: Widget::PopoverButton(p), .. } = widget {
|
||||
self.stack.extend(p.popover_layout.iter_mut());
|
||||
return self.next();
|
||||
}
|
||||
|
|
@ -273,17 +273,17 @@ pub enum LayoutGroup {
|
|||
#[serde(rename = "column")]
|
||||
Column {
|
||||
#[serde(rename = "columnWidgets")]
|
||||
widgets: Vec<WidgetHolder>,
|
||||
widgets: Vec<WidgetInstance>,
|
||||
},
|
||||
#[serde(rename = "row")]
|
||||
Row {
|
||||
#[serde(rename = "rowWidgets")]
|
||||
widgets: Vec<WidgetHolder>,
|
||||
widgets: Vec<WidgetInstance>,
|
||||
},
|
||||
#[serde(rename = "table")]
|
||||
Table {
|
||||
#[serde(rename = "tableWidgets")]
|
||||
rows: Vec<Vec<WidgetHolder>>,
|
||||
rows: Vec<Vec<WidgetInstance>>,
|
||||
unstyled: bool,
|
||||
},
|
||||
#[serde(rename = "section")]
|
||||
|
|
@ -302,8 +302,8 @@ impl Default for LayoutGroup {
|
|||
Self::Row { widgets: Vec::new() }
|
||||
}
|
||||
}
|
||||
impl From<Vec<WidgetHolder>> for LayoutGroup {
|
||||
fn from(widgets: Vec<WidgetHolder>) -> LayoutGroup {
|
||||
impl From<Vec<WidgetInstance>> for LayoutGroup {
|
||||
fn from(widgets: Vec<WidgetInstance>) -> LayoutGroup {
|
||||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
}
|
||||
|
|
@ -480,20 +480,20 @@ impl LayoutGroup {
|
|||
|
||||
// TODO: Rename to WidgetInstance
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WidgetHolder {
|
||||
pub struct WidgetInstance {
|
||||
#[serde(rename = "widgetId")]
|
||||
pub widget_id: WidgetId,
|
||||
pub widget: Widget,
|
||||
}
|
||||
|
||||
impl PartialEq for WidgetHolder {
|
||||
impl PartialEq for WidgetInstance {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.widget == other.widget
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetHolder {
|
||||
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_holder()")]
|
||||
impl WidgetInstance {
|
||||
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_instance()")]
|
||||
pub fn new(widget: Widget) -> Self {
|
||||
Self {
|
||||
widget_id: WidgetId(generate_uuid()),
|
||||
|
|
@ -606,16 +606,16 @@ pub enum DiffUpdate {
|
|||
#[serde(rename = "layoutGroup")]
|
||||
LayoutGroup(LayoutGroup),
|
||||
#[serde(rename = "widget")]
|
||||
Widget(WidgetHolder),
|
||||
Widget(WidgetInstance),
|
||||
}
|
||||
|
||||
impl DiffUpdate {
|
||||
/// Append the keyboard shortcut to the tooltip where applicable
|
||||
pub fn apply_keyboard_shortcut(&mut self, action_input_mapping: &impl Fn(&MessageDiscriminant) -> Option<KeysGroup>) {
|
||||
// Go through each widget to convert `ActionShortcut::Action` to `ActionShortcut::Shortcut` and append the key combination to the widget tooltip
|
||||
let convert_tooltip = |widget_holder: &mut WidgetHolder| {
|
||||
let convert_tooltip = |widget_instance: &mut WidgetInstance| {
|
||||
// Handle all the widgets that have tooltips
|
||||
let tooltip_shortcut = match &mut widget_holder.widget {
|
||||
let tooltip_shortcut = match &mut widget_instance.widget {
|
||||
Widget::BreadcrumbTrailButtons(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::CheckboxInput(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::ColorInput(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
|
|
@ -647,7 +647,7 @@ impl DiffUpdate {
|
|||
}
|
||||
|
||||
// Handle RadioInput separately because its tooltips are children of the widget
|
||||
if let Widget::RadioInput(radio_input) = &mut widget_holder.widget {
|
||||
if let Widget::RadioInput(radio_input) = &mut widget_instance.widget {
|
||||
for radio_entry_data in &mut radio_input.entries {
|
||||
// Convert `ActionShortcut::Action` to `ActionShortcut::Shortcut`
|
||||
if let Some(tooltip_shortcut) = radio_entry_data.tooltip_shortcut.as_mut() {
|
||||
|
|
@ -677,24 +677,24 @@ impl DiffUpdate {
|
|||
};
|
||||
|
||||
// Apply shortcut conversions to all widgets that have menu lists
|
||||
let convert_menu_lists = |widget_holder: &mut WidgetHolder| match &mut widget_holder.widget {
|
||||
let convert_menu_lists = |widget_instance: &mut WidgetInstance| match &mut widget_instance.widget {
|
||||
Widget::DropdownInput(dropdown_input) => apply_action_shortcut_to_menu_lists(&mut dropdown_input.entries),
|
||||
Widget::TextButton(text_button) => apply_action_shortcut_to_menu_lists(&mut text_button.menu_list_children),
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match self {
|
||||
Self::SubLayout(sub_layout) => sub_layout.iter_mut().flat_map(|layout_group| layout_group.iter_mut()).for_each(|widget_holder| {
|
||||
convert_tooltip(widget_holder);
|
||||
convert_menu_lists(widget_holder);
|
||||
Self::SubLayout(sub_layout) => sub_layout.iter_mut().flat_map(|layout_group| layout_group.iter_mut()).for_each(|widget_instance| {
|
||||
convert_tooltip(widget_instance);
|
||||
convert_menu_lists(widget_instance);
|
||||
}),
|
||||
Self::LayoutGroup(layout_group) => layout_group.iter_mut().for_each(|widget_holder| {
|
||||
convert_tooltip(widget_holder);
|
||||
convert_menu_lists(widget_holder);
|
||||
Self::LayoutGroup(layout_group) => layout_group.iter_mut().for_each(|widget_instance| {
|
||||
convert_tooltip(widget_instance);
|
||||
convert_menu_lists(widget_instance);
|
||||
}),
|
||||
Self::Widget(widget_holder) => {
|
||||
convert_tooltip(widget_holder);
|
||||
convert_menu_lists(widget_holder);
|
||||
Self::Widget(widget_instance) => {
|
||||
convert_tooltip(widget_instance);
|
||||
convert_menu_lists(widget_instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ pub type MenuListEntrySections = Vec<Vec<MenuListEntry>>;
|
|||
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
#[widget_builder(not_widget_holder)]
|
||||
#[widget_builder(not_widget_instance)]
|
||||
pub struct MenuListEntry {
|
||||
#[widget_builder(constructor)]
|
||||
pub value: String,
|
||||
|
|
@ -358,7 +358,7 @@ pub struct RadioInput {
|
|||
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
#[widget_builder(not_widget_holder)]
|
||||
#[widget_builder(not_widget_instance)]
|
||||
pub struct RadioEntryData {
|
||||
#[widget_builder(constructor)]
|
||||
pub value: String,
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ impl DataPanelMessageHandler {
|
|||
|
||||
widgets.extend([
|
||||
if is_layer {
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_holder()
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance()
|
||||
} else {
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_holder()
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance()
|
||||
},
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
TextInput::new(network_interface.display_name(&node_id, &[]))
|
||||
.tooltip_description(if is_layer { "Name of the selected layer." } else { "Name of the selected node." })
|
||||
.on_update(move |text_input| {
|
||||
|
|
@ -113,8 +113,8 @@ impl DataPanelMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.max_width(200)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ impl DataPanelMessageHandler {
|
|||
if !layout_data.breadcrumbs.is_empty() {
|
||||
let breadcrumb = BreadcrumbTrailButtons::new(layout_data.breadcrumbs)
|
||||
.on_update(|&len| DataPanelMessage::TruncateElementPath { len: len as usize }.into())
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
widgets.push(breadcrumb);
|
||||
}
|
||||
|
||||
|
|
@ -177,12 +177,12 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
|
|||
])
|
||||
}
|
||||
|
||||
fn column_headings(value: &[&str]) -> Vec<WidgetHolder> {
|
||||
value.iter().map(|text| TextLabel::new(*text).widget_holder()).collect()
|
||||
fn column_headings(value: &[&str]) -> Vec<WidgetInstance> {
|
||||
value.iter().map(|text| TextLabel::new(*text).widget_instance()).collect()
|
||||
}
|
||||
|
||||
fn label(x: impl Into<String>) -> Vec<LayoutGroup> {
|
||||
let error = vec![TextLabel::new(x).widget_holder()];
|
||||
let error = vec![TextLabel::new(x).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets: error }]
|
||||
}
|
||||
|
||||
|
|
@ -193,11 +193,11 @@ trait TableRowLayout {
|
|||
data.breadcrumbs.push(self.identifier());
|
||||
self.element_page(data)
|
||||
}
|
||||
fn element_widget(&self, index: usize) -> WidgetHolder {
|
||||
fn element_widget(&self, index: usize) -> WidgetInstance {
|
||||
TextButton::new(self.identifier())
|
||||
.on_update(move |_| DataPanelMessage::PushToElementPath { index }.into())
|
||||
.narrow(true)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
vec![]
|
||||
|
|
@ -227,7 +227,7 @@ impl<T: TableRowLayout> TableRowLayout for Vec<T> {
|
|||
let mut rows = self
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, row)| vec![TextLabel::new(format!("{index}")).narrow(true).widget_holder(), row.element_widget(index)])
|
||||
.map(|(index, row)| vec![TextLabel::new(format!("{index}")).narrow(true).widget_instance(), row.element_widget(index)])
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
rows.insert(0, column_headings(&["", "element"]));
|
||||
|
|
@ -261,13 +261,13 @@ impl<T: TableRowLayout> TableRowLayout for Table<T> {
|
|||
.enumerate()
|
||||
.map(|(index, row)| {
|
||||
vec![
|
||||
TextLabel::new(format!("{index}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{index}")).narrow(true).widget_instance(),
|
||||
row.element.element_widget(index),
|
||||
TextLabel::new(format_transform_matrix(row.transform)).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", row.alpha_blending)).narrow(true).widget_holder(),
|
||||
TextLabel::new(format_transform_matrix(row.transform)).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{}", row.alpha_blending)).narrow(true).widget_instance(),
|
||||
TextLabel::new(row.source_node_id.map_or_else(|| "-".to_string(), |id| format!("{}", id.0)))
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
|
@ -342,7 +342,7 @@ impl TableRowLayout for Vector {
|
|||
.on_update(move |_| DataPanelMessage::ViewVectorTableTab { tab }.into())
|
||||
})
|
||||
.collect();
|
||||
let table_tabs = vec![RadioInput::new(table_tab_entries).selected_index(Some(data.vector_table_tab as u32)).widget_holder()];
|
||||
let table_tabs = vec![RadioInput::new(table_tab_entries).selected_index(Some(data.vector_table_tab as u32)).widget_instance()];
|
||||
|
||||
let mut table_rows = Vec::new();
|
||||
match data.vector_table_tab {
|
||||
|
|
@ -351,37 +351,37 @@ impl TableRowLayout for Vector {
|
|||
|
||||
match self.style.fill.clone() {
|
||||
Fill::None => table_rows.push(vec![
|
||||
TextLabel::new("Fill").narrow(true).widget_holder(),
|
||||
ColorInput::new(FillChoice::None).disabled(true).menu_direction(Some(MenuDirection::Top)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill").narrow(true).widget_instance(),
|
||||
ColorInput::new(FillChoice::None).disabled(true).menu_direction(Some(MenuDirection::Top)).narrow(true).widget_instance(),
|
||||
]),
|
||||
Fill::Solid(color) => table_rows.push(vec![
|
||||
TextLabel::new("Fill").narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill").narrow(true).widget_instance(),
|
||||
ColorInput::new(FillChoice::Solid(color))
|
||||
.disabled(true)
|
||||
.menu_direction(Some(MenuDirection::Top))
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Fill::Gradient(gradient) => {
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Fill").narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill").narrow(true).widget_instance(),
|
||||
ColorInput::new(FillChoice::Gradient(gradient.stops))
|
||||
.disabled(true)
|
||||
.menu_direction(Some(MenuDirection::Top))
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Fill Gradient Type").narrow(true).widget_holder(),
|
||||
TextLabel::new(gradient.gradient_type.to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill Gradient Type").narrow(true).widget_instance(),
|
||||
TextLabel::new(gradient.gradient_type.to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Fill Gradient Start").narrow(true).widget_holder(),
|
||||
TextLabel::new(format_dvec2(gradient.start)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill Gradient Start").narrow(true).widget_instance(),
|
||||
TextLabel::new(format_dvec2(gradient.start)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Fill Gradient End").narrow(true).widget_holder(),
|
||||
TextLabel::new(format_dvec2(gradient.end)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Fill Gradient End").narrow(true).widget_instance(),
|
||||
TextLabel::new(format_dvec2(gradient.end)).narrow(true).widget_instance(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -389,81 +389,81 @@ impl TableRowLayout for Vector {
|
|||
if let Some(stroke) = self.style.stroke.clone() {
|
||||
let color = if let Some(color) = stroke.color { FillChoice::Solid(color) } else { FillChoice::None };
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke").narrow(true).widget_holder(),
|
||||
ColorInput::new(color).disabled(true).menu_direction(Some(MenuDirection::Top)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke").narrow(true).widget_instance(),
|
||||
ColorInput::new(color).disabled(true).menu_direction(Some(MenuDirection::Top)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Weight").narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{} px", stroke.weight)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Weight").narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{} px", stroke.weight)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Dash Lengths").narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Dash Lengths").narrow(true).widget_instance(),
|
||||
TextLabel::new(if stroke.dash_lengths.is_empty() {
|
||||
"-".to_string()
|
||||
} else {
|
||||
format!("[{}]", stroke.dash_lengths.iter().map(|x| format!("{x} px")).collect::<Vec<_>>().join(", "))
|
||||
})
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Dash Offset").narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", stroke.dash_offset)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Dash Offset").narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{}", stroke.dash_offset)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Cap").narrow(true).widget_holder(),
|
||||
TextLabel::new(stroke.cap.to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Cap").narrow(true).widget_instance(),
|
||||
TextLabel::new(stroke.cap.to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Join").narrow(true).widget_holder(),
|
||||
TextLabel::new(stroke.join.to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Join").narrow(true).widget_instance(),
|
||||
TextLabel::new(stroke.join.to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Join Miter Limit").narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", stroke.join_miter_limit)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Join Miter Limit").narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{}", stroke.join_miter_limit)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Align").narrow(true).widget_holder(),
|
||||
TextLabel::new(stroke.align.to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Align").narrow(true).widget_instance(),
|
||||
TextLabel::new(stroke.align.to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Transform").narrow(true).widget_holder(),
|
||||
TextLabel::new(format_transform_matrix(&stroke.transform)).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Transform").narrow(true).widget_instance(),
|
||||
TextLabel::new(format_transform_matrix(&stroke.transform)).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Non-Scaling").narrow(true).widget_holder(),
|
||||
TextLabel::new((if stroke.non_scaling { "Yes" } else { "No" }).to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Non-Scaling").narrow(true).widget_instance(),
|
||||
TextLabel::new((if stroke.non_scaling { "Yes" } else { "No" }).to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Stroke Paint Order").narrow(true).widget_holder(),
|
||||
TextLabel::new(stroke.paint_order.to_string()).narrow(true).widget_holder(),
|
||||
TextLabel::new("Stroke Paint Order").narrow(true).widget_instance(),
|
||||
TextLabel::new(stroke.paint_order.to_string()).narrow(true).widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
let colinear = self.colinear_manipulators.iter().map(|[a, b]| format!("[{a} / {b}]")).collect::<Vec<_>>().join(", ");
|
||||
let colinear = if colinear.is_empty() { "-".to_string() } else { colinear };
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Colinear Handle IDs").narrow(true).widget_holder(),
|
||||
TextLabel::new(colinear).narrow(true).widget_holder(),
|
||||
TextLabel::new("Colinear Handle IDs").narrow(true).widget_instance(),
|
||||
TextLabel::new(colinear).narrow(true).widget_instance(),
|
||||
]);
|
||||
|
||||
table_rows.push(vec![
|
||||
TextLabel::new("Upstream Nested Layers").narrow(true).widget_holder(),
|
||||
TextLabel::new("Upstream Nested Layers").narrow(true).widget_instance(),
|
||||
TextLabel::new(if self.upstream_data.is_some() {
|
||||
"Yes (this preserves references to its upstream nested layers for editing by tools)"
|
||||
} else {
|
||||
"No (this doesn't preserve references to its upstream nested layers for editing by tools)"
|
||||
})
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
VectorTableTab::Points => {
|
||||
table_rows.push(column_headings(&["", "position"]));
|
||||
table_rows.extend(self.point_domain.iter().map(|(id, position)| {
|
||||
vec![
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{position}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{position}")).narrow(true).widget_instance(),
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
|
@ -471,10 +471,10 @@ impl TableRowLayout for Vector {
|
|||
table_rows.push(column_headings(&["", "start_index", "end_index", "handles"]));
|
||||
table_rows.extend(self.segment_domain.iter().map(|(id, start, end, handles)| {
|
||||
vec![
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{start}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{end}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{handles:?}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{start}")).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{end}")).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{handles:?}")).narrow(true).widget_instance(),
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
|
@ -482,9 +482,9 @@ impl TableRowLayout for Vector {
|
|||
table_rows.push(column_headings(&["", "segment_range", "fill"]));
|
||||
table_rows.extend(self.region_domain.iter().map(|(id, segment_range, fill)| {
|
||||
vec![
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{segment_range:?}")).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", fill.inner())).narrow(true).widget_holder(),
|
||||
TextLabel::new(format!("{}", id.inner())).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{segment_range:?}")).narrow(true).widget_instance(),
|
||||
TextLabel::new(format!("{}", fill.inner())).narrow(true).widget_instance(),
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
|
@ -505,7 +505,7 @@ impl TableRowLayout for Raster<CPU> {
|
|||
let raster = self.data();
|
||||
|
||||
if raster.width == 0 || raster.height == 0 {
|
||||
let widgets = vec![TextLabel::new("Image has no area").widget_holder()];
|
||||
let widgets = vec![TextLabel::new("Image has no area").widget_instance()];
|
||||
return vec![LayoutGroup::Row { widgets }];
|
||||
}
|
||||
|
||||
|
|
@ -520,7 +520,7 @@ impl TableRowLayout for Raster<CPU> {
|
|||
base64_string
|
||||
});
|
||||
|
||||
let widgets = vec![ImageLabel::new(base64_string).widget_holder()];
|
||||
let widgets = vec![ImageLabel::new(base64_string).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -533,7 +533,7 @@ impl TableRowLayout for Raster<GPU> {
|
|||
format!("Raster ({}x{})", self.data().width(), self.data().height())
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new("Raster is a texture on the GPU and cannot currently be displayed here").widget_holder()];
|
||||
let widgets = vec![TextLabel::new("Raster is a texture on the GPU and cannot currently be displayed here").widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -545,12 +545,12 @@ impl TableRowLayout for Color {
|
|||
fn identifier(&self) -> String {
|
||||
format!("Color (#{})", self.to_gamma_srgb().to_rgba_hex_srgb())
|
||||
}
|
||||
fn element_widget(&self, _index: usize) -> WidgetHolder {
|
||||
fn element_widget(&self, _index: usize) -> WidgetInstance {
|
||||
ColorInput::new(FillChoice::Solid(*self))
|
||||
.disabled(true)
|
||||
.menu_direction(Some(MenuDirection::Top))
|
||||
.narrow(true)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![self.element_widget(0)];
|
||||
|
|
@ -565,12 +565,12 @@ impl TableRowLayout for GradientStops {
|
|||
fn identifier(&self) -> String {
|
||||
format!("Gradient ({} stops)", self.0.len())
|
||||
}
|
||||
fn element_widget(&self, _index: usize) -> WidgetHolder {
|
||||
fn element_widget(&self, _index: usize) -> WidgetInstance {
|
||||
ColorInput::new(FillChoice::Gradient(self.clone()))
|
||||
.menu_direction(Some(MenuDirection::Top))
|
||||
.disabled(true)
|
||||
.narrow(true)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![self.element_widget(0)];
|
||||
|
|
@ -586,7 +586,7 @@ impl TableRowLayout for f64 {
|
|||
"Number (f64)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -599,7 +599,7 @@ impl TableRowLayout for u32 {
|
|||
"Number (u32)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -612,7 +612,7 @@ impl TableRowLayout for u64 {
|
|||
"Number (u64)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -625,7 +625,7 @@ impl TableRowLayout for bool {
|
|||
"Bool".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -644,7 +644,7 @@ impl TableRowLayout for String {
|
|||
}
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_holder()];
|
||||
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -657,7 +657,7 @@ impl TableRowLayout for Option<f64> {
|
|||
"Option<f64>".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("{self:?}")).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(format!("{self:?}")).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -670,7 +670,7 @@ impl TableRowLayout for DVec2 {
|
|||
"Vec2".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -683,7 +683,7 @@ impl TableRowLayout for Vec2 {
|
|||
"Vec2".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -696,7 +696,7 @@ impl TableRowLayout for DAffine2 {
|
|||
"Transform".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(self)).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(self)).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
@ -710,7 +710,7 @@ impl TableRowLayout for Affine2 {
|
|||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let matrix = DAffine2::from_cols_array(&self.to_cols_array().map(|x| x as f64));
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(&matrix)).widget_holder()];
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(&matrix)).widget_instance()];
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2194,8 +2194,8 @@ impl DocumentMessageHandler {
|
|||
// .selected_index(Some(self.document_mode as u32))
|
||||
// .draw_icon(true)
|
||||
// .interactive(false) // TODO: set to true when dialogs are not spawned
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Section).widget_holder(),
|
||||
// .widget_instance(),
|
||||
// Separator::new(SeparatorType::Section).widget_instance(),
|
||||
],
|
||||
}]);
|
||||
|
||||
|
|
@ -2215,13 +2215,13 @@ impl DocumentMessageHandler {
|
|||
.tooltip_shortcut(action_shortcut!(AnimationMessageDiscriminant::RestartAnimation))
|
||||
.on_update(|_| AnimationMessage::RestartAnimation.into())
|
||||
.disabled(time == Duration::ZERO)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new(if animation_is_playing { "PlaybackPause" } else { "PlaybackPlay" }, 24)
|
||||
.tooltip_label(if animation_is_playing { "Pause Animation" } else { "Play Animation" })
|
||||
.tooltip_shortcut(action_shortcut!(AnimationMessageDiscriminant::ToggleLivePreview))
|
||||
.on_update(|_| AnimationMessage::ToggleLivePreview.into())
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(self.overlays_visibility_settings.all)
|
||||
.icon("Overlays")
|
||||
.tooltip_label("Overlays")
|
||||
|
|
@ -2233,14 +2233,14 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
PopoverButton::new()
|
||||
.popover_layout(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Overlays").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Overlays").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("General").widget_holder()],
|
||||
widgets: vec![TextLabel::new("General").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
|
|
@ -2255,8 +2255,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2273,13 +2273,13 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Select Tool").widget_holder()],
|
||||
widgets: vec![TextLabel::new("Select Tool").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
|
|
@ -2294,8 +2294,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2312,8 +2312,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2330,8 +2330,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Transform Dial".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Dial".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2348,8 +2348,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2366,8 +2366,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Transform Origin".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2384,8 +2384,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2402,13 +2402,13 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Pen & Path Tools").widget_holder()],
|
||||
widgets: vec![TextLabel::new("Pen & Path Tools").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
|
|
@ -2423,8 +2423,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2441,8 +2441,8 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new("Anchors".to_string()).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Anchors".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
|
|
@ -2460,17 +2460,17 @@ impl DocumentMessageHandler {
|
|||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new("Handles".to_string())
|
||||
.disabled(!self.overlays_visibility_settings.anchors)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
])
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
CheckboxInput::new(snapping_state.snapping_enabled)
|
||||
.icon("Snapping")
|
||||
.tooltip_label("Snapping")
|
||||
|
|
@ -2482,15 +2482,15 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
PopoverButton::new()
|
||||
.popover_layout(
|
||||
[
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Snapping").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Snapping").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(SnappingOptions::BoundingBoxes.to_string()).widget_holder()],
|
||||
widgets: vec![TextLabel::new(SnappingOptions::BoundingBoxes.to_string()).widget_instance()],
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
|
|
@ -2509,13 +2509,13 @@ impl DocumentMessageHandler {
|
|||
.tooltip_label(name)
|
||||
.tooltip_description(description)
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
}))
|
||||
.chain([LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_holder()],
|
||||
widgets: vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_instance()],
|
||||
}])
|
||||
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, description)| LayoutGroup::Row {
|
||||
widgets: {
|
||||
|
|
@ -2532,26 +2532,26 @@ impl DocumentMessageHandler {
|
|||
.tooltip_label(name)
|
||||
.tooltip_description(description)
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_holder(),
|
||||
.widget_instance(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
}))
|
||||
.collect(),
|
||||
)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
CheckboxInput::new(self.snapping_state.grid_snapping)
|
||||
.icon("Grid")
|
||||
.tooltip_label("Grid")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleGridVisibility))
|
||||
.on_update(|optional_input: &CheckboxInput| DocumentMessage::GridVisibility { visible: optional_input.checked }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
PopoverButton::new()
|
||||
.popover_layout(overlay_options(&self.snapping_state.grid))
|
||||
.popover_min_width(Some(320))
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
RadioInput::new(vec![
|
||||
RadioEntryData::new("Normal")
|
||||
.icon("RenderModeNormal")
|
||||
|
|
@ -2572,18 +2572,18 @@ impl DocumentMessageHandler {
|
|||
])
|
||||
.selected_index(Some(self.render_mode as u32))
|
||||
.narrow(true)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
// PopoverButton::new()
|
||||
// .popover_layout(vec![
|
||||
// LayoutGroup::Row {
|
||||
// widgets: vec![TextLabel::new("Render Mode").bold(true).widget_holder()],
|
||||
// widgets: vec![TextLabel::new("Render Mode").bold(true).widget_instance()],
|
||||
// },
|
||||
// LayoutGroup::Row {
|
||||
// widgets: vec![TextLabel::new("Coming soon").widget_holder()],
|
||||
// widgets: vec![TextLabel::new("Coming soon").widget_instance()],
|
||||
// },
|
||||
// ])
|
||||
// .widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// .widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
];
|
||||
|
||||
widgets.extend(navigation_controls(&self.document_ptz, &self.navigation_handler, false));
|
||||
|
|
@ -2591,7 +2591,7 @@ impl DocumentMessageHandler {
|
|||
let tilt_value = self.navigation_handler.snapped_tilt(self.document_ptz.tilt()) / (std::f64::consts::PI / 180.);
|
||||
if tilt_value.abs() > 0.00001 {
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(tilt_value))
|
||||
.unit("°")
|
||||
.increment_behavior(NumberInputIncrementBehavior::Callback)
|
||||
|
|
@ -2616,19 +2616,19 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextButton::new("Node Graph")
|
||||
.icon(Some((if self.graph_view_overlay_open { "GraphViewOpen" } else { "GraphViewClosed" }).into()))
|
||||
.hover_icon(Some((if self.graph_view_overlay_open { "GraphViewClosed" } else { "GraphViewOpen" }).into()))
|
||||
.tooltip_label(if self.graph_view_overlay_open { "Hide Node Graph" } else { "Show Node Graph" })
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
let document_bar_layout = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]);
|
||||
|
|
@ -2726,8 +2726,8 @@ impl DocumentMessageHandler {
|
|||
.draw_icon(false)
|
||||
.max_width(100)
|
||||
.tooltip_label("Blend Mode")
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(opacity)
|
||||
.label("Opacity")
|
||||
.unit("%")
|
||||
|
|
@ -2748,8 +2748,8 @@ impl DocumentMessageHandler {
|
|||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||
.max_width(100)
|
||||
.tooltip_label("Opacity")
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(fill)
|
||||
.label("Fill")
|
||||
.unit("%")
|
||||
|
|
@ -2770,7 +2770,7 @@ impl DocumentMessageHandler {
|
|||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||
.max_width(100)
|
||||
.tooltip_label("Fill")
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
let layers_panel_control_bar_left = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]);
|
||||
|
||||
|
|
@ -2781,14 +2781,14 @@ impl DocumentMessageHandler {
|
|||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedLocked))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedVisibility))
|
||||
.on_update(|_| DocumentMessage::ToggleSelectedVisibility.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
let layers_panel_control_bar_right = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]);
|
||||
|
||||
|
|
@ -2843,11 +2843,11 @@ impl DocumentMessageHandler {
|
|||
Message::NoOp
|
||||
}
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
vec![LayoutGroup::Row { widgets: vec![node_chooser] }]
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
IconButton::new("Folder", 24)
|
||||
.tooltip_label("Group Selected")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GroupSelectedLayers))
|
||||
|
|
@ -2856,18 +2856,18 @@ impl DocumentMessageHandler {
|
|||
DocumentMessage::GroupSelectedLayers { group_folder_type }.into()
|
||||
})
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("NewLayer", 24)
|
||||
.tooltip_label("New Layer")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::CreateEmptyFolder))
|
||||
.on_update(|_| DocumentMessage::CreateEmptyFolder.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("Trash", 24)
|
||||
.tooltip_label("Delete Selected")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::DeleteSelectedLayers))
|
||||
.on_update(|_| DocumentMessage::DeleteSelectedLayers.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
let layers_panel_bottom_bar = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]);
|
||||
|
||||
|
|
@ -3144,24 +3144,24 @@ impl<'a> ClickXRayIter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHandler, node_graph: bool) -> Vec<WidgetHolder> {
|
||||
pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHandler, node_graph: bool) -> Vec<WidgetInstance> {
|
||||
let mut list = vec![
|
||||
IconButton::new("ZoomIn", 24)
|
||||
.tooltip_label("Zoom In")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomIncrease))
|
||||
.on_update(|_| NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("ZoomOut", 24)
|
||||
.tooltip_label("Zoom Out")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomDecrease))
|
||||
.on_update(|_| NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("ZoomReset", 24)
|
||||
.tooltip_label("Reset Tilt and Zoom to 100%")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasTiltResetAndZoomTo100Percent))
|
||||
.on_update(|_| NavigationMessage::CanvasTiltResetAndZoomTo100Percent.into())
|
||||
.disabled(ptz.tilt().abs() < 1e-4 && (ptz.zoom() - 1.).abs() < 1e-4)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
if ptz.flip && !node_graph {
|
||||
list.push(
|
||||
|
|
@ -3170,11 +3170,11 @@ pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHand
|
|||
.tooltip_description("Flip the canvas back to its standard orientation.")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasFlip))
|
||||
.on_update(|_| NavigationMessage::CanvasFlip.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
}
|
||||
list.extend([
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(navigation_handler.snapped_zoom(ptz.zoom()) * 100.))
|
||||
.unit("%")
|
||||
.min(0.000001)
|
||||
|
|
@ -3189,7 +3189,7 @@ pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHand
|
|||
.increment_behavior(NumberInputIncrementBehavior::Callback)
|
||||
.increment_callback_decrease(|_| NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }.into())
|
||||
.increment_callback_increase(|_| NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
list
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2536,7 +2536,7 @@ fn static_input_properties() -> InputProperties {
|
|||
};
|
||||
if let Some(&TaggedValue::F64(val)) = input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(val))
|
||||
.unit("°")
|
||||
.mode(NumberInputMode::Range)
|
||||
|
|
@ -2548,7 +2548,7 @@ fn static_input_properties() -> InputProperties {
|
|||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -2567,7 +2567,7 @@ fn static_input_properties() -> InputProperties {
|
|||
};
|
||||
if let Some(&TaggedValue::DVec2(val)) = input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(val.x))
|
||||
.label("X")
|
||||
.unit("°")
|
||||
|
|
@ -2579,8 +2579,8 @@ fn static_input_properties() -> InputProperties {
|
|||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(val.y))
|
||||
.label("Y")
|
||||
.unit("°")
|
||||
|
|
@ -2592,7 +2592,7 @@ fn static_input_properties() -> InputProperties {
|
|||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2144,12 +2144,12 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
}
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
vec![LayoutGroup::Row { widgets: vec![node_chooser] }]
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
//
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
//
|
||||
IconButton::new("Folder", 24)
|
||||
.tooltip_label("Group Selected")
|
||||
|
|
@ -2159,20 +2159,20 @@ impl NodeGraphMessageHandler {
|
|||
DocumentMessage::GroupSelectedLayers { group_folder_type }.into()
|
||||
})
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("NewLayer", 24)
|
||||
.tooltip_label("New Layer")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::CreateEmptyFolder))
|
||||
.on_update(|_| DocumentMessage::CreateEmptyFolder.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("Trash", 24)
|
||||
.tooltip_label("Delete Selected")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::DeleteSelectedLayers))
|
||||
.on_update(|_| DocumentMessage::DeleteSelectedLayers.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
//
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
//
|
||||
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||
.hover_icon(Some((if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" }).into()))
|
||||
|
|
@ -2180,14 +2180,14 @@ impl NodeGraphMessageHandler {
|
|||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedLocked))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||
.disabled(!has_selection || !selection_includes_layers)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedVisibility))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedVisibility.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let mut selection = selected_nodes.selected_nodes();
|
||||
|
|
@ -2212,8 +2212,8 @@ impl NodeGraphMessageHandler {
|
|||
.icon(Some("FrameAll".to_string()))
|
||||
.tooltip_description("Restore preview to the graph output.")
|
||||
.on_update(move |_| NodeGraphMessage::TogglePreview { node_id }.into())
|
||||
.widget_holder();
|
||||
widgets.extend([Separator::new(SeparatorType::Unrelated).widget_holder(), button]);
|
||||
.widget_instance();
|
||||
widgets.extend([Separator::new(SeparatorType::Unrelated).widget_instance(), button]);
|
||||
} else if let Some(&node_id) = selection {
|
||||
let selection_is_not_already_the_output = !network
|
||||
.exports
|
||||
|
|
@ -2226,15 +2226,15 @@ impl NodeGraphMessageHandler {
|
|||
.tooltip_description("Temporarily set the graph output to the selected node or layer. Perform the shortcut on a node or layer for quick access.")
|
||||
.tooltip_shortcut(action_shortcut_manual!(Key::Alt, Key::MouseLeft))
|
||||
.on_update(move |_| NodeGraphMessage::TogglePreview { node_id }.into())
|
||||
.widget_holder();
|
||||
widgets.extend([Separator::new(SeparatorType::Unrelated).widget_holder(), button]);
|
||||
.widget_instance();
|
||||
widgets.extend([Separator::new(SeparatorType::Unrelated).widget_instance(), button]);
|
||||
}
|
||||
}
|
||||
|
||||
let subgraph_path_names_length = subgraph_path_names.len();
|
||||
if subgraph_path_names_length >= 2 {
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
BreadcrumbTrailButtons::new(subgraph_path_names)
|
||||
.on_update(move |index| {
|
||||
DocumentMessage::ExitNestedNetwork {
|
||||
|
|
@ -2242,7 +2242,7 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -2273,19 +2273,19 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
];
|
||||
widgets.extend(navigation_controls(node_graph_ptz, navigation_handler, true));
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextButton::new("Node Graph")
|
||||
.icon(Some("GraphViewOpen".into()))
|
||||
.hover_icon(Some("GraphViewClosed".into()))
|
||||
.tooltip_label("Hide Node Graph")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
self.widgets[1] = LayoutGroup::Row { widgets };
|
||||
|
|
@ -2332,9 +2332,9 @@ impl NodeGraphMessageHandler {
|
|||
if let [node_id] = *nodes.as_slice() {
|
||||
properties.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&node_id, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected node.")
|
||||
.on_update(move |text_input| {
|
||||
|
|
@ -2345,8 +2345,8 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
@ -2360,14 +2360,14 @@ impl NodeGraphMessageHandler {
|
|||
// This may require store a separate path for the properties panel
|
||||
let mut properties = vec![LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
IconLabel::new("File").tooltip_description("Name of the current document.").widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
IconLabel::new("File").tooltip_description("Name of the current document.").widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
TextInput::new(context.document_name)
|
||||
.tooltip_description("Name of the current document.")
|
||||
.on_update(|text_input| DocumentMessage::RenameDocument { new_name: text_input.value.clone() }.into())
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
],
|
||||
}];
|
||||
|
||||
|
|
@ -2407,9 +2407,9 @@ impl NodeGraphMessageHandler {
|
|||
|
||||
let mut layer_properties = vec![LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&layer, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected layer.")
|
||||
.on_update(move |text_input| {
|
||||
|
|
@ -2420,8 +2420,8 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
PopoverButton::new()
|
||||
.icon(Some("Node".to_string()))
|
||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||
|
|
@ -2442,11 +2442,11 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
vec![LayoutGroup::Row { widgets: vec![node_chooser] }]
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
],
|
||||
}];
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use graphene_std::vector::misc::{ArcType, CentroidType, ExtrudeJoiningAlgorithm,
|
|||
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops, GradientType, PaintOrder, StrokeAlign, StrokeCap, StrokeJoin};
|
||||
|
||||
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
||||
let widget = TextLabel::new(text).widget_holder();
|
||||
let widget = TextLabel::new(text).widget_instance();
|
||||
vec![LayoutGroup::Row { widgets: vec![widget] }]
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ pub fn commit_value<T>(_: &T) -> Message {
|
|||
DocumentMessage::AddTransaction.into()
|
||||
}
|
||||
|
||||
pub fn expose_widget(node_id: NodeId, index: usize, data_type: FrontendGraphDataType, exposed: bool) -> WidgetHolder {
|
||||
pub fn expose_widget(node_id: NodeId, index: usize, data_type: FrontendGraphDataType, exposed: bool) -> WidgetInstance {
|
||||
ParameterExposeButton::new()
|
||||
.exposed(exposed)
|
||||
.data_type(data_type)
|
||||
|
|
@ -63,20 +63,20 @@ pub fn expose_widget(node_id: NodeId, index: usize, data_type: FrontendGraphData
|
|||
}
|
||||
.into()]),
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
// TODO: Remove this when we have proper entry row formatting that includes room for Assists.
|
||||
pub fn add_blank_assist(widgets: &mut Vec<WidgetHolder>) {
|
||||
pub fn add_blank_assist(widgets: &mut Vec<WidgetInstance>) {
|
||||
widgets.extend_from_slice(&[
|
||||
// Custom CSS specific to the Properties panel converts this Section separator into the width of an assist (24px).
|
||||
Separator::new(SeparatorType::Section).widget_holder(),
|
||||
Separator::new(SeparatorType::Section).widget_instance(),
|
||||
// This last one is the separator after the 24px assist.
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
]);
|
||||
}
|
||||
|
||||
pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetHolder> {
|
||||
pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo {
|
||||
document_node,
|
||||
node_id,
|
||||
|
|
@ -101,7 +101,7 @@ pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<Widget
|
|||
if exposable {
|
||||
widgets.push(expose_widget(node_id, index, input_type, input.is_exposed()));
|
||||
}
|
||||
widgets.push(TextLabel::new(name).tooltip_description(description).widget_holder());
|
||||
widgets.push(TextLabel::new(name).tooltip_description(description).widget_instance());
|
||||
if blank_assist {
|
||||
add_blank_assist(&mut widgets);
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ pub(crate) fn property_from_type(
|
|||
_ => {
|
||||
let mut widgets = start_widgets(default_info);
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("-")
|
||||
.tooltip_label(format!(
|
||||
"Data Type: {}",
|
||||
|
|
@ -241,7 +241,7 @@ pub(crate) fn property_from_type(
|
|||
.unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref())),
|
||||
))
|
||||
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
return Err(vec![widgets.into()]);
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ pub(crate) fn property_from_type(
|
|||
}
|
||||
}
|
||||
}
|
||||
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_holder()].into(),
|
||||
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_instance()].into(),
|
||||
Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
|
||||
Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
|
||||
};
|
||||
|
|
@ -259,7 +259,7 @@ pub(crate) fn property_from_type(
|
|||
Ok(extra_widgets)
|
||||
}
|
||||
|
||||
pub fn text_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetHolder> {
|
||||
pub fn text_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -271,17 +271,17 @@ pub fn text_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetHo
|
|||
};
|
||||
if let Some(TaggedValue::String(x)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextInput::new(x.clone())
|
||||
.on_update(update_value(|x: &TextInput| TaggedValue::String(x.value.clone()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn text_area_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetHolder> {
|
||||
pub fn text_area_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -293,17 +293,17 @@ pub fn text_area_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<Wid
|
|||
};
|
||||
if let Some(TaggedValue::String(x)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextAreaInput::new(x.clone())
|
||||
.on_update(update_value(|x: &TextAreaInput| TaggedValue::String(x.value.clone()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn bool_widget(parameter_widgets_info: ParameterWidgetsInfo, checkbox_input: CheckboxInput) -> Vec<WidgetHolder> {
|
||||
pub fn bool_widget(parameter_widgets_info: ParameterWidgetsInfo, checkbox_input: CheckboxInput) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -315,18 +315,18 @@ pub fn bool_widget(parameter_widgets_info: ParameterWidgetsInfo, checkbox_input:
|
|||
};
|
||||
if let Some(&TaggedValue::Bool(x)) = input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
checkbox_input
|
||||
.checked(x)
|
||||
.on_update(update_value(|x: &CheckboxInput| TaggedValue::Bool(x.checked), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn reference_point_widget(parameter_widgets_info: ParameterWidgetsInfo, disabled: bool) -> Vec<WidgetHolder> {
|
||||
pub fn reference_point_widget(parameter_widgets_info: ParameterWidgetsInfo, disabled: bool) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -338,7 +338,7 @@ pub fn reference_point_widget(parameter_widgets_info: ParameterWidgetsInfo, disa
|
|||
};
|
||||
if let Some(&TaggedValue::ReferencePoint(reference_point)) = input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(reference_point != ReferencePoint::None)
|
||||
.on_update(update_value(
|
||||
move |x: &CheckboxInput| TaggedValue::ReferencePoint(if x.checked { ReferencePoint::Center } else { ReferencePoint::None }),
|
||||
|
|
@ -346,12 +346,12 @@ pub fn reference_point_widget(parameter_widgets_info: ParameterWidgetsInfo, disa
|
|||
index,
|
||||
))
|
||||
.disabled(disabled)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
ReferencePointInput::new(reference_point)
|
||||
.on_update(update_value(move |x: &ReferencePointInput| TaggedValue::ReferencePoint(x.value), node_id, index))
|
||||
.disabled(disabled)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
|
|
@ -361,15 +361,15 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut location_widgets = start_widgets(parameter_widgets_info);
|
||||
location_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
location_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let mut scale_widgets = vec![TextLabel::new("").widget_holder()];
|
||||
let mut scale_widgets = vec![TextLabel::new("").widget_instance()];
|
||||
add_blank_assist(&mut scale_widgets);
|
||||
scale_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
scale_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let mut resolution_widgets = vec![TextLabel::new("").widget_holder()];
|
||||
let mut resolution_widgets = vec![TextLabel::new("").widget_instance()];
|
||||
add_blank_assist(&mut resolution_widgets);
|
||||
resolution_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
resolution_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
|
|
@ -405,8 +405,8 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(top_left.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
|
|
@ -429,7 +429,7 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
scale_widgets.extend_from_slice(&[
|
||||
|
|
@ -452,8 +452,8 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(bounds.y))
|
||||
.label("H")
|
||||
.unit(" px")
|
||||
|
|
@ -473,7 +473,7 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
resolution_widgets.push(
|
||||
|
|
@ -495,7 +495,7 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -513,15 +513,15 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut location_widgets = start_widgets(parameter_widgets_info);
|
||||
location_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
location_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let mut rotation_widgets = vec![TextLabel::new("").widget_holder()];
|
||||
let mut rotation_widgets = vec![TextLabel::new("").widget_instance()];
|
||||
add_blank_assist(&mut rotation_widgets);
|
||||
rotation_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
rotation_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let mut scale_widgets = vec![TextLabel::new("").widget_holder()];
|
||||
let mut scale_widgets = vec![TextLabel::new("").widget_instance()];
|
||||
add_blank_assist(&mut scale_widgets);
|
||||
scale_widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
scale_widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
|
|
@ -548,8 +548,8 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(translation.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
|
|
@ -563,7 +563,7 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
rotation_widgets.extend_from_slice(&[NumberInput::new(Some(rotation.to_degrees()))
|
||||
|
|
@ -580,7 +580,7 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder()]);
|
||||
.widget_instance()]);
|
||||
|
||||
scale_widgets.extend_from_slice(&[
|
||||
NumberInput::new(Some(scale.x))
|
||||
|
|
@ -595,8 +595,8 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(scale.y))
|
||||
.label("H")
|
||||
.unit("x")
|
||||
|
|
@ -609,7 +609,7 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
vec![
|
||||
|
|
@ -642,7 +642,7 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
match input.as_non_exposed_value() {
|
||||
Some(&TaggedValue::DVec2(dvec2)) => {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(dvec2.x))
|
||||
.label(x)
|
||||
.unit(unit)
|
||||
|
|
@ -651,8 +651,8 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
.is_integer(is_integer)
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(input.value.unwrap(), dvec2.y)), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(dvec2.y))
|
||||
.label(y)
|
||||
.unit(unit)
|
||||
|
|
@ -661,12 +661,12 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
.is_integer(is_integer)
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(dvec2.x, input.value.unwrap())), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
Some(&TaggedValue::F64(value)) => {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(value))
|
||||
.label(x)
|
||||
.unit(unit)
|
||||
|
|
@ -675,8 +675,8 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
.is_integer(is_integer)
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(input.value.unwrap(), value)), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(value))
|
||||
.label(y)
|
||||
.unit(unit)
|
||||
|
|
@ -685,7 +685,7 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
.is_integer(is_integer)
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(value, input.value.unwrap())), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -694,7 +694,7 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
|||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
|
||||
pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text_input: TextInput) -> Vec<WidgetHolder> {
|
||||
pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text_input: TextInput) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -716,17 +716,17 @@ pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text
|
|||
};
|
||||
if let Some(TaggedValue::VecF64(x)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
text_input
|
||||
.value(x.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(", "))
|
||||
.on_update(optionally_update_value(move |x: &TextInput| from_string(&x.value), node_id, index))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn array_of_vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, text_props: TextInput) -> Vec<WidgetHolder> {
|
||||
pub fn array_of_vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, text_props: TextInput) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -748,17 +748,17 @@ pub fn array_of_vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, text_p
|
|||
};
|
||||
if let Some(TaggedValue::VecDVec2(x)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
text_props
|
||||
.value(x.iter().map(|v| format!("({}, {})", v.x, v.y)).collect::<Vec<_>>().join(", "))
|
||||
.on_update(optionally_update_value(move |x: &TextInput| from_string(&x.value), node_id, index))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetHolder>, Option<Vec<WidgetHolder>>) {
|
||||
pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetInstance>, Option<Vec<WidgetInstance>>) {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut first_widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -773,22 +773,22 @@ pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetH
|
|||
};
|
||||
if let Some(TaggedValue::Font(font)) = &input.as_non_exposed_value() {
|
||||
first_widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
FontInput::new(font.font_family.clone(), font.font_style.clone())
|
||||
.on_update(update_value(from_font_input, node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
let mut second_row = vec![TextLabel::new("").widget_holder()];
|
||||
let mut second_row = vec![TextLabel::new("").widget_instance()];
|
||||
add_blank_assist(&mut second_row);
|
||||
second_row.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
FontInput::new(font.font_family.clone(), font.font_style.clone())
|
||||
.is_style_picker(true)
|
||||
.on_update(update_value(from_font_input, node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
second_widgets = Some(second_row);
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetH
|
|||
}
|
||||
|
||||
// Two number fields beside one another, the first for the fractional part (decimals, range mode) and the second for the whole part (integers, increment mode)
|
||||
pub fn progression_widget(parameter_widgets_info: ParameterWidgetsInfo, number_props: NumberInput) -> Vec<WidgetHolder> {
|
||||
pub fn progression_widget(parameter_widgets_info: ParameterWidgetsInfo, number_props: NumberInput) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -811,7 +811,7 @@ pub fn progression_widget(parameter_widgets_info: ParameterWidgetsInfo, number_p
|
|||
let fractional_part = x.fract();
|
||||
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.clone()
|
||||
.label("Progress")
|
||||
|
|
@ -821,10 +821,10 @@ pub fn progression_widget(parameter_widgets_info: ParameterWidgetsInfo, number_p
|
|||
.value(Some(fractional_part))
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::F64(whole_part + input.value.unwrap()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
TextLabel::new("+").widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
TextLabel::new("+").widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
number_props
|
||||
.label("Element #")
|
||||
.mode_increment()
|
||||
|
|
@ -833,13 +833,13 @@ pub fn progression_widget(parameter_widgets_info: ParameterWidgetsInfo, number_p
|
|||
.value(Some(whole_part))
|
||||
.on_update(update_value(move |input: &NumberInput| TaggedValue::F64(input.value.unwrap() + fractional_part), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
}
|
||||
|
||||
pub fn number_widget(parameter_widgets_info: ParameterWidgetsInfo, number_props: NumberInput) -> Vec<WidgetHolder> {
|
||||
pub fn number_widget(parameter_widgets_info: ParameterWidgetsInfo, number_props: NumberInput) -> Vec<WidgetInstance> {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
let mut widgets = start_widgets(parameter_widgets_info);
|
||||
|
|
@ -851,75 +851,75 @@ pub fn number_widget(parameter_widgets_info: ParameterWidgetsInfo, number_props:
|
|||
};
|
||||
match input.as_non_exposed_value() {
|
||||
Some(&TaggedValue::F64(x)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.value(Some(x))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::F64(x.value.unwrap()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Some(&TaggedValue::F32(x)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.value(Some(x as f64))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::F32(x.value.unwrap() as f32), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Some(&TaggedValue::U32(x)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.value(Some(x as f64))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::U32((x.value.unwrap()) as u32), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Some(&TaggedValue::U64(x)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.value(Some(x as f64))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::U64((x.value.unwrap()) as u64), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Some(&TaggedValue::OptionalF64(x)) => {
|
||||
// TODO: Don't wipe out the previously set value (setting it back to the default of 100) when reenabling this checkbox back to Some from None
|
||||
let toggle_enabled = move |checkbox_input: &CheckboxInput| TaggedValue::OptionalF64(if checkbox_input.checked { Some(100.) } else { None });
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
// The checkbox toggles if the value is Some or None
|
||||
CheckboxInput::new(x.is_some())
|
||||
.on_update(update_value(toggle_enabled, node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
.value(x)
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::OptionalF64(x.value), node_id, index))
|
||||
.disabled(x.is_none())
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
Some(&TaggedValue::DVec2(dvec2)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
// We use an arbitrary `y` instead of an arbitrary `x` here because the "Grid" node's "Spacing" value's height should be used from rectangular mode when transferred to "Y Spacing" in isometric mode
|
||||
.value(Some(dvec2.y))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::F64(x.value.unwrap()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
Some(&TaggedValue::FVec2(vec2)) => widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
number_props
|
||||
// We use an arbitrary `y` instead of an arbitrary `x` here because the "Grid" node's "Spacing" value's height should be used from rectangular mode when transferred to "Y Spacing" in isometric mode
|
||||
.value(Some(vec2.y as f64))
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::F32(x.value.unwrap() as f32), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]),
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -954,10 +954,10 @@ pub fn blend_mode_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Layout
|
|||
.collect();
|
||||
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
DropdownInput::new(entries)
|
||||
.selected_index(blend_mode.index_in_list_svg_subset().map(|index| index as u32))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
LayoutGroup::Row { widgets }.with_tooltip_description("Formula used for blending.")
|
||||
|
|
@ -975,7 +975,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
};
|
||||
|
||||
// Add a separator
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
// Add the color input
|
||||
match &**tagged_value {
|
||||
|
|
@ -985,7 +985,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
.allow_none(false)
|
||||
.on_update(update_value(|input: &ColorInput| TaggedValue::ColorNotInTable(input.value.as_solid().unwrap()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
),
|
||||
TaggedValue::OptionalColorNotInTable(color) => widgets.push(
|
||||
color_button
|
||||
|
|
@ -993,7 +993,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
.allow_none(true)
|
||||
.on_update(update_value(|input: &ColorInput| TaggedValue::OptionalColorNotInTable(input.value.as_solid()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
),
|
||||
TaggedValue::Color(color_table) => widgets.push(
|
||||
color_button
|
||||
|
|
@ -1007,7 +1007,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
),
|
||||
TaggedValue::GradientTable(gradient_table) => widgets.push(
|
||||
color_button
|
||||
|
|
@ -1021,7 +1021,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
),
|
||||
TaggedValue::GradientStops(gradient_stops) => widgets.push(
|
||||
color_button
|
||||
|
|
@ -1032,7 +1032,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||
index,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
),
|
||||
x => warn!("Colour {x:?}"),
|
||||
}
|
||||
|
|
@ -1057,11 +1057,11 @@ pub fn curve_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup
|
|||
};
|
||||
if let Some(TaggedValue::Curve(curve)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CurveInput::new(curve.clone())
|
||||
.on_update(update_value(|x: &CurveInput| TaggedValue::Curve(x.value.clone()), node_id, index))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
LayoutGroup::Row { widgets }
|
||||
|
|
@ -1467,10 +1467,10 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
|
|||
|
||||
// Corner Radius
|
||||
let mut corner_radius_row_1 = start_widgets(ParameterWidgetsInfo::new(node_id, CornerRadiusInput::<f64>::INDEX, true, context));
|
||||
corner_radius_row_1.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
corner_radius_row_1.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let mut corner_radius_row_2 = vec![Separator::new(SeparatorType::Unrelated).widget_holder()];
|
||||
corner_radius_row_2.push(TextLabel::new("").widget_holder());
|
||||
let mut corner_radius_row_2 = vec![Separator::new(SeparatorType::Unrelated).widget_instance()];
|
||||
corner_radius_row_2.push(TextLabel::new("").widget_instance());
|
||||
add_blank_assist(&mut corner_radius_row_2);
|
||||
|
||||
let document_node = match get_document_node(node_id, context) {
|
||||
|
|
@ -1540,7 +1540,7 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
|
|||
]),
|
||||
})
|
||||
.on_commit(commit_value);
|
||||
let radio_input = RadioInput::new(vec![uniform, individual]).selected_index(Some(is_individual as u32)).widget_holder();
|
||||
let radio_input = RadioInput::new(vec![uniform, individual]).selected_index(Some(is_individual as u32)).widget_instance();
|
||||
corner_radius_row_1.push(radio_input);
|
||||
|
||||
// Radius value input widget
|
||||
|
|
@ -1561,14 +1561,14 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
|
|||
TextInput::default()
|
||||
.value(individual_val.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(", "))
|
||||
.on_update(optionally_update_value(move |x: &TextInput| from_string(&x.value), node_id, CornerRadiusInput::<f64>::INDEX))
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
} else {
|
||||
NumberInput::default()
|
||||
.value(Some(uniform_val))
|
||||
.unit(" px")
|
||||
.on_update(update_value(move |x: &NumberInput| TaggedValue::F64(x.value.unwrap()), node_id, CornerRadiusInput::<f64>::INDEX))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
};
|
||||
corner_radius_row_2.push(input_widget);
|
||||
}
|
||||
|
|
@ -1730,7 +1730,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
let backup_color_fill: Fill = backup_color.clone().into();
|
||||
let backup_gradient_fill: Fill = backup_gradient.clone().into();
|
||||
|
||||
widgets_first_row.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets_first_row.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets_first_row.push(
|
||||
ColorInput::default()
|
||||
.value(fill.clone().into())
|
||||
|
|
@ -1765,12 +1765,12 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
]),
|
||||
})
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
let mut widgets = vec![LayoutGroup::Row { widgets: widgets_first_row }];
|
||||
|
||||
let fill_type_switch = {
|
||||
let mut row = vec![TextLabel::new("").widget_holder()];
|
||||
let mut row = vec![TextLabel::new("").widget_instance()];
|
||||
match fill {
|
||||
Fill::Solid(_) | Fill::None => add_blank_assist(&mut row),
|
||||
Fill::Gradient(gradient) => {
|
||||
|
|
@ -1788,8 +1788,8 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
node_id,
|
||||
FillInput::<Color>::INDEX,
|
||||
))
|
||||
.widget_holder();
|
||||
row.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
.widget_instance();
|
||||
row.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
row.push(reverse_button);
|
||||
}
|
||||
}
|
||||
|
|
@ -1806,8 +1806,8 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
];
|
||||
|
||||
row.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
RadioInput::new(entries).selected_index(Some(if fill.as_gradient().is_some() { 1 } else { 0 })).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
RadioInput::new(entries).selected_index(Some(if fill.as_gradient().is_some() { 1 } else { 0 })).widget_instance(),
|
||||
]);
|
||||
|
||||
LayoutGroup::Row { widgets: row }
|
||||
|
|
@ -1815,7 +1815,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
widgets.push(fill_type_switch);
|
||||
|
||||
if let Fill::Gradient(gradient) = fill.clone() {
|
||||
let mut row = vec![TextLabel::new("").widget_holder()];
|
||||
let mut row = vec![TextLabel::new("").widget_instance()];
|
||||
match gradient.gradient_type {
|
||||
GradientType::Linear => add_blank_assist(&mut row),
|
||||
GradientType::Radial => {
|
||||
|
|
@ -1838,8 +1838,8 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
node_id,
|
||||
FillInput::<Color>::INDEX,
|
||||
))
|
||||
.widget_holder();
|
||||
row.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
.widget_instance();
|
||||
row.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
row.push(reverse_radial_gradient_button);
|
||||
}
|
||||
}
|
||||
|
|
@ -1875,8 +1875,8 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||
];
|
||||
|
||||
row.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
RadioInput::new(entries).selected_index(Some(gradient.gradient_type as u32)).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
RadioInput::new(entries).selected_index(Some(gradient.gradient_type as u32)).widget_instance(),
|
||||
]);
|
||||
|
||||
widgets.push(LayoutGroup::Row { widgets: row });
|
||||
|
|
@ -1996,7 +1996,7 @@ pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
|
|||
};
|
||||
if let Some(TaggedValue::String(x)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextInput::new(x.clone())
|
||||
.centered(true)
|
||||
.on_update(update_value(
|
||||
|
|
@ -2017,13 +2017,13 @@ pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
|
|||
ExpressionInput::INDEX,
|
||||
))
|
||||
.on_commit(commit_value)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
widgets
|
||||
})();
|
||||
let operand_b = number_widget(ParameterWidgetsInfo::new(node_id, OperandBInput::<f64>::INDEX, true, context), NumberInput::default());
|
||||
let operand_a_hint = vec![TextLabel::new("(Operand A is the primary input)").widget_holder()];
|
||||
let operand_a_hint = vec![TextLabel::new("(Operand A is the primary input)").widget_instance()];
|
||||
|
||||
vec![
|
||||
LayoutGroup::Row { widgets: expression }.with_tooltip_description(r#"A math expression that may incorporate "A" and/or "B", such as "sqrt(A + B) - B^2"."#),
|
||||
|
|
@ -2077,7 +2077,7 @@ pub mod choice {
|
|||
|
||||
fn disabled(self, disabled: bool) -> Self;
|
||||
|
||||
fn build<U, C>(&self, current: Self::Value, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetHolder
|
||||
fn build<U, C>(&self, current: Self::Value, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetInstance
|
||||
where
|
||||
U: Fn(&Self::Value) -> Message + 'static + Send + Sync,
|
||||
C: Fn(&()) -> Message + 'static + Send + Sync;
|
||||
|
|
@ -2116,7 +2116,7 @@ pub mod choice {
|
|||
todo!()
|
||||
}
|
||||
|
||||
fn dropdown_menu<U, C>(&self, current: E, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetHolder
|
||||
fn dropdown_menu<U, C>(&self, current: E, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetInstance
|
||||
where
|
||||
U: Fn(&E) -> Message + 'static + Send + Sync,
|
||||
C: Fn(&()) -> Message + 'static + Send + Sync,
|
||||
|
|
@ -2134,10 +2134,10 @@ pub mod choice {
|
|||
.collect()
|
||||
})
|
||||
.collect();
|
||||
DropdownInput::new(items).disabled(self.disabled).selected_index(Some(current.as_u32())).widget_holder()
|
||||
DropdownInput::new(items).disabled(self.disabled).selected_index(Some(current.as_u32())).widget_instance()
|
||||
}
|
||||
|
||||
fn radio_buttons<U, C>(&self, current: E, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetHolder
|
||||
fn radio_buttons<U, C>(&self, current: E, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetInstance
|
||||
where
|
||||
U: Fn(&E) -> Message + 'static + Send + Sync,
|
||||
C: Fn(&()) -> Message + 'static + Send + Sync,
|
||||
|
|
@ -2156,7 +2156,7 @@ pub mod choice {
|
|||
if let Some(icon) = var_meta.icon { entry.icon(icon) } else { entry.label(var_meta.label) }
|
||||
})
|
||||
.collect();
|
||||
RadioInput::new(items).selected_index(Some(current.as_u32())).widget_holder()
|
||||
RadioInput::new(items).selected_index(Some(current.as_u32())).widget_instance()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2171,7 +2171,7 @@ pub mod choice {
|
|||
E::DESCRIPTION
|
||||
}
|
||||
|
||||
fn build<U, C>(&self, current: Self::Value, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetHolder
|
||||
fn build<U, C>(&self, current: Self::Value, updater_factory: impl Fn() -> U, committer_factory: impl Fn() -> C) -> WidgetInstance
|
||||
where
|
||||
U: Fn(&Self::Value) -> Message + 'static + Send + Sync,
|
||||
C: Fn(&()) -> Message + 'static + Send + Sync,
|
||||
|
|
@ -2222,7 +2222,7 @@ pub mod choice {
|
|||
let committer = || super::commit_value;
|
||||
let updater = || super::update_value(move |v: &W::Value| TaggedValue::from(v.clone()), node_id, index);
|
||||
let widget = self.widget_factory.build(current, updater, committer);
|
||||
widgets.extend_from_slice(&[Separator::new(SeparatorType::Unrelated).widget_holder(), widget]);
|
||||
widgets.extend_from_slice(&[Separator::new(SeparatorType::Unrelated).widget_instance(), widget]);
|
||||
}
|
||||
|
||||
let mut row = LayoutGroup::Row { widgets };
|
||||
|
|
|
|||
|
|
@ -236,13 +236,13 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
|||
};
|
||||
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Grid").bold(true).widget_holder()],
|
||||
widgets: vec![TextLabel::new("Grid").bold(true).widget_instance()],
|
||||
});
|
||||
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Type").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Type").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
RadioInput::new(vec![
|
||||
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
|
||||
if let GridType::Isometric { y_axis_spacing, angle_a, angle_b } = grid.grid_type {
|
||||
|
|
@ -268,98 +268,101 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
|||
GridType::Rectangular { .. } => 0,
|
||||
GridType::Isometric { .. } => 1,
|
||||
}))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
|
||||
let mut color_widgets = vec![TextLabel::new("Display").table_align(true).widget_holder(), Separator::new(SeparatorType::Unrelated).widget_holder()];
|
||||
let mut color_widgets = vec![
|
||||
TextLabel::new("Display").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
];
|
||||
color_widgets.extend([
|
||||
CheckboxInput::new(grid.dot_display)
|
||||
.icon("GridDotted")
|
||||
.tooltip_label("Display as Dotted Grid")
|
||||
.on_update(update_display(grid, |grid| Some(&mut grid.dot_display)))
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
]);
|
||||
color_widgets.push(
|
||||
ColorInput::new(FillChoice::Solid(grid.grid_color.to_gamma_srgb()))
|
||||
.tooltip_label("Grid Display Color")
|
||||
.allow_none(false)
|
||||
.on_update(update_color(grid, |grid| Some(&mut grid.grid_color)))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
widgets.push(LayoutGroup::Row { widgets: color_widgets });
|
||||
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Origin").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Origin").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
|
||||
match grid.grid_type {
|
||||
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Spacing").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Spacing").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(spacing.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.x)))
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(spacing.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.y)))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
}),
|
||||
GridType::Isometric { y_axis_spacing, angle_a, angle_b } => {
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Y Spacing").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Y Spacing").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(y_axis_spacing))
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(200)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.isometric_y_spacing()))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Angles").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextLabel::new("Angles").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(angle_a))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_a()))
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(angle_b))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_b()))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.flush(true)
|
||||
.icon(Some("GraphiteLogo".into()))
|
||||
.on_commit(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.rs".into() }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
#[cfg(target_os = "macos")]
|
||||
TextButton::new("Graphite")
|
||||
.label("")
|
||||
|
|
@ -107,7 +107,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.on_commit(|_| AppWindowMessage::Close.into()),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("File")
|
||||
.label("File")
|
||||
.flush(true)
|
||||
|
|
@ -173,7 +173,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
#[cfg(not(target_os = "macos"))]
|
||||
vec![preferences],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Edit")
|
||||
.label("Edit")
|
||||
.flush(true)
|
||||
|
|
@ -234,7 +234,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.disabled(no_active_document),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Layer")
|
||||
.label("Layer")
|
||||
.flush(true)
|
||||
|
|
@ -503,7 +503,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.disabled(!make_path_editable_is_allowed),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Select")
|
||||
.label("Select")
|
||||
.flush(true)
|
||||
|
|
@ -543,7 +543,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.disabled(!has_selection_history.1),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("View")
|
||||
.label("View")
|
||||
.flush(true)
|
||||
|
|
@ -617,7 +617,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.disabled(no_active_document),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Window")
|
||||
.label("Window")
|
||||
.flush(true)
|
||||
|
|
@ -642,7 +642,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
.on_commit(|_| PortfolioMessage::ToggleDataPanelOpen.into()),
|
||||
],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
TextButton::new("Help")
|
||||
.label("Help")
|
||||
.flush(true)
|
||||
|
|
@ -733,7 +733,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
vec![MenuListEntry::new("Trigger a Crash").label("Trigger a Crash").icon("Warning").on_commit(|_| panic!())],
|
||||
])],
|
||||
])
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets: menu_bar_buttons }]))
|
||||
|
|
|
|||
|
|
@ -892,30 +892,30 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||
.icon(Some("File".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| DialogMessage::RequestNewDocumentDialog.into())
|
||||
.widget_holder(),
|
||||
ShortcutLabel::new(action_shortcut!(DialogMessageDiscriminant::RequestNewDocumentDialog)).widget_holder(),
|
||||
.widget_instance(),
|
||||
ShortcutLabel::new(action_shortcut!(DialogMessageDiscriminant::RequestNewDocumentDialog)).widget_instance(),
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Open Document")
|
||||
.icon(Some("Folder".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| PortfolioMessage::OpenDocument.into())
|
||||
.widget_holder(),
|
||||
ShortcutLabel::new(action_shortcut!(PortfolioMessageDiscriminant::OpenDocument)).widget_holder(),
|
||||
.widget_instance(),
|
||||
ShortcutLabel::new(action_shortcut!(PortfolioMessageDiscriminant::OpenDocument)).widget_instance(),
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Open Demo Artwork")
|
||||
.icon(Some("Image".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| DialogMessage::RequestDemoArtworkDialog.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Support the Development Fund")
|
||||
.icon(Some("Heart".into()))
|
||||
.flush(true)
|
||||
.on_commit(move |_| FrontendMessage::TriggerVisitLink { url: donate.to_string() }.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,20 +79,20 @@ impl ToolColorOptions {
|
|||
reset_callback: impl Fn(&IconButton) -> Message + 'static + Send + Sync,
|
||||
radio_callback: fn(ToolColorType) -> WidgetCallback<()>,
|
||||
color_callback: impl Fn(&ColorInput) -> Message + 'static + Send + Sync,
|
||||
) -> Vec<WidgetHolder> {
|
||||
let mut widgets = vec![TextLabel::new(label_text).widget_holder()];
|
||||
) -> Vec<WidgetInstance> {
|
||||
let mut widgets = vec![TextLabel::new(label_text).widget_instance()];
|
||||
|
||||
if !color_allow_none {
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
} else {
|
||||
let reset = IconButton::new("CloseX", 12)
|
||||
.disabled(self.custom_color.is_none() && self.color_type == ToolColorType::Custom)
|
||||
.tooltip_label("Clear Color")
|
||||
.on_update(reset_callback);
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(reset.widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
widgets.push(reset.widget_instance());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
};
|
||||
|
||||
let entries = vec![
|
||||
|
|
@ -107,16 +107,16 @@ impl ToolColorOptions {
|
|||
entry
|
||||
})
|
||||
.collect();
|
||||
let radio = RadioInput::new(entries).selected_index(Some(self.color_type.clone() as u32)).widget_holder();
|
||||
let radio = RadioInput::new(entries).selected_index(Some(self.color_type.clone() as u32)).widget_instance();
|
||||
widgets.push(radio);
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
|
||||
let fill_choice = match self.active_color() {
|
||||
Some(color) => FillChoice::Solid(color.to_gamma_srgb()),
|
||||
None => FillChoice::None,
|
||||
};
|
||||
let color_button = ColorInput::new(fill_choice).allow_none(color_allow_none).on_update(color_callback);
|
||||
widgets.push(color_button.widget_holder());
|
||||
widgets.push(color_button.widget_instance());
|
||||
|
||||
widgets
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use graphene_std::transform::ReferencePoint;
|
|||
use graphene_std::vector::misc::ManipulatorPointId;
|
||||
use std::fmt;
|
||||
|
||||
pub fn pin_pivot_widget(active: bool, enabled: bool, source: PivotToolSource) -> WidgetHolder {
|
||||
pub fn pin_pivot_widget(active: bool, enabled: bool, source: PivotToolSource) -> WidgetInstance {
|
||||
IconButton::new(if active { "PinActive" } else { "PinInactive" }, 24)
|
||||
.tooltip_label(if active { "Unpin Custom Pivot" } else { "Pin Custom Pivot" })
|
||||
.tooltip_description("Unless pinned, the pivot will return to its prior reference point when a new selection is made.")
|
||||
|
|
@ -27,10 +27,10 @@ pub fn pin_pivot_widget(active: bool, enabled: bool, source: PivotToolSource) ->
|
|||
}
|
||||
.into(),
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
pub fn pivot_reference_point_widget(disabled: bool, reference_point: ReferencePoint, source: PivotToolSource) -> WidgetHolder {
|
||||
pub fn pivot_reference_point_widget(disabled: bool, reference_point: ReferencePoint, source: PivotToolSource) -> WidgetInstance {
|
||||
ReferencePointInput::new(reference_point)
|
||||
.tooltip_label("Custom Pivot Reference Point")
|
||||
.tooltip_description("Places the pivot at a corner, edge, or center of the selection bounds, unless it is dragged elsewhere.")
|
||||
|
|
@ -39,10 +39,10 @@ pub fn pivot_reference_point_widget(disabled: bool, reference_point: ReferencePo
|
|||
PivotToolSource::Select => SelectToolMessage::SetPivot { position: pivot_input.value }.into(),
|
||||
PivotToolSource::Path => PathToolMessage::SetPivot { position: pivot_input.value }.into(),
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
pub fn pivot_gizmo_type_widget(state: PivotGizmoState, source: PivotToolSource) -> Vec<WidgetHolder> {
|
||||
pub fn pivot_gizmo_type_widget(state: PivotGizmoState, source: PivotToolSource) -> Vec<WidgetInstance> {
|
||||
let gizmo_type_entries = [PivotGizmoType::Pivot, PivotGizmoType::Average, PivotGizmoType::Active]
|
||||
.iter()
|
||||
.map(|gizmo_type| {
|
||||
|
|
@ -82,8 +82,8 @@ pub fn pivot_gizmo_type_widget(state: PivotGizmoState, source: PivotToolSource)
|
|||
}
|
||||
.into(),
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
DropdownInput::new(vec![gizmo_type_entries])
|
||||
.selected_index(Some(match state.gizmo_type {
|
||||
PivotGizmoType::Pivot => 0,
|
||||
|
|
@ -102,7 +102,7 @@ pub fn pivot_gizmo_type_widget(state: PivotGizmoState, source: PivotToolSource)
|
|||
.trim(),
|
||||
)
|
||||
.disabled(state.disabled)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ impl LayoutHolder for BrushTool {
|
|||
.max(BRUSH_MAX_SIZE) /* Anything bigger would cause the application to be unresponsive and eventually die */
|
||||
.unit(" px")
|
||||
.on_update(|number_input: &NumberInput| BrushToolMessage::UpdateOptions { options: BrushToolMessageOptionsUpdate::Diameter(number_input.value.unwrap()) }.into())
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(self.options.hardness))
|
||||
.label("Hardness")
|
||||
.min(0.)
|
||||
|
|
@ -121,8 +121,8 @@ impl LayoutHolder for BrushTool {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(self.options.flow))
|
||||
.label("Flow")
|
||||
.min(1.)
|
||||
|
|
@ -135,8 +135,8 @@ impl LayoutHolder for BrushTool {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
NumberInput::new(Some(self.options.spacing))
|
||||
.label("Spacing")
|
||||
.min(1.)
|
||||
|
|
@ -149,10 +149,10 @@ impl LayoutHolder for BrushTool {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
let draw_mode_entries: Vec<_> = [DrawMode::Draw, DrawMode::Erase, DrawMode::Restore]
|
||||
.into_iter()
|
||||
|
|
@ -165,9 +165,9 @@ impl LayoutHolder for BrushTool {
|
|||
})
|
||||
})
|
||||
.collect();
|
||||
widgets.push(RadioInput::new(draw_mode_entries).selected_index(Some(self.options.draw_mode as u32)).widget_holder());
|
||||
widgets.push(RadioInput::new(draw_mode_entries).selected_index(Some(self.options.draw_mode as u32)).widget_instance());
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.append(&mut self.options.color.create_widgets(
|
||||
"Color",
|
||||
|
|
@ -194,7 +194,7 @@ impl LayoutHolder for BrushTool {
|
|||
},
|
||||
));
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
|
||||
let blend_mode_entries: Vec<Vec<_>> = BlendMode::list()
|
||||
.iter()
|
||||
|
|
@ -217,7 +217,7 @@ impl LayoutHolder for BrushTool {
|
|||
.selected_index(self.options.blend_mode.index_in_list().map(|index| index as u32))
|
||||
.tooltip_description("The blend mode used with the background when performing a brush stroke. Only used in draw mode.")
|
||||
.disabled(self.options.draw_mode != DrawMode::Draw)
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ impl ToolMetadata for FreehandTool {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetInstance {
|
||||
NumberInput::new(Some(line_weight))
|
||||
.unit(" px")
|
||||
.label("Weight")
|
||||
|
|
@ -92,7 +92,7 @@ fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
impl LayoutHolder for FreehandTool {
|
||||
|
|
@ -122,7 +122,7 @@ impl LayoutHolder for FreehandTool {
|
|||
},
|
||||
);
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.append(&mut self.options.stroke.create_widgets(
|
||||
"Stroke",
|
||||
|
|
@ -148,7 +148,7 @@ impl LayoutHolder for FreehandTool {
|
|||
.into()
|
||||
},
|
||||
));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.push(create_weight_widget(self.options.line_weight));
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ impl LayoutHolder for GradientTool {
|
|||
}),
|
||||
])
|
||||
.selected_index(Some((self.selected_gradient().unwrap_or(self.options.gradient_type) == GradientType::Radial) as u32))
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets: vec![gradient_type] }]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ impl LayoutHolder for PathTool {
|
|||
Message::NoOp
|
||||
}
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
let y_location = NumberInput::new(y)
|
||||
.unit(" px")
|
||||
|
|
@ -231,10 +231,10 @@ impl LayoutHolder for PathTool {
|
|||
Message::NoOp
|
||||
}
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
let related_seperator = Separator::new(SeparatorType::Related).widget_holder();
|
||||
let unrelated_seperator = Separator::new(SeparatorType::Unrelated).widget_holder();
|
||||
let related_seperator = Separator::new(SeparatorType::Related).widget_instance();
|
||||
let unrelated_seperator = Separator::new(SeparatorType::Unrelated).widget_instance();
|
||||
|
||||
let colinear_handles_description = "Keep both handles unbent, each 180° apart, when moving either.";
|
||||
let colinear_handles_state = manipulator_angle.and_then(|angle| match angle {
|
||||
|
|
@ -257,13 +257,13 @@ impl LayoutHolder for PathTool {
|
|||
.tooltip_label("Colinear Handles")
|
||||
.tooltip_description(colinear_handles_description)
|
||||
.for_label(checkbox_id)
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let colinear_handles_label = TextLabel::new("Colinear Handles")
|
||||
.disabled(!self.tool_data.can_toggle_colinearity)
|
||||
.tooltip_label("Colinear Handles")
|
||||
.tooltip_description(colinear_handles_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
let point_editing_mode = CheckboxInput::new(self.options.path_editing_mode.point_editing_mode)
|
||||
// TODO(Keavon): Replace with a real icon
|
||||
|
|
@ -272,7 +272,7 @@ impl LayoutHolder for PathTool {
|
|||
.tooltip_description("To multi-select modes, perform the shortcut shown.")
|
||||
.tooltip_shortcut(action_shortcut_manual!(Key::Shift, Key::MouseLeft))
|
||||
.on_update(|_| PathToolMessage::TogglePointEditing.into())
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let segment_editing_mode = CheckboxInput::new(self.options.path_editing_mode.segment_editing_mode)
|
||||
// TODO(Keavon): Replace with a real icon
|
||||
.icon("Remove")
|
||||
|
|
@ -280,7 +280,7 @@ impl LayoutHolder for PathTool {
|
|||
.tooltip_description("To multi-select modes, perform the shortcut shown.")
|
||||
.tooltip_shortcut(action_shortcut_manual!(Key::Shift, Key::MouseLeft))
|
||||
.on_update(|_| PathToolMessage::ToggleSegmentEditing.into())
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
let path_overlay_mode_widget = RadioInput::new(vec![
|
||||
RadioEntryData::new("all")
|
||||
|
|
@ -315,7 +315,7 @@ impl LayoutHolder for PathTool {
|
|||
}),
|
||||
])
|
||||
.selected_index(Some(self.options.path_overlay_mode as u32))
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
// Works only if a single layer is selected and its type is Vector
|
||||
let path_node_button = TextButton::new("Make Path Editable")
|
||||
|
|
@ -326,7 +326,7 @@ impl LayoutHolder for PathTool {
|
|||
)
|
||||
.on_update(|_| NodeGraphMessage::AddPathNode.into())
|
||||
.disabled(!self.tool_data.make_path_editable_is_allowed)
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
|
||||
let [_checkbox, _dropdown] = {
|
||||
let pivot_gizmo_type_widget = pivot_gizmo_type_widget(self.tool_data.pivot_gizmo.state, PivotToolSource::Path);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ impl ToolMetadata for PenTool {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetInstance {
|
||||
NumberInput::new(Some(line_weight))
|
||||
.unit(" px")
|
||||
.label("Weight")
|
||||
|
|
@ -148,7 +148,7 @@ fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
impl LayoutHolder for PenTool {
|
||||
|
|
@ -178,7 +178,7 @@ impl LayoutHolder for PenTool {
|
|||
},
|
||||
);
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.append(&mut self.options.stroke.create_widgets(
|
||||
"Stroke",
|
||||
|
|
@ -205,11 +205,11 @@ impl LayoutHolder for PenTool {
|
|||
},
|
||||
));
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.push(create_weight_widget(self.options.line_weight));
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.push(
|
||||
RadioInput::new(vec![
|
||||
|
|
@ -235,7 +235,7 @@ impl LayoutHolder for PenTool {
|
|||
}),
|
||||
])
|
||||
.selected_index(Some(self.options.pen_overlay_mode as u32))
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
);
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ impl ToolMetadata for SelectTool {
|
|||
}
|
||||
|
||||
impl SelectTool {
|
||||
fn deep_selection_widget(&self) -> WidgetHolder {
|
||||
fn deep_selection_widget(&self) -> WidgetInstance {
|
||||
let layer_selection_behavior_entries = [NestedSelectionBehavior::Shallowest, NestedSelectionBehavior::Deepest]
|
||||
.iter()
|
||||
.map(|mode| {
|
||||
|
|
@ -151,10 +151,10 @@ impl SelectTool {
|
|||
"Shallow Select: clicks initially select the least-nested layers and double clicks drill deeper into the folder hierarchy.\n\
|
||||
Deep Select: clicks directly select the most-nested layers in the folder hierarchy.",
|
||||
)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
fn alignment_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetHolder> + use<> {
|
||||
fn alignment_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetInstance> + use<> {
|
||||
[AlignAxis::X, AlignAxis::Y]
|
||||
.into_iter()
|
||||
.flat_map(|axis| [(axis, AlignAggregate::Min), (axis, AlignAggregate::Center), (axis, AlignAggregate::Max)])
|
||||
|
|
@ -171,11 +171,11 @@ impl SelectTool {
|
|||
.tooltip_label(label)
|
||||
.on_update(move |_| DocumentMessage::AlignSelectedLayers { axis, aggregate }.into())
|
||||
.disabled(disabled)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
})
|
||||
}
|
||||
|
||||
fn flip_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetHolder> + use<> {
|
||||
fn flip_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetInstance> + use<> {
|
||||
[(FlipAxis::X, "FlipHorizontal", "Flip Horizontal"), (FlipAxis::Y, "FlipVertical", "Flip Vertical")]
|
||||
.into_iter()
|
||||
.map(move |(flip_axis, icon, label)| {
|
||||
|
|
@ -183,11 +183,11 @@ impl SelectTool {
|
|||
.tooltip_label(label)
|
||||
.on_update(move |_| DocumentMessage::FlipSelectedLayers { flip_axis }.into())
|
||||
.disabled(disabled)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
})
|
||||
}
|
||||
|
||||
fn turn_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetHolder> + use<> {
|
||||
fn turn_widgets(&self, disabled: bool) -> impl Iterator<Item = WidgetInstance> + use<> {
|
||||
[(-90., "TurnNegative90", "Turn -90°"), (90., "TurnPositive90", "Turn 90°")]
|
||||
.into_iter()
|
||||
.map(move |(degrees, icon, label)| {
|
||||
|
|
@ -195,11 +195,11 @@ impl SelectTool {
|
|||
.tooltip_label(label)
|
||||
.on_update(move |_| DocumentMessage::RotateSelectedLayers { degrees }.into())
|
||||
.disabled(disabled)
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
})
|
||||
}
|
||||
|
||||
fn boolean_widgets(&self, selected_count: usize) -> impl Iterator<Item = WidgetHolder> + use<> {
|
||||
fn boolean_widgets(&self, selected_count: usize) -> impl Iterator<Item = WidgetInstance> + use<> {
|
||||
let list = <BooleanOperation as graphene_std::choice_type::ChoiceTypeStatic>::list();
|
||||
list.iter().flat_map(|i| i.iter()).map(move |(operation, info)| {
|
||||
IconButton::new(info.icon.unwrap(), 24)
|
||||
|
|
@ -210,7 +210,7 @@ impl SelectTool {
|
|||
let group_folder_type = GroupFolderType::BooleanOperation(*operation);
|
||||
DocumentMessage::GroupSelectedLayers { group_folder_type }.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -223,12 +223,12 @@ impl LayoutHolder for SelectTool {
|
|||
widgets.push(self.deep_selection_widget());
|
||||
|
||||
// Pivot gizmo type (checkbox + dropdown for pivot/origin)
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.extend(pivot_gizmo_type_widget(self.tool_data.pivot_gizmo.state, PivotToolSource::Select));
|
||||
|
||||
if self.tool_data.pivot_gizmo.state.is_pivot_type() {
|
||||
// Nine-position reference point widget
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
widgets.push(pivot_reference_point_widget(
|
||||
self.tool_data.selected_layers_count == 0 || !self.tool_data.pivot_gizmo.state.is_pivot(),
|
||||
self.tool_data.pivot_gizmo.pivot.to_pivot_position(),
|
||||
|
|
@ -236,7 +236,7 @@ impl LayoutHolder for SelectTool {
|
|||
));
|
||||
|
||||
// Pivot pin button
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
|
||||
let pin_active = self.tool_data.pivot_gizmo.pin_active();
|
||||
let pin_enabled = self.tool_data.pivot_gizmo.pivot.old_pivot_position == ReferencePoint::None && !self.tool_data.pivot_gizmo.state.disabled;
|
||||
|
|
@ -248,33 +248,33 @@ impl LayoutHolder for SelectTool {
|
|||
|
||||
// Align
|
||||
let disabled = self.tool_data.selected_layers_count < 2;
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.extend(self.alignment_widgets(disabled));
|
||||
// widgets.push(
|
||||
// PopoverButton::new()
|
||||
// .popover_layout(vec![
|
||||
// LayoutGroup::Row {
|
||||
// widgets: vec![TextLabel::new("Align").bold(true).widget_holder()],
|
||||
// widgets: vec![TextLabel::new("Align").bold(true).widget_instance()],
|
||||
// },
|
||||
// LayoutGroup::Row {
|
||||
// widgets: vec![TextLabel::new("Coming soon").widget_holder()],
|
||||
// widgets: vec![TextLabel::new("Coming soon").widget_instance()],
|
||||
// },
|
||||
// ])
|
||||
// .disabled(disabled)
|
||||
// .widget_holder(),
|
||||
// .widget_instance(),
|
||||
// );
|
||||
|
||||
// Flip
|
||||
let disabled = self.tool_data.selected_layers_count == 0;
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.extend(self.flip_widgets(disabled));
|
||||
|
||||
// Turn
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.extend(self.turn_widgets(disabled));
|
||||
|
||||
// Boolean
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.extend(self.boolean_widgets(self.tool_data.selected_layers_count));
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ pub enum ShapeToolMessage {
|
|||
NudgeSelectedLayers { delta_x: f64, delta_y: f64, resize: Key, resize_opposite_corner: Key },
|
||||
}
|
||||
|
||||
fn create_sides_widget(vertices: u32) -> WidgetHolder {
|
||||
fn create_sides_widget(vertices: u32) -> WidgetInstance {
|
||||
NumberInput::new(Some(vertices as f64))
|
||||
.label("Sides")
|
||||
.int()
|
||||
|
|
@ -113,10 +113,10 @@ fn create_sides_widget(vertices: u32) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
fn create_turns_widget(turns: f64) -> WidgetHolder {
|
||||
fn create_turns_widget(turns: f64) -> WidgetInstance {
|
||||
NumberInput::new(Some(turns))
|
||||
.label("Turns")
|
||||
.min(0.5)
|
||||
|
|
@ -127,10 +127,10 @@ fn create_turns_widget(turns: f64) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
fn create_shape_option_widget(shape_type: ShapeType) -> WidgetHolder {
|
||||
fn create_shape_option_widget(shape_type: ShapeType) -> WidgetInstance {
|
||||
let entries = vec![vec![
|
||||
MenuListEntry::new("Polygon").label("Polygon").on_commit(move |_| {
|
||||
ShapeToolMessage::UpdateOptions {
|
||||
|
|
@ -169,10 +169,10 @@ fn create_shape_option_widget(shape_type: ShapeType) -> WidgetHolder {
|
|||
.into()
|
||||
}),
|
||||
]];
|
||||
DropdownInput::new(entries).selected_index(Some(shape_type as u32)).widget_holder()
|
||||
DropdownInput::new(entries).selected_index(Some(shape_type as u32)).widget_instance()
|
||||
}
|
||||
|
||||
fn create_arc_type_widget(arc_type: ArcType) -> WidgetHolder {
|
||||
fn create_arc_type_widget(arc_type: ArcType) -> WidgetInstance {
|
||||
let entries = vec![
|
||||
RadioEntryData::new("Open").label("Open").on_update(move |_| {
|
||||
ShapeToolMessage::UpdateOptions {
|
||||
|
|
@ -193,10 +193,10 @@ fn create_arc_type_widget(arc_type: ArcType) -> WidgetHolder {
|
|||
.into()
|
||||
}),
|
||||
];
|
||||
RadioInput::new(entries).selected_index(Some(arc_type as u32)).widget_holder()
|
||||
RadioInput::new(entries).selected_index(Some(arc_type as u32)).widget_instance()
|
||||
}
|
||||
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetInstance {
|
||||
NumberInput::new(Some(line_weight))
|
||||
.unit(" px")
|
||||
.label("Weight")
|
||||
|
|
@ -208,10 +208,10 @@ fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
fn create_spiral_type_widget(spiral_type: SpiralType) -> WidgetHolder {
|
||||
fn create_spiral_type_widget(spiral_type: SpiralType) -> WidgetInstance {
|
||||
let entries = vec![vec![
|
||||
MenuListEntry::new("Archimedean").label("Archimedean").on_commit(move |_| {
|
||||
ShapeToolMessage::UpdateOptions {
|
||||
|
|
@ -226,10 +226,10 @@ fn create_spiral_type_widget(spiral_type: SpiralType) -> WidgetHolder {
|
|||
.into()
|
||||
}),
|
||||
]];
|
||||
DropdownInput::new(entries).selected_index(Some(spiral_type as u32)).widget_holder()
|
||||
DropdownInput::new(entries).selected_index(Some(spiral_type as u32)).widget_instance()
|
||||
}
|
||||
|
||||
fn create_grid_type_widget(grid_type: GridType) -> WidgetHolder {
|
||||
fn create_grid_type_widget(grid_type: GridType) -> WidgetInstance {
|
||||
let entries = vec![
|
||||
RadioEntryData::new("Rectangular").label("Rectangular").on_update(move |_| {
|
||||
ShapeToolMessage::UpdateOptions {
|
||||
|
|
@ -244,7 +244,7 @@ fn create_grid_type_widget(grid_type: GridType) -> WidgetHolder {
|
|||
.into()
|
||||
}),
|
||||
];
|
||||
RadioInput::new(entries).selected_index(Some(grid_type as u32)).widget_holder()
|
||||
RadioInput::new(entries).selected_index(Some(grid_type as u32)).widget_instance()
|
||||
}
|
||||
|
||||
impl LayoutHolder for ShapeTool {
|
||||
|
|
@ -253,30 +253,30 @@ impl LayoutHolder for ShapeTool {
|
|||
|
||||
if !self.tool_data.hide_shape_option_widget {
|
||||
widgets.push(create_shape_option_widget(self.options.shape_type));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
if self.options.shape_type == ShapeType::Polygon || self.options.shape_type == ShapeType::Star {
|
||||
widgets.push(create_sides_widget(self.options.vertices));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
}
|
||||
|
||||
if self.options.shape_type == ShapeType::Arc {
|
||||
widgets.push(create_arc_type_widget(self.options.arc_type));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
}
|
||||
}
|
||||
|
||||
if self.options.shape_type == ShapeType::Spiral {
|
||||
widgets.push(create_spiral_type_widget(self.options.spiral_type));
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
|
||||
|
||||
widgets.push(create_turns_widget(self.options.turns));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
}
|
||||
|
||||
if self.options.shape_type == ShapeType::Grid {
|
||||
widgets.push(create_grid_type_widget(self.options.grid_type));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
}
|
||||
|
||||
if self.options.shape_type != ShapeType::Line {
|
||||
|
|
@ -305,7 +305,7 @@ impl LayoutHolder for ShapeTool {
|
|||
},
|
||||
));
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
}
|
||||
|
||||
widgets.append(&mut self.options.stroke.create_widgets(
|
||||
|
|
@ -332,7 +332,7 @@ impl LayoutHolder for ShapeTool {
|
|||
.into()
|
||||
},
|
||||
));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.push(create_weight_widget(self.options.line_weight));
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl ToolMetadata for SplineTool {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
||||
fn create_weight_widget(line_weight: f64) -> WidgetInstance {
|
||||
NumberInput::new(Some(line_weight))
|
||||
.unit(" px")
|
||||
.label("Weight")
|
||||
|
|
@ -99,7 +99,7 @@ fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
impl LayoutHolder for SplineTool {
|
||||
|
|
@ -129,7 +129,7 @@ impl LayoutHolder for SplineTool {
|
|||
},
|
||||
);
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.append(&mut self.options.stroke.create_widgets(
|
||||
"Stroke",
|
||||
|
|
@ -155,7 +155,7 @@ impl LayoutHolder for SplineTool {
|
|||
.into()
|
||||
},
|
||||
));
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
widgets.push(create_weight_widget(self.options.line_weight));
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ impl ToolMetadata for TextTool {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
||||
fn create_text_widgets(tool: &TextTool) -> Vec<WidgetInstance> {
|
||||
let font = FontInput::new(&tool.options.font_name, &tool.options.font_style)
|
||||
.is_style_picker(false)
|
||||
.on_update(|font_input: &FontInput| {
|
||||
|
|
@ -108,7 +108,7 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let style = FontInput::new(&tool.options.font_name, &tool.options.font_style)
|
||||
.is_style_picker(true)
|
||||
.on_update(|font_input: &FontInput| {
|
||||
|
|
@ -120,7 +120,7 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let size = NumberInput::new(Some(tool.options.font_size))
|
||||
.unit(" px")
|
||||
.label("Size")
|
||||
|
|
@ -133,7 +133,7 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let line_height_ratio = NumberInput::new(Some(tool.options.line_height_ratio))
|
||||
.label("Line Height")
|
||||
.int()
|
||||
|
|
@ -146,7 +146,7 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
|||
}
|
||||
.into()
|
||||
})
|
||||
.widget_holder();
|
||||
.widget_instance();
|
||||
let align_entries: Vec<_> = [TextAlign::Left, TextAlign::Center, TextAlign::Right, TextAlign::JustifyLeft]
|
||||
.into_iter()
|
||||
.map(|align| {
|
||||
|
|
@ -158,16 +158,16 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
|
|||
})
|
||||
})
|
||||
.collect();
|
||||
let align = RadioInput::new(align_entries).selected_index(Some(tool.options.align as u32)).widget_holder();
|
||||
let align = RadioInput::new(align_entries).selected_index(Some(tool.options.align as u32)).widget_instance();
|
||||
vec![
|
||||
font,
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
style,
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
size,
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
line_height_ratio,
|
||||
Separator::new(SeparatorType::Related).widget_holder(),
|
||||
Separator::new(SeparatorType::Related).widget_instance(),
|
||||
align,
|
||||
]
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ impl LayoutHolder for TextTool {
|
|||
fn layout(&self) -> Layout {
|
||||
let mut widgets = create_text_widgets(self);
|
||||
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
|
||||
|
||||
widgets.append(&mut self.options.fill.create_widgets(
|
||||
"Fill",
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ impl DocumentToolData {
|
|||
pub fn update_working_colors(&self, responses: &mut VecDeque<Message>) {
|
||||
let layout = WidgetLayout::new(vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![WorkingColorsInput::new(self.primary_color.to_gamma_srgb(), self.secondary_color.to_gamma_srgb()).widget_holder()],
|
||||
widgets: vec![WorkingColorsInput::new(self.primary_color.to_gamma_srgb(), self.secondary_color.to_gamma_srgb()).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
|
|
@ -127,12 +127,12 @@ impl DocumentToolData {
|
|||
.tooltip_label("Swap")
|
||||
.tooltip_shortcut(action_shortcut!(ToolMessageDiscriminant::SwapColors))
|
||||
.on_update(|_| ToolMessage::SwapColors.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
IconButton::new("WorkingColors", 16)
|
||||
.tooltip_label("Reset")
|
||||
.tooltip_shortcut(action_shortcut!(ToolMessageDiscriminant::ResetColors))
|
||||
.on_update(|_| ToolMessage::ResetColors.into())
|
||||
.widget_holder(),
|
||||
.widget_instance(),
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
@ -257,7 +257,7 @@ impl LayoutHolder for ToolData {
|
|||
.collect::<Vec<_>>()
|
||||
)
|
||||
.flat_map(|group| {
|
||||
let separator = std::iter::once(Separator::new(SeparatorType::Section).direction(SeparatorDirection::Vertical).widget_holder());
|
||||
let separator = std::iter::once(Separator::new(SeparatorType::Section).direction(SeparatorDirection::Vertical).widget_instance());
|
||||
let buttons = group.into_iter().map(|ToolEntry { tooltip_label, tooltip_description, tooltip_shortcut, tool_type, icon_name }| {
|
||||
let coming_soon = tooltip_description.contains("Coming soon.");
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ impl LayoutHolder for ToolData {
|
|||
}
|
||||
}
|
||||
})
|
||||
.widget_holder()
|
||||
.widget_instance()
|
||||
});
|
||||
|
||||
separator.chain(buttons)
|
||||
|
|
@ -297,7 +297,7 @@ impl LayoutHolder for ToolData {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, WidgetBuilder)]
|
||||
#[widget_builder(not_widget_holder)]
|
||||
#[widget_builder(not_widget_instance)]
|
||||
pub struct ToolEntry {
|
||||
#[widget_builder(constructor)]
|
||||
pub tool_type: ToolType,
|
||||
|
|
@ -522,27 +522,27 @@ impl HintData {
|
|||
|
||||
for (index, hint_group) in self.0.iter().enumerate() {
|
||||
if index > 0 {
|
||||
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
|
||||
widgets.push(Separator::new(SeparatorType::Section).widget_instance());
|
||||
}
|
||||
for hint in &hint_group.0 {
|
||||
if hint.plus {
|
||||
widgets.push(TextLabel::new("+").bold(true).widget_holder());
|
||||
widgets.push(TextLabel::new("+").bold(true).widget_instance());
|
||||
}
|
||||
if hint.slash {
|
||||
widgets.push(TextLabel::new("/").bold(true).widget_holder());
|
||||
widgets.push(TextLabel::new("/").bold(true).widget_instance());
|
||||
}
|
||||
|
||||
for shortcut in &hint.key_groups {
|
||||
widgets.push(ShortcutLabel::new(Some(ActionShortcut::Shortcut(shortcut.clone()))).widget_holder());
|
||||
widgets.push(ShortcutLabel::new(Some(ActionShortcut::Shortcut(shortcut.clone()))).widget_instance());
|
||||
}
|
||||
if let Some(mouse_movement) = &hint.mouse {
|
||||
let mouse_movement = LabeledShortcut(vec![LabeledKeyOrMouseMotion::MouseMotion(mouse_movement.clone())]);
|
||||
let shortcut = ActionShortcut::Shortcut(mouse_movement);
|
||||
widgets.push(ShortcutLabel::new(Some(shortcut)).widget_holder());
|
||||
widgets.push(ShortcutLabel::new(Some(shortcut)).widget_instance());
|
||||
}
|
||||
|
||||
if !hint.label.is_empty() {
|
||||
widgets.push(TextLabel::new(hint.label.clone()).widget_holder());
|
||||
widgets.push(TextLabel::new(hint.label.clone()).widget_instance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1465,22 +1465,22 @@ export class Widget {
|
|||
widgetId!: bigint;
|
||||
}
|
||||
|
||||
function hoistWidgetHolder(widgetHolder: any): Widget {
|
||||
const kind = Object.keys(widgetHolder.widget)[0];
|
||||
const props = widgetHolder.widget[kind];
|
||||
function hoistWidgetInstance(widgetInstance: any): Widget {
|
||||
const kind = Object.keys(widgetInstance.widget)[0];
|
||||
const props = widgetInstance.widget[kind];
|
||||
props.kind = kind;
|
||||
|
||||
if (kind === "PopoverButton") {
|
||||
props.popoverLayout = props.popoverLayout.map(createLayoutGroup);
|
||||
}
|
||||
|
||||
const { widgetId } = widgetHolder;
|
||||
const { widgetId } = widgetInstance;
|
||||
|
||||
return plainToClass(Widget, { props, widgetId });
|
||||
}
|
||||
|
||||
function hoistWidgetHolders(widgetHolders: any[]): Widget[] {
|
||||
return widgetHolders.map(hoistWidgetHolder);
|
||||
function hoistWidgetInstances(widgetInstance: any[]): Widget[] {
|
||||
return widgetInstance.map(hoistWidgetInstance);
|
||||
}
|
||||
|
||||
// WIDGET LAYOUT
|
||||
|
|
@ -1588,7 +1588,7 @@ function createWidgetDiff(diffs: any[]): WidgetDiff[] {
|
|||
return { widgetPath, newValue: createLayoutGroup(newValue.layoutGroup) };
|
||||
}
|
||||
if (newValue.widget) {
|
||||
return { widgetPath, newValue: hoistWidgetHolder(newValue.widget) };
|
||||
return { widgetPath, newValue: hoistWidgetInstance(newValue.widget) };
|
||||
}
|
||||
// This code should be unreachable
|
||||
throw new Error("DiffUpdate invalid");
|
||||
|
|
@ -1598,14 +1598,14 @@ function createWidgetDiff(diffs: any[]): WidgetDiff[] {
|
|||
// Unpacking a layout group
|
||||
function createLayoutGroup(layoutGroup: any): LayoutGroup {
|
||||
if (layoutGroup.column) {
|
||||
const columnWidgets = hoistWidgetHolders(layoutGroup.column.columnWidgets);
|
||||
const columnWidgets = hoistWidgetInstances(layoutGroup.column.columnWidgets);
|
||||
|
||||
const result: WidgetSpanColumn = { columnWidgets };
|
||||
return result;
|
||||
}
|
||||
|
||||
if (layoutGroup.row) {
|
||||
const result: WidgetSpanRow = { rowWidgets: hoistWidgetHolders(layoutGroup.row.rowWidgets) };
|
||||
const result: WidgetSpanRow = { rowWidgets: hoistWidgetInstances(layoutGroup.row.rowWidgets) };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1623,7 +1623,7 @@ function createLayoutGroup(layoutGroup: any): LayoutGroup {
|
|||
|
||||
if (layoutGroup.table) {
|
||||
const result: WidgetTable = {
|
||||
tableWidgets: layoutGroup.table.tableWidgets.map(hoistWidgetHolders),
|
||||
tableWidgets: layoutGroup.table.tableWidgets.map(hoistWidgetInstances),
|
||||
unstyled: layoutGroup.table.unstyled,
|
||||
};
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -102,16 +102,16 @@ pub fn derive_widget_builder_impl(input_item: TokenStream2) -> syn::Result<Token
|
|||
// Create functions based on each field
|
||||
let builder_functions = fields.iter().map(construct_builder).collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
// Check if this should not have the `widget_holder()` function due to a `#[widget_builder(not_widget_holder)]` attribute
|
||||
let widget_holder_fn = if !has_attribute(&input.attrs, "not_widget_holder") {
|
||||
// A doc comment for the widget_holder function
|
||||
let widget_holder_doc_comment = Literal::string(&format!("Wrap {struct_name_ident} as a WidgetHolder."));
|
||||
// Check if this should not have the `widget_instance()` function due to a `#[widget_builder(not_widget_instance)]` attribute
|
||||
let widget_instance_fn = if !has_attribute(&input.attrs, "not_widget_instance") {
|
||||
// A doc comment for the widget_instance function
|
||||
let widget_instance_doc_comment = Literal::string(&format!("Wrap {struct_name_ident} as a WidgetInstance."));
|
||||
|
||||
// Construct the `widget_holder` function
|
||||
// Construct the `widget_instance` function
|
||||
quote::quote! {
|
||||
#[doc = #widget_holder_doc_comment]
|
||||
pub fn widget_holder(self) -> crate::messages::layout::utility_types::layout_widget::WidgetHolder {
|
||||
crate::messages::layout::utility_types::layout_widget::WidgetHolder::new( crate::messages::layout::utility_types::layout_widget::Widget::#struct_name_ident(self))
|
||||
#[doc = #widget_instance_doc_comment]
|
||||
pub fn widget_instance(self) -> crate::messages::layout::utility_types::layout_widget::WidgetInstance {
|
||||
crate::messages::layout::utility_types::layout_widget::WidgetInstance::new( crate::messages::layout::utility_types::layout_widget::Widget::#struct_name_ident(self))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -156,7 +156,7 @@ pub fn derive_widget_builder_impl(input_item: TokenStream2) -> syn::Result<Token
|
|||
|
||||
#(#builder_functions)*
|
||||
|
||||
#widget_holder_fn
|
||||
#widget_instance_fn
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue