mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 01:58:11 +08:00
Rename WidgetHolder to WidgetInstance
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user