mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 18:58:12 +08:00
Add properties panel entries for artboards (#572)
* Artboards can have properties * fix crash when renaming artboards * moved target document to utility types * moved import and added test for file version information * fixed missing import * fix error from merging * - typed properties message handler data - removed name from WidgetRow * clippy warnings * artboards have seperate properties section * - color input can be forced to have selection - crop tool shows on switch - select tool shows on switch * variable renamed * change to use PropType<boolean> instead of PropType<Boolean> * Add an artboard icon * Add the "Delete Artboard" hint * fix unselect glitch * even better * Remove the Transform properties group Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
ca28bc3947
commit
916a575446
@@ -1,4 +1,5 @@
|
||||
use crate::consts::SELECTION_TOLERANCE;
|
||||
use crate::document::utility_types::TargetDocument;
|
||||
use crate::document::DocumentMessageHandler;
|
||||
use crate::frontend::utility_types::MouseCursorIcon;
|
||||
use crate::input::keyboard::{Key, MouseMotion};
|
||||
@@ -125,6 +126,13 @@ impl Fsm for CropToolFsmState {
|
||||
data.bounding_box_overlays = Some(bounding_box_overlays);
|
||||
|
||||
responses.push_back(OverlaysMessage::Rerender.into());
|
||||
responses.push_back(
|
||||
PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: vec![vec![data.selected_board.unwrap()]],
|
||||
document: TargetDocument::Artboard,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
@@ -168,6 +176,14 @@ impl Fsm for CropToolFsmState {
|
||||
|
||||
data.snap_handler.start_snap(document, document.bounding_boxes(None, Some(intersection[0])), true, true);
|
||||
|
||||
responses.push_back(
|
||||
PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: vec![intersection.clone()],
|
||||
document: TargetDocument::Artboard,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
CropToolFsmState::Dragging
|
||||
} else {
|
||||
let id = generate_uuid();
|
||||
@@ -184,6 +200,8 @@ impl Fsm for CropToolFsmState {
|
||||
.into(),
|
||||
);
|
||||
|
||||
responses.push_back(PropertiesPanelMessage::ClearSelection.into());
|
||||
|
||||
CropToolFsmState::Drawing
|
||||
}
|
||||
}
|
||||
@@ -273,6 +291,16 @@ impl Fsm for CropToolFsmState {
|
||||
.into(),
|
||||
);
|
||||
|
||||
// Have to put message here instead of when Artboard is created
|
||||
// This might result in a few more calls but it is not reliant on the order of messages
|
||||
responses.push_back(
|
||||
PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: vec![vec![data.selected_board.unwrap()]],
|
||||
document: TargetDocument::Artboard,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
responses.push_back(ToolMessage::DocumentIsDirty.into());
|
||||
|
||||
CropToolFsmState::Drawing
|
||||
@@ -328,6 +356,15 @@ impl Fsm for CropToolFsmState {
|
||||
bounding_box_overlays.delete(responses);
|
||||
}
|
||||
|
||||
// Register properties when switching back to other tools
|
||||
responses.push_back(
|
||||
PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: document.selected_layers().map(|path| path.to_vec()).collect(),
|
||||
document: TargetDocument::Artwork,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
data.snap_handler.cleanup(responses);
|
||||
CropToolFsmState::Ready
|
||||
}
|
||||
@@ -353,6 +390,12 @@ impl Fsm for CropToolFsmState {
|
||||
label: String::from("Move Artboard"),
|
||||
plus: false,
|
||||
}]),
|
||||
HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::KeyBackspace])],
|
||||
mouse: None,
|
||||
label: String::from("Delete Artboard"),
|
||||
plus: false,
|
||||
}]),
|
||||
]),
|
||||
CropToolFsmState::Dragging => HintData(vec![HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::KeyShift])],
|
||||
|
||||
@@ -60,7 +60,6 @@ enum FreehandToolFsmState {
|
||||
impl PropertyHolder for FreehandTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
|
||||
@@ -61,7 +61,6 @@ pub enum LineOptionsUpdate {
|
||||
impl PropertyHolder for LineTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
|
||||
@@ -70,7 +70,6 @@ pub enum PenOptionsUpdate {
|
||||
impl PropertyHolder for PenTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
|
||||
@@ -60,7 +60,6 @@ pub enum SelectToolMessage {
|
||||
impl PropertyHolder for SelectTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![
|
||||
WidgetHolder::new(Widget::IconButton(IconButton {
|
||||
icon: "AlignLeft".into(),
|
||||
|
||||
@@ -59,7 +59,6 @@ pub enum ShapeOptionsUpdate {
|
||||
impl PropertyHolder for ShapeTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
label: "Sides".into(),
|
||||
value: self.options.vertices as f64,
|
||||
|
||||
@@ -64,7 +64,6 @@ pub enum SplineOptionsUpdate {
|
||||
impl PropertyHolder for SplineTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
|
||||
@@ -64,7 +64,6 @@ pub enum TextOptionsUpdate {
|
||||
impl PropertyHolder for TextTool {
|
||||
fn properties(&self) -> WidgetLayout {
|
||||
WidgetLayout::new(vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Font Size".into(),
|
||||
|
||||
Reference in New Issue
Block a user