mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 07:48:12 +08:00
Consolidate MenuListButton into TextButton (#1470)
This commit is contained in:
@@ -95,7 +95,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
let index = export_area_options.iter().position(|(val, _, _)| val == &self.bounds).unwrap();
|
||||
let entries = vec![export_area_options
|
||||
.into_iter()
|
||||
.map(|(val, name, disabled)| DropdownEntryData::new(name).on_update(move |_| ExportDialogMessage::ExportBounds(val).into()).disabled(disabled))
|
||||
.map(|(val, name, disabled)| MenuListEntry::new(name).on_update(move |_| ExportDialogMessage::ExportBounds(val).into()).disabled(disabled))
|
||||
.collect()];
|
||||
|
||||
let export_area = vec![
|
||||
|
||||
@@ -100,6 +100,9 @@ pub struct TextButton {
|
||||
#[serde(skip)]
|
||||
pub tooltip_shortcut: Option<ActionKeys>,
|
||||
|
||||
#[serde(rename = "menuListChildren")]
|
||||
pub menu_list_children: MenuListEntrySections,
|
||||
|
||||
// Callbacks
|
||||
#[serde(skip)]
|
||||
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Default for CheckboxInput {
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct DropdownInput {
|
||||
#[widget_builder(constructor)]
|
||||
pub entries: DropdownInputEntries,
|
||||
pub entries: MenuListEntrySections,
|
||||
|
||||
// This uses `u32` instead of `usize` since it will be serialized as a normal JS number (replace this with `usize` after switching to a Rust-based GUI)
|
||||
#[serde(rename = "selectedIndex")]
|
||||
@@ -68,15 +68,15 @@ pub struct DropdownInput {
|
||||
pub tooltip_shortcut: Option<ActionKeys>,
|
||||
//
|
||||
// Callbacks
|
||||
// `on_update` exists on the `DropdownEntryData`, not this parent `DropdownInput`
|
||||
// `on_update` exists on the `MenuListEntry`, not this parent `DropdownInput`
|
||||
}
|
||||
|
||||
pub type DropdownInputEntries = Vec<Vec<DropdownEntryData>>;
|
||||
pub type MenuListEntrySections = Vec<Vec<MenuListEntry>>;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
#[widget_builder(not_widget_holder)]
|
||||
pub struct DropdownEntryData {
|
||||
pub struct MenuListEntry {
|
||||
pub value: String,
|
||||
|
||||
#[widget_builder(constructor)]
|
||||
@@ -91,7 +91,7 @@ pub struct DropdownEntryData {
|
||||
|
||||
pub disabled: bool,
|
||||
|
||||
pub children: DropdownInputEntries,
|
||||
pub children: MenuListEntrySections,
|
||||
|
||||
// Callbacks
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -1590,11 +1590,11 @@ impl DocumentMessageHandler {
|
||||
widgets: vec![
|
||||
DropdownInput::new(
|
||||
vec![vec![
|
||||
DropdownEntryData::new(DocumentMode::DesignMode.to_string()).icon(DocumentMode::DesignMode.icon_name()),
|
||||
DropdownEntryData::new(DocumentMode::SelectMode.to_string())
|
||||
MenuListEntry::new(DocumentMode::DesignMode.to_string()).icon(DocumentMode::DesignMode.icon_name()),
|
||||
MenuListEntry::new(DocumentMode::SelectMode.to_string())
|
||||
.icon(DocumentMode::SelectMode.icon_name())
|
||||
.on_update(|_| DialogMessage::RequestComingSoonDialog { issue: Some(330) }.into()),
|
||||
DropdownEntryData::new(DocumentMode::GuideMode.to_string())
|
||||
MenuListEntry::new(DocumentMode::GuideMode.to_string())
|
||||
.icon(DocumentMode::GuideMode.icon_name())
|
||||
.on_update(|_| DialogMessage::RequestComingSoonDialog { issue: Some(331) }.into()),
|
||||
]])
|
||||
@@ -1662,7 +1662,7 @@ impl DocumentMessageHandler {
|
||||
modes
|
||||
.iter()
|
||||
.map(|mode| {
|
||||
DropdownEntryData::new(mode.to_string())
|
||||
MenuListEntry::new(mode.to_string())
|
||||
.value(mode.to_string())
|
||||
.on_update(|_| DocumentMessage::SetBlendModeForSelectedLayers { blend_mode: *mode }.into())
|
||||
})
|
||||
|
||||
+7
-7
@@ -333,7 +333,7 @@ fn color_channel(document_node: &DocumentNode, node_id: u64, index: usize, name:
|
||||
let calculation_modes = [RedGreenBlue::Red, RedGreenBlue::Green, RedGreenBlue::Blue];
|
||||
let mut entries = Vec::with_capacity(calculation_modes.len());
|
||||
for method in calculation_modes {
|
||||
entries.push(DropdownEntryData::new(method.to_string()).on_update(update_value(move |_| TaggedValue::RedGreenBlue(method), node_id, index)));
|
||||
entries.push(MenuListEntry::new(method.to_string()).on_update(update_value(move |_| TaggedValue::RedGreenBlue(method), node_id, index)));
|
||||
}
|
||||
let entries = vec![entries];
|
||||
|
||||
@@ -356,7 +356,7 @@ fn noise_type(document_node: &DocumentNode, node_id: u64, index: usize, name: &s
|
||||
let calculation_modes = NoiseType::list();
|
||||
let mut entries = Vec::with_capacity(calculation_modes.len());
|
||||
for method in calculation_modes {
|
||||
entries.push(DropdownEntryData::new(method.to_string()).on_update(update_value(move |_| TaggedValue::NoiseType(method), node_id, index)));
|
||||
entries.push(MenuListEntry::new(method.to_string()).on_update(update_value(move |_| TaggedValue::NoiseType(method), node_id, index)));
|
||||
}
|
||||
let entries = vec![entries];
|
||||
|
||||
@@ -381,7 +381,7 @@ fn blend_mode(document_node: &DocumentNode, node_id: u64, index: usize, name: &s
|
||||
.map(|category| {
|
||||
category
|
||||
.iter()
|
||||
.map(|mode| DropdownEntryData::new(mode.to_string()).on_update(update_value(move |_| TaggedValue::BlendMode(*mode), node_id, index)))
|
||||
.map(|mode| MenuListEntry::new(mode.to_string()).on_update(update_value(move |_| TaggedValue::BlendMode(*mode), node_id, index)))
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
@@ -405,7 +405,7 @@ fn luminance_calculation(document_node: &DocumentNode, node_id: u64, index: usiz
|
||||
let calculation_modes = LuminanceCalculation::list();
|
||||
let mut entries = Vec::with_capacity(calculation_modes.len());
|
||||
for method in calculation_modes {
|
||||
entries.push(DropdownEntryData::new(method.to_string()).on_update(update_value(move |_| TaggedValue::LuminanceCalculation(method), node_id, index)));
|
||||
entries.push(MenuListEntry::new(method.to_string()).on_update(update_value(move |_| TaggedValue::LuminanceCalculation(method), node_id, index)));
|
||||
}
|
||||
let entries = vec![entries];
|
||||
|
||||
@@ -955,7 +955,7 @@ pub fn adjust_selective_color_properties(document_node: &DocumentNode, node_id:
|
||||
.map(|section| {
|
||||
section
|
||||
.iter()
|
||||
.map(|choice| DropdownEntryData::new(choice.to_string()).on_update(update_value(move |_| TaggedValue::SelectiveColorChoice(*choice), node_id, colors_index)))
|
||||
.map(|choice| MenuListEntry::new(choice.to_string()).on_update(update_value(move |_| TaggedValue::SelectiveColorChoice(*choice), node_id, colors_index)))
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
@@ -1577,7 +1577,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let sampling_methods = ImaginateSamplingMethod::list();
|
||||
let mut entries = Vec::with_capacity(sampling_methods.len());
|
||||
for method in sampling_methods {
|
||||
entries.push(DropdownEntryData::new(method.to_string()).on_update(update_value(move |_| TaggedValue::ImaginateSamplingMethod(method), node_id, sampling_method_index)));
|
||||
entries.push(MenuListEntry::new(method.to_string()).on_update(update_value(move |_| TaggedValue::ImaginateSamplingMethod(method), node_id, sampling_method_index)));
|
||||
}
|
||||
let entries = vec![entries];
|
||||
|
||||
@@ -1730,7 +1730,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let mask_fill_content_modes = ImaginateMaskStartingFill::list();
|
||||
let mut entries = Vec::with_capacity(mask_fill_content_modes.len());
|
||||
for mode in mask_fill_content_modes {
|
||||
entries.push(DropdownEntryData::new(mode.to_string()).on_update(update_value(move |_| TaggedValue::ImaginateMaskStartingFill(mode), node_id, mask_fill_index)));
|
||||
entries.push(MenuListEntry::new(mode.to_string()).on_update(update_value(move |_| TaggedValue::ImaginateMaskStartingFill(mode), node_id, mask_fill_index)));
|
||||
}
|
||||
let entries = vec![entries];
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ impl LayoutHolder for BrushTool {
|
||||
group
|
||||
.iter()
|
||||
.map(|blend_mode| {
|
||||
DropdownEntryData::new(format!("{blend_mode}"))
|
||||
MenuListEntry::new(format!("{blend_mode}"))
|
||||
.value(format!("{blend_mode:?}"))
|
||||
.on_update(|_| BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::BlendMode(*blend_mode)).into())
|
||||
})
|
||||
|
||||
@@ -103,7 +103,7 @@ impl SelectTool {
|
||||
// let layer_selection_behavior_entries = [NestedSelectionBehavior::Deepest, NestedSelectionBehavior::Shallowest]
|
||||
// .iter()
|
||||
// .map(|mode| {
|
||||
// DropdownEntryData::new(mode.to_string())
|
||||
// MenuListEntry::new(mode.to_string())
|
||||
// .value(mode.to_string())
|
||||
// .on_update(move |_| SelectToolMessage::SelectOptions(SelectOptionsUpdate::NestedSelectionBehavior(*mode)).into())
|
||||
// })
|
||||
|
||||
Reference in New Issue
Block a user