Skip to content

Commit

Permalink
Merge branch 'master' into path_editing_clutter
Browse files Browse the repository at this point in the history
  • Loading branch information
4adex authored Feb 9, 2025
2 parents 818b0af + 0037f51 commit 0e5e56c
Show file tree
Hide file tree
Showing 76 changed files with 484 additions and 194 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"css-unused-selector": "ignore",
"vite-plugin-svelte-css-no-scopable-elements": "ignore",
"a11y-no-static-element-interactions": "ignore",
"a11y-no-noninteractive-element-interactions": "ignore"
"a11y-no-noninteractive-element-interactions": "ignore",
"a11y-click-events-have-key-events": "ignore"
},
// VS Code config
"html.format.wrapLineLength": 200,
Expand Down
16 changes: 12 additions & 4 deletions editor/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,18 @@ impl Dispatcher {
let ipp = &self.message_handlers.input_preprocessor_message_handler;
let preferences = &self.message_handlers.preferences_message_handler;
let current_tool = &self.message_handlers.tool_message_handler.tool_state.tool_data.active_tool_type;

self.message_handlers
.portfolio_message_handler
.process_message(message, &mut queue, PortfolioMessageData { ipp, preferences, current_tool });
let message_logging_verbosity = self.message_handlers.debug_message_handler.message_logging_verbosity;

self.message_handlers.portfolio_message_handler.process_message(
message,
&mut queue,
PortfolioMessageData {
ipp,
preferences,
current_tool,
message_logging_verbosity,
},
);
}
Message::Preferences(message) => {
self.message_handlers.preferences_message_handler.process_message(message, &mut queue, ());
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/debug/utility_types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, Default, Clone, Copy)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
pub enum MessageLoggingVerbosity {
#[default]
Off,
Expand Down
32 changes: 16 additions & 16 deletions editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ impl LayoutHolder for DemoArtworkDialog {
let mut rows_of_images_with_buttons: Vec<_> = ARTWORK
.chunks(3)
.flat_map(|chunk| {
let images = chunk.iter().map(|(_, thumbnail, _)| ImageLabel::new(*thumbnail).width(Some("256px".into())).widget_holder()).collect();
fn make_dialog(name: &str, filename: &str) -> Message {
DialogMessage::CloseDialogAndThen {
followups: vec![FrontendMessage::TriggerFetchAndOpenDocument {
name: name.to_string(),
filename: filename.to_string(),
}
.into()],
}
.into()
}

let images = chunk
.iter()
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width(Some("256px".into())).on_update(|_| make_dialog(name, filename)).widget_holder())
.collect();

let buttons = chunk
.iter()
.map(|(name, _, filename)| {
TextButton::new(*name)
.min_width(256)
.on_update(|_| {
DialogMessage::CloseDialogAndThen {
followups: vec![FrontendMessage::TriggerFetchAndOpenDocument {
name: name.to_string(),
filename: filename.to_string(),
}
.into()],
}
.into()
})
.widget_holder()
})
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_holder())
.collect();

vec![LayoutGroup::Row { widgets: images }, LayoutGroup::Row { widgets: buttons }, LayoutGroup::Row { widgets: vec![] }]
Expand Down
10 changes: 9 additions & 1 deletion editor/src/messages/layout/layout_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,18 @@ impl LayoutMessageHandler {
WidgetValueAction::Commit => (icon_button.on_commit.callback)(&()),
WidgetValueAction::Update => (icon_button.on_update.callback)(icon_button),
};

responses.add(callback_message);
}
Widget::ImageButton(image_label) => {
let callback_message = match action {
WidgetValueAction::Commit => (image_label.on_commit.callback)(&()),
WidgetValueAction::Update => (image_label.on_update.callback)(&()),
};

responses.add(callback_message);
}
Widget::IconLabel(_) => {}
Widget::ImageLabel(_) => {}
Widget::InvisibleStandinInput(invisible) => {
let callback_message = match action {
WidgetValueAction::Commit => (invisible.on_commit.callback)(&()),
Expand Down
6 changes: 3 additions & 3 deletions editor/src/messages/layout/utility_types/layout_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl LayoutGroup {
Widget::FontInput(x) => &mut x.tooltip,
Widget::IconButton(x) => &mut x.tooltip,
Widget::IconLabel(x) => &mut x.tooltip,
Widget::ImageLabel(x) => &mut x.tooltip,
Widget::ImageButton(x) => &mut x.tooltip,
Widget::NumberInput(x) => &mut x.tooltip,
Widget::ParameterExposeButton(x) => &mut x.tooltip,
Widget::PopoverButton(x) => &mut x.tooltip,
Expand Down Expand Up @@ -504,7 +504,7 @@ pub enum Widget {
FontInput(FontInput),
IconButton(IconButton),
IconLabel(IconLabel),
ImageLabel(ImageLabel),
ImageButton(ImageButton),
InvisibleStandinInput(InvisibleStandinInput),
NodeCatalog(NodeCatalog),
NumberInput(NumberInput),
Expand Down Expand Up @@ -579,8 +579,8 @@ impl DiffUpdate {
Widget::ParameterExposeButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
Widget::PopoverButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
Widget::TextButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
Widget::ImageButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
Widget::IconLabel(_)
| Widget::ImageLabel(_)
| Widget::CurveInput(_)
| Widget::InvisibleStandinInput(_)
| Widget::NodeCatalog(_)
Expand Down
26 changes: 26 additions & 0 deletions editor/src/messages/layout/utility_types/widgets/button_widgets.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
use crate::messages::tool::tool_messages::tool_prelude::WidgetCallback;

use graphene_std::vector::style::FillChoice;
use graphite_proc_macros::WidgetBuilder;
Expand Down Expand Up @@ -120,6 +121,31 @@ pub struct TextButton {
pub on_commit: WidgetCallback<()>,
}

#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
#[derivative(Debug, PartialEq)]
pub struct ImageButton {
#[widget_builder(constructor)]
pub image: String,

pub width: Option<String>,

pub height: Option<String>,

pub tooltip: String,

#[serde(skip)]
pub tooltip_shortcut: Option<ActionKeys>,

// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<()>,

#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
}

#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
#[derivative(Debug, PartialEq, Default)]
pub struct ColorButton {
Expand Down
15 changes: 3 additions & 12 deletions editor/src/messages/layout/utility_types/widgets/label_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ pub struct IconLabel {
pub tooltip: String,
}

#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder, specta::Type)]
pub struct ImageLabel {
#[widget_builder(constructor)]
pub image: String,

pub width: Option<String>,

pub height: Option<String>,

pub tooltip: String,
}

#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
pub struct Separator {
pub direction: SeparatorDirection,
Expand Down Expand Up @@ -55,6 +43,9 @@ pub struct TextLabel {

pub italic: bool,

#[serde(rename = "centerAlign")]
pub center_align: bool,

#[serde(rename = "tableAlign")]
pub table_align: bool,

Expand Down
3 changes: 1 addition & 2 deletions editor/src/messages/portfolio/document/document_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ pub enum DocumentMessage {
axis: AlignAxis,
aggregate: AlignAggregate,
},
ClearArtboards,
RemoveArtboards,
ClearLayersPanel,
CreateEmptyFolder,
DebugPrintDocument,
DeleteNode {
node_id: NodeId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
});
}
}
DocumentMessage::ClearArtboards => {
responses.add(GraphOperationMessage::ClearArtboards);
DocumentMessage::RemoveArtboards => {
responses.add(GraphOperationMessage::RemoveArtboards);
}
DocumentMessage::ClearLayersPanel => {
// Send an empty layer list
Expand Down Expand Up @@ -305,9 +305,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
});
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![id] });
}
DocumentMessage::DebugPrintDocument => {
info!("{:?}", self.network_interface);
}
DocumentMessage::DeleteNode { node_id } => {
responses.add(DocumentMessage::StartTransaction);

Expand Down Expand Up @@ -1337,7 +1334,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
fn actions(&self) -> ActionList {
let mut common = actions!(DocumentMessageDiscriminant;
CreateEmptyFolder,
DebugPrintDocument,
DeselectAllLayers,
GraphViewOverlayToggle,
Noop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub enum GraphOperationMessage {
location: IVec2,
dimensions: IVec2,
},
ClearArtboards,
RemoveArtboards,
NewSvg {
id: NodeId,
svg: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageData<'_>> for Gr
modify_inputs.resize_artboard(location, dimensions);
}
}
GraphOperationMessage::ClearArtboards => {
GraphOperationMessage::RemoveArtboards => {
if network_interface.all_artboards().is_empty() {
return;
}
Expand Down
Loading

0 comments on commit 0e5e56c

Please sign in to comment.