Remove widgets built by methods on WidgetHolder

This commit is contained in:
Keavon Chambers
2023-07-31 23:36:12 -07:00
parent de27f2c006
commit 8e87e42f3e
21 changed files with 270 additions and 264 deletions
@@ -1,5 +1,5 @@
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
use crate::messages::layout::utility_types::widget_prelude::{ColorInput, IconButton, RadioEntryData, RadioInput, TextLabel, WidgetHolder};
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::Message;
use graphene_core::Color;
@@ -71,16 +71,16 @@ impl ToolColorOptions {
let mut widgets = vec![TextLabel::new(label_text).widget_holder()];
if !color_allow_none {
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
} else {
let reset = IconButton::new("CloseX", 12)
.disabled(self.custom_color.is_none() && self.color_type == ToolColorType::Custom)
.tooltip("Clear Color")
.on_update(reset_callback);
widgets.push(WidgetHolder::related_separator());
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
widgets.push(reset.widget_holder());
widgets.push(WidgetHolder::related_separator());
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
};
let entries = vec![
@@ -97,7 +97,7 @@ impl ToolColorOptions {
.collect();
let radio = RadioInput::new(entries).selected_index(self.color_type.clone() as u32).widget_holder();
widgets.push(radio);
widgets.push(WidgetHolder::related_separator());
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
let color_input = ColorInput::new(self.active_color()).allow_none(color_allow_none).on_update(color_callback);
widgets.push(color_input.widget_holder());
@@ -150,7 +150,7 @@ impl PropertyHolder for BrushTool {
.unit(" px")
.on_update(|number_input: &NumberInput| BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::Diameter(number_input.value.unwrap())).into())
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
NumberInput::new(Some(self.options.hardness))
.label("Hardness")
.min(0.)
@@ -158,7 +158,7 @@ impl PropertyHolder for BrushTool {
.unit("%")
.on_update(|number_input: &NumberInput| BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::Hardness(number_input.value.unwrap())).into())
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
NumberInput::new(Some(self.options.flow))
.label("Flow")
.min(1.)
@@ -166,7 +166,7 @@ impl PropertyHolder for BrushTool {
.unit("%")
.on_update(|number_input: &NumberInput| BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::Flow(number_input.value.unwrap())).into())
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
NumberInput::new(Some(self.options.spacing))
.label("Spacing")
.min(1.)
@@ -176,7 +176,7 @@ impl PropertyHolder for BrushTool {
.widget_holder(),
];
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
let draw_mode_entries: Vec<_> = [DrawMode::Draw, DrawMode::Erase, DrawMode::Restore]
.into_iter()
@@ -184,7 +184,7 @@ impl PropertyHolder for BrushTool {
.collect();
widgets.push(RadioInput::new(draw_mode_entries).selected_index(self.options.draw_mode as u32).widget_holder());
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.color.create_widgets(
"Color",
@@ -194,7 +194,7 @@ impl PropertyHolder for BrushTool {
|color: &ColorInput| BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::Color(color.value)).into(),
));
widgets.push(WidgetHolder::related_separator());
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
let blend_mode_entries: Vec<Vec<_>> = EXPOSED_BLEND_MODES
.iter()
@@ -2,7 +2,7 @@ use crate::messages::frontend::utility_types::MouseCursorIcon;
use crate::messages::input_mapper::utility_types::input_keyboard::{Key, MouseMotion};
use crate::messages::layout::utility_types::layout_widget::{Layout, LayoutGroup, PropertyHolder, WidgetCallback, WidgetLayout};
use crate::messages::layout::utility_types::misc::LayoutTarget;
use crate::messages::layout::utility_types::widget_prelude::{ColorInput, NumberInput, WidgetHolder};
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::*;
use crate::messages::tool::common_functionality::color_selector::{ToolColorOptions, ToolColorType};
use crate::messages::tool::common_functionality::graph_modification_utils;
@@ -101,7 +101,7 @@ impl PropertyHolder for EllipseTool {
|color: &ColorInput| EllipseToolMessage::UpdateOptions(EllipseOptionsUpdate::FillColor(color.value)).into(),
);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -110,7 +110,7 @@ impl PropertyHolder for EllipseTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| EllipseToolMessage::UpdateOptions(EllipseOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| EllipseToolMessage::UpdateOptions(EllipseOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -105,7 +105,7 @@ impl PropertyHolder for FreehandTool {
|color: &ColorInput| FreehandToolMessage::UpdateOptions(FreehandOptionsUpdate::FillColor(color.value)).into(),
);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -114,7 +114,7 @@ impl PropertyHolder for FreehandTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| FreehandToolMessage::UpdateOptions(FreehandOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| FreehandToolMessage::UpdateOptions(FreehandOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -99,7 +99,7 @@ impl PropertyHolder for LineTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| LineToolMessage::UpdateOptions(LineOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| LineToolMessage::UpdateOptions(LineOptionsUpdate::StrokeColor(color.value)).into(),
);
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -124,7 +124,7 @@ impl PropertyHolder for PenTool {
|color: &ColorInput| PenToolMessage::UpdateOptions(PenOptionsUpdate::FillColor(color.value)).into(),
);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -133,7 +133,7 @@ impl PropertyHolder for PenTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| PenToolMessage::UpdateOptions(PenOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| PenToolMessage::UpdateOptions(PenOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -87,7 +87,7 @@ impl PropertyHolder for RectangleTool {
|color: &ColorInput| RectangleToolMessage::UpdateOptions(RectangleOptionsUpdate::FillColor(color.value)).into(),
);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -96,7 +96,7 @@ impl PropertyHolder for RectangleTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| RectangleToolMessage::UpdateOptions(RectangleOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| RectangleToolMessage::UpdateOptions(RectangleOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -133,13 +133,13 @@ impl PropertyHolder for SelectTool {
.selected_index(Some((self.tool_data.nested_selection_behavior == NestedSelectionBehavior::Shallowest) as u32))
.tooltip("Choose if clicking nested layers directly selects the deepest, or selects the shallowest and deepens by double clicking")
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
// We'd like this widget to hide and show itself whenever the transformation cage is active or inactive (i.e. when no layers are selected)
PivotAssist::new(self.tool_data.pivot.to_pivot_position())
.disabled(deactivate_pivot)
.on_update(|pivot_assist: &PivotAssist| SelectToolMessage::SetPivot { position: pivot_assist.position }.into())
.widget_holder(),
WidgetHolder::section_separator(),
Separator::new(SeparatorType::Section).widget_holder(),
IconButton::new("AlignLeft", 24)
.tooltip("Align Left")
.disabled(deactivate_alignment)
@@ -173,7 +173,7 @@ impl PropertyHolder for SelectTool {
.into()
})
.widget_holder(),
WidgetHolder::unrelated_separator(),
Separator::new(SeparatorType::Unrelated).widget_holder(),
IconButton::new("AlignTop", 24)
.tooltip("Align Top")
.disabled(deactivate_alignment)
@@ -207,9 +207,9 @@ impl PropertyHolder for SelectTool {
.into()
})
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
PopoverButton::new("Align", "Coming soon").widget_holder(),
WidgetHolder::section_separator(),
Separator::new(SeparatorType::Section).widget_holder(),
IconButton::new("FlipHorizontal", 24)
.tooltip("Flip Horizontal")
.on_update(|_| SelectToolMessage::FlipHorizontal.into())
@@ -218,9 +218,9 @@ impl PropertyHolder for SelectTool {
.tooltip("Flip Vertical")
.on_update(|_| SelectToolMessage::FlipVertical.into())
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
PopoverButton::new("Flip", "Coming soon").widget_holder(),
WidgetHolder::section_separator(),
Separator::new(SeparatorType::Section).widget_holder(),
IconButton::new("BooleanUnion", 24)
.tooltip("Boolean Union (coming soon)")
.on_update(|_| DialogMessage::RequestComingSoonDialog { issue: Some(1091) }.into())
@@ -241,7 +241,7 @@ impl PropertyHolder for SelectTool {
.tooltip("Boolean Difference (coming soon)")
.on_update(|_| DialogMessage::RequestComingSoonDialog { issue: Some(1091) }.into())
.widget_holder(),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
PopoverButton::new("Boolean", "Coming soon").widget_holder(),
],
}]))
@@ -125,11 +125,11 @@ impl PropertyHolder for ShapeTool {
fn properties(&self) -> Layout {
let mut widgets = vec![
create_star_option_widget(self.options.primitive_shape_type),
WidgetHolder::related_separator(),
Separator::new(SeparatorType::Related).widget_holder(),
create_sides_widget(self.options.vertices),
];
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.fill.create_widgets(
"Fill",
@@ -139,7 +139,7 @@ impl PropertyHolder for ShapeTool {
|color: &ColorInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::FillColor(color.value)).into(),
));
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -148,7 +148,7 @@ impl PropertyHolder for ShapeTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -108,7 +108,7 @@ impl PropertyHolder for SplineTool {
|color: &ColorInput| SplineToolMessage::UpdateOptions(SplineOptionsUpdate::FillColor(color.value)).into(),
);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.stroke.create_widgets(
"Stroke",
@@ -117,7 +117,7 @@ impl PropertyHolder for SplineTool {
|color_type: ToolColorType| WidgetCallback::new(move |_| SplineToolMessage::UpdateOptions(SplineOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|color: &ColorInput| SplineToolMessage::UpdateOptions(SplineOptionsUpdate::StrokeColor(color.value)).into(),
));
widgets.push(WidgetHolder::unrelated_separator());
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
widgets.push(create_weight_widget(self.options.line_weight));
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
@@ -125,14 +125,20 @@ fn create_text_widgets(tool: &TextTool) -> Vec<WidgetHolder> {
.min(1.)
.on_update(|number_input: &NumberInput| TextToolMessage::UpdateOptions(TextOptionsUpdate::FontSize(number_input.value.unwrap() as u32)).into())
.widget_holder();
vec![font, WidgetHolder::related_separator(), style, WidgetHolder::related_separator(), size]
vec![
font,
Separator::new(SeparatorType::Related).widget_holder(),
style,
Separator::new(SeparatorType::Related).widget_holder(),
size,
]
}
impl PropertyHolder for TextTool {
fn properties(&self) -> Layout {
let mut widgets = create_text_widgets(self);
widgets.push(WidgetHolder::section_separator());
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
widgets.append(&mut self.options.fill.create_widgets(
"Fill",
+1 -1
View File
@@ -256,7 +256,7 @@ impl PropertyHolder for ToolData {
}
}).collect::<Vec<_>>())
.flat_map(|group| {
let separator = std::iter::once(Separator::new(SeparatorDirection::Vertical, SeparatorType::Section).widget_holder());
let separator = std::iter::once(Separator::new(SeparatorType::Section).direction(SeparatorDirection::Vertical).widget_holder());
let buttons = group.into_iter().map(|ToolEntry { tooltip, tooltip_shortcut, tool_type, icon_name }| {
IconButton::new(icon_name, 32)
.disabled( false)