Skip to content

Commit 74aa907

Browse files
committed
fix: pin only if moved in first place
1 parent 1e8f486 commit 74aa907

5 files changed

Lines changed: 18 additions & 20 deletions

File tree

editor/src/consts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ pub const SCALE_EFFECT: f64 = 0.5;
134134

135135
// COLORS
136136
pub const COLOR_OVERLAY_BLUE: &str = "#00a8ff";
137-
pub const COLOR_OVERLAY_BLUE_50: &str = "rgba(0, 168, 255, 0.5)";
138137
pub const COLOR_OVERLAY_YELLOW: &str = "#ffc848";
139138
pub const COLOR_OVERLAY_GREEN: &str = "#63ce63";
140139
pub const COLOR_OVERLAY_RED: &str = "#ef5454";

editor/src/messages/portfolio/document/overlays/utility_types.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::utility_functions::overlay_canvas_context;
22
use crate::consts::{
3-
COLOR_OVERLAY_BLUE, COLOR_OVERLAY_BLUE_50, COLOR_OVERLAY_GREEN, COLOR_OVERLAY_RED, COLOR_OVERLAY_WHITE, COLOR_OVERLAY_YELLOW, COMPASS_ROSE_ARROW_SIZE, COMPASS_ROSE_HOVER_RING_DIAMETER,
3+
COLOR_OVERLAY_BLUE, COLOR_OVERLAY_GREEN, COLOR_OVERLAY_ORANGE, COLOR_OVERLAY_RED, COLOR_OVERLAY_WHITE, COLOR_OVERLAY_YELLOW, COMPASS_ROSE_ARROW_SIZE, COMPASS_ROSE_HOVER_RING_DIAMETER,
44
COMPASS_ROSE_MAIN_RING_DIAMETER, COMPASS_ROSE_RING_INNER_DIAMETER, DOWEL_PIN_RADIUS, MANIPULATOR_GROUP_MARKER_SIZE, PIVOT_CROSSHAIR_LENGTH, PIVOT_CROSSHAIR_THICKNESS, PIVOT_DIAMETER,
55
};
66
use crate::messages::prelude::Message;
@@ -431,10 +431,7 @@ impl OverlayContext {
431431

432432
pub fn draw_scale(&mut self, start: DVec2, scale: f64, radius: f64, text: &str) {
433433
let sign = scale.signum();
434-
let mut fill_color = graphene_std::Color::from_rgb_str(crate::consts::COLOR_OVERLAY_WHITE.strip_prefix('#').unwrap())
435-
.unwrap()
436-
.with_alpha(0.05)
437-
.to_rgba_hex_srgb();
434+
let mut fill_color = Color::from_rgb_str(COLOR_OVERLAY_WHITE.strip_prefix('#').unwrap()).unwrap().with_alpha(0.05).to_rgba_hex_srgb();
438435
fill_color.insert(0, '#');
439436
let fill_color = Some(fill_color.as_str());
440437
self.line(start + DVec2::X * radius * sign, start + DVec2::X * (radius * scale), None, None);
@@ -471,10 +468,7 @@ impl OverlayContext {
471468

472469
// Hover ring
473470
if show_hover_ring {
474-
let mut fill_color = graphene_std::Color::from_rgb_str(COLOR_OVERLAY_BLUE.strip_prefix('#').unwrap())
475-
.unwrap()
476-
.with_alpha(0.5)
477-
.to_rgba_hex_srgb();
471+
let mut fill_color = Color::from_rgb_str(COLOR_OVERLAY_BLUE.strip_prefix('#').unwrap()).unwrap().with_alpha(0.5).to_rgba_hex_srgb();
478472
fill_color.insert(0, '#');
479473

480474
self.render_context.set_line_width(HOVER_RING_STROKE_WIDTH);
@@ -560,7 +554,7 @@ impl OverlayContext {
560554

561555
pub fn dowel_pin(&mut self, position: DVec2, angle: f64, color: Option<&str>) {
562556
let (x, y) = (position.round() - DVec2::splat(0.5)).into();
563-
let color = color.unwrap_or(COLOR_OVERLAY_YELLOW);
557+
let color = color.unwrap_or(COLOR_OVERLAY_ORANGE);
564558

565559
self.start_dpi_aware_transform();
566560

@@ -637,9 +631,11 @@ impl OverlayContext {
637631
pub fn outline_overlay_bezier(&mut self, bezier: Bezier, transform: DAffine2) {
638632
self.start_dpi_aware_transform();
639633

634+
let color = Color::from_rgb_str(COLOR_OVERLAY_BLUE.strip_prefix('#').unwrap()).unwrap().with_alpha(0.05).to_rgba_hex_srgb();
635+
640636
self.render_context.begin_path();
641637
self.bezier_command(bezier, transform, true);
642-
self.render_context.set_stroke_style_str(COLOR_OVERLAY_BLUE_50);
638+
self.render_context.set_stroke_style_str(&color);
643639
self.render_context.set_line_width(4.);
644640
self.render_context.stroke();
645641

editor/src/messages/tool/common_functionality/pivot.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ use glam::{DAffine2, DVec2};
1212
use graphene_std::{transform::ReferencePoint, vector::ManipulatorPointId};
1313
use std::fmt;
1414

15-
pub fn pin_pivot_widget(disabled: bool, source: Source) -> WidgetHolder {
16-
IconButton::new(if disabled { "PinInactive" } else { "PinActive" }, 24)
17-
.tooltip(if disabled { "Pin Transform Pivot" } else { "Unpin Transform Pivot" })
15+
pub fn pin_pivot_widget(inactive: bool, enabled: bool, source: Source) -> WidgetHolder {
16+
IconButton::new(if inactive { "PinInactive" } else { "PinActive" }, 24)
17+
.tooltip(if inactive { "Pin Transform Pivot" } else { "Unpin Transform Pivot" })
1818
.on_update(move |_| match source {
19-
Source::Select => SelectToolMessage::SelectOptions(SelectOptionsUpdate::TogglePivotPinned()).into(),
20-
Source::Path => PathToolMessage::UpdateOptions(PathOptionsUpdate::TogglePivotPinned()).into(),
19+
Source::Select if enabled => SelectToolMessage::SelectOptions(SelectOptionsUpdate::TogglePivotPinned()).into(),
20+
Source::Path if enabled => PathToolMessage::UpdateOptions(PathOptionsUpdate::TogglePivotPinned()).into(),
21+
_ => Message::NoOp
2122
})
2223
.widget_holder()
2324
}

editor/src/messages/tool/tool_messages/path_tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl LayoutHolder for PathTool {
271271
let has_somrthing = !self.tool_data.saved_points_before_anchor_convert_smooth_sharp.is_empty();
272272
let _pivot_reference = pivot_reference_point_widget(has_somrthing || !self.tool_data.dot.state.is_pivot(), self.tool_data.dot.pivot.to_pivot_position(), Source::Path);
273273

274-
let _pin_pivot = pin_pivot_widget(self.tool_data.dot.pin_inactive(), Source::Path);
274+
let _pin_pivot = pin_pivot_widget(self.tool_data.dot.pin_inactive(), false, Source::Path);
275275

276276
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row {
277277
widgets: vec![

editor/src/messages/tool/tool_messages/select_tool.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ impl LayoutHolder for SelectTool {
214214

215215
// Pivot pin
216216
widgets.push(Separator::new(SeparatorType::Related).widget_holder());
217-
widgets.push(pin_pivot_widget(self.tool_data.dot.pin_inactive(), Source::Select));
217+
218+
let pin_enabled = self.tool_data.dot.pivot.old_pivot_position == ReferencePoint::None;
219+
widgets.push(pin_pivot_widget(self.tool_data.dot.pin_inactive(), pin_enabled, Source::Select));
218220

219221
// Align
220222
let disabled = self.tool_data.selected_layers_count < 2;
@@ -807,7 +809,7 @@ impl Fsm for SelectToolFsmState {
807809
}
808810
}
809811
if let Some(origin) = active_origin {
810-
overlay_context.dowel_pin(origin, origin_angle, Some(COLOR_OVERLAY_ORANGE));
812+
overlay_context.dowel_pin(origin, origin_angle, Some(COLOR_OVERLAY_YELLOW));
811813
}
812814

813815
let has_layers = document.network_interface.selected_nodes().has_selected_nodes();

0 commit comments

Comments
 (0)