Organize the categories of widget component props

This commit is contained in:
Keavon Chambers
2025-12-23 21:23:13 -08:00
parent 6dea184b03
commit 63217feac6
50 changed files with 643 additions and 729 deletions
@@ -83,16 +83,16 @@ impl ToolColorOptions {
let mut widgets = vec![TextLabel::new(label_text).widget_instance()];
if !color_allow_none {
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Related).widget_instance());
widgets.push(reset.widget_instance());
widgets.push(Separator::new(SeparatorType::Related).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Related).widget_instance());
};
let entries = vec![
@@ -109,7 +109,7 @@ impl ToolColorOptions {
.collect();
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_instance());
widgets.push(Separator::new(SeparatorStyle::Related).widget_instance());
let fill_choice = match self.active_color() {
Some(color) => FillChoice::Solid(color.to_gamma_srgb()),
@@ -83,7 +83,7 @@ pub fn pivot_gizmo_type_widget(state: PivotGizmoState, source: PivotToolSource)
.into(),
})
.widget_instance(),
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
DropdownInput::new(vec![gizmo_type_entries])
.selected_index(Some(match state.gizmo_type {
PivotGizmoType::Pivot => 0,
@@ -108,7 +108,7 @@ impl LayoutHolder for BrushTool {
.unit(" px")
.on_update(|number_input: &NumberInput| BrushToolMessage::UpdateOptions { options: BrushToolMessageOptionsUpdate::Diameter(number_input.value.unwrap()) }.into())
.widget_instance(),
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
NumberInput::new(Some(self.options.hardness))
.label("Hardness")
.min(0.)
@@ -122,7 +122,7 @@ impl LayoutHolder for BrushTool {
.into()
})
.widget_instance(),
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
NumberInput::new(Some(self.options.flow))
.label("Flow")
.min(1.)
@@ -136,7 +136,7 @@ impl LayoutHolder for BrushTool {
.into()
})
.widget_instance(),
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
NumberInput::new(Some(self.options.spacing))
.label("Spacing")
.min(1.)
@@ -152,7 +152,7 @@ impl LayoutHolder for BrushTool {
.widget_instance(),
];
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
let draw_mode_entries: Vec<_> = [DrawMode::Draw, DrawMode::Erase, DrawMode::Restore]
.into_iter()
@@ -167,7 +167,7 @@ impl LayoutHolder for BrushTool {
.collect();
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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Related).widget_instance());
let blend_mode_entries: Vec<Vec<_>> = BlendMode::list()
.iter()
@@ -122,7 +122,7 @@ impl LayoutHolder for FreehandTool {
},
);
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(create_weight_widget(self.options.line_weight));
Layout(vec![LayoutGroup::Row { widgets }])
@@ -234,8 +234,8 @@ impl LayoutHolder for PathTool {
})
.widget_instance();
let related_seperator = Separator::new(SeparatorType::Related).widget_instance();
let unrelated_seperator = Separator::new(SeparatorType::Unrelated).widget_instance();
let related_seperator = Separator::new(SeparatorStyle::Related).widget_instance();
let unrelated_seperator = Separator::new(SeparatorStyle::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 {
@@ -178,7 +178,7 @@ impl LayoutHolder for PenTool {
},
);
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(create_weight_widget(self.options.line_weight));
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(
RadioInput::new(vec![
@@ -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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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,20 +248,20 @@ impl LayoutHolder for SelectTool {
// Align
let disabled = self.tool_data.selected_layers_count < 2;
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.extend(self.alignment_widgets(disabled));
// Flip
let disabled = self.tool_data.selected_layers_count == 0;
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.extend(self.flip_widgets(disabled));
// Turn
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.extend(self.turn_widgets(disabled));
// Boolean
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.extend(self.boolean_widgets(self.tool_data.selected_layers_count));
Layout(vec![LayoutGroup::Row { widgets }])
@@ -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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Related).widget_instance());
widgets.push(create_turns_widget(self.options.turns));
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(create_weight_widget(self.options.line_weight));
Layout(vec![LayoutGroup::Row { widgets }])
@@ -129,7 +129,7 @@ impl LayoutHolder for SplineTool {
},
);
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::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_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(create_weight_widget(self.options.line_weight));
Layout(vec![LayoutGroup::Row { widgets }])
@@ -215,13 +215,13 @@ fn create_text_widgets(tool: &TextTool, font_catalog: &FontCatalog) -> Vec<Widge
let align = RadioInput::new(align_entries).selected_index(Some(tool.options.align as u32)).widget_instance();
vec![
font,
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
style,
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
size,
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
line_height_ratio,
Separator::new(SeparatorType::Related).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
align,
]
}
@@ -243,7 +243,7 @@ impl TextTool {
fn layout(&self, font_catalog: &FontCatalog) -> Layout {
let mut widgets = create_text_widgets(self, font_catalog);
widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.append(&mut self.options.fill.create_widgets(
"Fill",
+3 -3
View File
@@ -278,11 +278,11 @@ impl ToolData {
)
.filter(|group| !group.is_empty())
.flat_map(|group| {
let separator = std::iter::once(Separator::new(SeparatorType::Section).direction(SeparatorDirection::Vertical).widget_instance());
let separator = std::iter::once(Separator::new(SeparatorStyle::Section).direction(SeparatorDirection::Vertical).widget_instance());
let buttons = group.into_iter().map(|ToolEntry { tooltip_label, tooltip_description, tooltip_shortcut, tool_type, icon_name }| {
IconButton::new(icon_name, 32)
.disabled(false)
.active(match tool_type {
.emphasized(match tool_type {
ToolType::Line | ToolType::Ellipse | ToolType::Rectangle => { self.active_shape_type.is_some() && active_tool == tool_type }
_ => active_tool == tool_type,
})
@@ -533,7 +533,7 @@ impl HintData {
for (index, hint_group) in self.0.iter().enumerate() {
if index > 0 {
widgets.push(Separator::new(SeparatorType::Section).widget_instance());
widgets.push(Separator::new(SeparatorStyle::Section).widget_instance());
}
for hint in &hint_group.0 {
if hint.plus {