Skip to content

Commit 54894c5

Browse files
Merge branch 'master' into desktop-tell-cef-to-use-wayland-if-available
2 parents d3023f5 + 66cd7a3 commit 54894c5

45 files changed

Lines changed: 1238 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

editor/src/consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ pub const POINT_RADIUS_HANDLE_SNAP_THRESHOLD: f64 = 8.;
126126
pub const POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD: f64 = 7.9;
127127
pub const NUMBER_OF_POINTS_DIAL_SPOKE_EXTENSION: f64 = 1.2;
128128
pub const NUMBER_OF_POINTS_DIAL_SPOKE_LENGTH: f64 = 10.;
129+
pub const ARC_SNAP_THRESHOLD: f64 = 5.;
130+
pub const ARC_SWEEP_GIZMO_RADIUS: f64 = 14.;
131+
pub const ARC_SWEEP_GIZMO_TEXT_HEIGHT: f64 = 12.;
129132
pub const GIZMO_HIDE_THRESHOLD: f64 = 20.;
130133

131134
// SCROLLBARS

editor/src/dispatcher.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Dispatcher {
1414
#[derive(Debug, Default)]
1515
pub struct DispatcherMessageHandlers {
1616
animation_message_handler: AnimationMessageHandler,
17+
app_window_message_handler: AppWindowMessageHandler,
1718
broadcast_message_handler: BroadcastMessageHandler,
1819
debug_message_handler: DebugMessageHandler,
1920
dialog_message_handler: DialogMessageHandler,
@@ -129,6 +130,9 @@ impl Dispatcher {
129130
Message::Animation(message) => {
130131
self.message_handlers.animation_message_handler.process_message(message, &mut queue, ());
131132
}
133+
Message::AppWindow(message) => {
134+
self.message_handlers.app_window_message_handler.process_message(message, &mut queue, ());
135+
}
132136
Message::Broadcast(message) => self.message_handlers.broadcast_message_handler.process_message(message, &mut queue, ()),
133137
Message::Debug(message) => {
134138
self.message_handlers.debug_message_handler.process_message(message, &mut queue, ());
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use crate::messages::prelude::*;
2+
3+
#[impl_message(Message, AppWindow)]
4+
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
5+
pub enum AppWindowMessage {
6+
AppWindowMinimize,
7+
AppWindowMaximize,
8+
AppWindowClose,
9+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use crate::messages::app_window::AppWindowMessage;
2+
use crate::messages::prelude::*;
3+
use graphite_proc_macros::{ExtractField, message_handler_data};
4+
5+
#[derive(Debug, Clone, Default, ExtractField)]
6+
pub struct AppWindowMessageHandler {
7+
platform: AppWindowPlatform,
8+
maximized: bool,
9+
viewport_hole_punch_active: bool,
10+
}
11+
12+
#[message_handler_data]
13+
impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
14+
fn process_message(&mut self, message: AppWindowMessage, responses: &mut std::collections::VecDeque<Message>, _: ()) {
15+
match message {
16+
AppWindowMessage::AppWindowMinimize => {
17+
self.platform = if self.platform == AppWindowPlatform::Mac {
18+
AppWindowPlatform::Windows
19+
} else {
20+
AppWindowPlatform::Mac
21+
};
22+
responses.add(FrontendMessage::UpdatePlatform { platform: self.platform });
23+
}
24+
AppWindowMessage::AppWindowMaximize => {
25+
self.maximized = !self.maximized;
26+
responses.add(FrontendMessage::UpdateMaximized { maximized: self.maximized });
27+
28+
self.viewport_hole_punch_active = !self.viewport_hole_punch_active;
29+
responses.add(FrontendMessage::UpdateViewportHolePunch {
30+
active: self.viewport_hole_punch_active,
31+
});
32+
}
33+
AppWindowMessage::AppWindowClose => {
34+
self.platform = AppWindowPlatform::Web;
35+
responses.add(FrontendMessage::UpdatePlatform { platform: self.platform });
36+
}
37+
}
38+
}
39+
40+
fn actions(&self) -> ActionList {
41+
actions!(AppWindowMessageDiscriminant;)
42+
}
43+
}
44+
45+
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
46+
pub enum AppWindowPlatform {
47+
#[default]
48+
Web,
49+
Windows,
50+
Mac,
51+
Linux,
52+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mod app_window_message;
2+
pub mod app_window_message_handler;
3+
4+
#[doc(inline)]
5+
pub use app_window_message::{AppWindowMessage, AppWindowMessageDiscriminant};
6+
#[doc(inline)]
7+
pub use app_window_message_handler::AppWindowMessageHandler;

editor/src/messages/frontend/frontend_message.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::utility_types::{FrontendDocumentDetails, MouseCursorIcon};
2+
use crate::messages::app_window::app_window_message_handler::AppWindowPlatform;
23
use crate::messages::layout::utility_types::widget_prelude::*;
34
use crate::messages::portfolio::document::node_graph::utility_types::{
45
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, Transform,
@@ -309,4 +310,13 @@ pub enum FrontendMessage {
309310
layout_target: LayoutTarget,
310311
diff: Vec<WidgetDiff>,
311312
},
313+
UpdatePlatform {
314+
platform: AppWindowPlatform,
315+
},
316+
UpdateMaximized {
317+
maximized: bool,
318+
},
319+
UpdateViewportHolePunch {
320+
active: bool,
321+
},
312322
}

editor/src/messages/message.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ pub enum Message {
99
#[child]
1010
Animation(AnimationMessage),
1111
#[child]
12+
AppWindow(AppWindowMessage),
13+
#[child]
1214
Broadcast(BroadcastMessage),
1315
#[child]
1416
Debug(DebugMessage),

editor/src/messages/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! The root-level messages forming the first layer of the message system architecture.
22
33
pub mod animation;
4+
pub mod app_window;
45
pub mod broadcast;
56
pub mod debug;
67
pub mod dialog;

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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, COLOR_OVERLAY_YELLOW_DULL, COMPASS_ROSE_ARROW_SIZE,
4-
COMPASS_ROSE_HOVER_RING_DIAMETER, COMPASS_ROSE_MAIN_RING_DIAMETER, COMPASS_ROSE_RING_INNER_DIAMETER, DOWEL_PIN_RADIUS, MANIPULATOR_GROUP_MARKER_SIZE, PIVOT_CROSSHAIR_LENGTH,
5-
PIVOT_CROSSHAIR_THICKNESS, PIVOT_DIAMETER,
3+
ARC_SWEEP_GIZMO_RADIUS, COLOR_OVERLAY_BLUE, COLOR_OVERLAY_BLUE_50, COLOR_OVERLAY_GREEN, COLOR_OVERLAY_RED, COLOR_OVERLAY_WHITE, COLOR_OVERLAY_YELLOW, COLOR_OVERLAY_YELLOW_DULL,
4+
COMPASS_ROSE_ARROW_SIZE, COMPASS_ROSE_HOVER_RING_DIAMETER, COMPASS_ROSE_MAIN_RING_DIAMETER, COMPASS_ROSE_RING_INNER_DIAMETER, DOWEL_PIN_RADIUS, MANIPULATOR_GROUP_MARKER_SIZE,
5+
PIVOT_CROSSHAIR_LENGTH, PIVOT_CROSSHAIR_THICKNESS, PIVOT_DIAMETER,
66
};
77
use crate::messages::prelude::Message;
88
use bezier_rs::{Bezier, Subpath};
@@ -423,6 +423,14 @@ impl OverlayContext {
423423
self.render_context.stroke();
424424
}
425425

426+
pub fn draw_arc_gizmo_angle(&mut self, pivot: DVec2, bold_radius: f64, dash_radius: f64, arc_radius: f64, offset_angle: f64, angle: f64) {
427+
let end_point1 = pivot + bold_radius * DVec2::from_angle(angle + offset_angle);
428+
let end_point2 = pivot + dash_radius * DVec2::from_angle(offset_angle);
429+
self.line(pivot, end_point1, None, None);
430+
self.dashed_line(pivot, end_point2, None, None, Some(2.), Some(2.), Some(0.5));
431+
self.draw_arc(pivot, arc_radius, offset_angle, (angle) % TAU + offset_angle);
432+
}
433+
426434
pub fn draw_angle(&mut self, pivot: DVec2, radius: f64, arc_radius: f64, offset_angle: f64, angle: f64) {
427435
let end_point1 = pivot + radius * DVec2::from_angle(angle + offset_angle);
428436
let end_point2 = pivot + radius * DVec2::from_angle(offset_angle);
@@ -584,6 +592,12 @@ impl OverlayContext {
584592
self.end_dpi_aware_transform();
585593
}
586594

595+
pub fn arc_sweep_angle(&mut self, offset_angle: f64, angle: f64, end_point_position: DVec2, bold_radius: f64, dash_radius: f64, pivot: DVec2, text: &str, transform: DAffine2) {
596+
self.manipulator_handle(end_point_position, true, Some(COLOR_OVERLAY_RED));
597+
self.draw_arc_gizmo_angle(pivot, bold_radius, dash_radius, ARC_SWEEP_GIZMO_RADIUS, offset_angle, angle.to_radians());
598+
self.text(&text, COLOR_OVERLAY_BLUE, None, transform, 16., [Pivot::Middle, Pivot::Middle]);
599+
}
600+
587601
/// Used by the Pen and Path tools to outline the path of the shape.
588602
pub fn outline_vector(&mut self, vector_data: &VectorData, transform: DAffine2) {
589603
self.start_dpi_aware_transform();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ impl<'a> Selected<'a> {
517517
tool_type: &'a ToolType,
518518
pen_handle: Option<&'a mut DVec2>,
519519
) -> Self {
520-
// If user is using the Select tool then use the original layer transforms
521-
if (*tool_type == ToolType::Select) && (*original_transforms == OriginalTransforms::Path(HashMap::new())) {
520+
// If user is using the Select tool or Shape tool then use the original layer transforms
521+
if (*tool_type == ToolType::Select || *tool_type == ToolType::Shape) && (*original_transforms == OriginalTransforms::Path(HashMap::new())) {
522522
*original_transforms = OriginalTransforms::Layer(HashMap::new());
523523
}
524524

0 commit comments

Comments
 (0)