@@ -7,6 +7,10 @@ use crate::consts::{
7
7
ASYMPTOTIC_EFFECT , DEFAULT_DOCUMENT_NAME , FILE_EXPORT_SUFFIX , FILE_SAVE_SUFFIX , GRAPHITE_DOCUMENT_VERSION , SCALE_EFFECT , SCROLLBAR_SPACING , VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR ,
8
8
} ;
9
9
use crate :: input:: InputPreprocessorMessageHandler ;
10
+ use crate :: layout:: widgets:: {
11
+ IconButton , LayoutRow , NumberInput , NumberInputIncrementBehavior , OptionalInput , PopoverButton , PropertyHolder , RadioEntryData , RadioInput , Separator , SeparatorDirection , SeparatorType , Widget ,
12
+ WidgetCallback , WidgetHolder , WidgetLayout ,
13
+ } ;
10
14
use crate :: message_prelude:: * ;
11
15
use crate :: EditorError ;
12
16
@@ -459,6 +463,154 @@ impl DocumentMessageHandler {
459
463
}
460
464
}
461
465
466
+ impl PropertyHolder for DocumentMessageHandler {
467
+ fn properties ( & self ) -> WidgetLayout {
468
+ WidgetLayout :: new ( vec ! [ LayoutRow :: Row {
469
+ name: "" . into( ) ,
470
+ widgets: vec![
471
+ WidgetHolder :: new( Widget :: OptionalInput ( OptionalInput {
472
+ checked: self . snapping_enabled,
473
+ icon: "Snapping" . into( ) ,
474
+ tooltip: "Snapping" . into( ) ,
475
+ on_update: WidgetCallback :: new( |updated_optional_input| DocumentMessage :: SetSnapping { snap: updated_optional_input. checked } . into( ) ) ,
476
+ } ) ) ,
477
+ WidgetHolder :: new( Widget :: PopoverButton ( PopoverButton {
478
+ title: "Snapping" . into( ) ,
479
+ text: "The contents of this popover menu are coming soon" . into( ) ,
480
+ } ) ) ,
481
+ WidgetHolder :: new( Widget :: Separator ( Separator {
482
+ separator_type: SeparatorType :: Unrelated ,
483
+ direction: SeparatorDirection :: Horizontal ,
484
+ } ) ) ,
485
+ WidgetHolder :: new( Widget :: OptionalInput ( OptionalInput {
486
+ checked: true ,
487
+ icon: "Grid" . into( ) ,
488
+ tooltip: "Grid" . into( ) ,
489
+ on_update: WidgetCallback :: new( |_| FrontendMessage :: DisplayDialogComingSoon { issue: Some ( 318 ) } . into( ) ) ,
490
+ } ) ) ,
491
+ WidgetHolder :: new( Widget :: PopoverButton ( PopoverButton {
492
+ title: "Grid" . into( ) ,
493
+ text: "The contents of this popover menu are coming soon" . into( ) ,
494
+ } ) ) ,
495
+ WidgetHolder :: new( Widget :: Separator ( Separator {
496
+ separator_type: SeparatorType :: Unrelated ,
497
+ direction: SeparatorDirection :: Horizontal ,
498
+ } ) ) ,
499
+ WidgetHolder :: new( Widget :: OptionalInput ( OptionalInput {
500
+ checked: self . overlays_visible,
501
+ icon: "Overlays" . into( ) ,
502
+ tooltip: "Overlays" . into( ) ,
503
+ on_update: WidgetCallback :: new( |updated_optional_input| {
504
+ DocumentMessage :: SetOverlaysVisibility {
505
+ visible: updated_optional_input. checked,
506
+ }
507
+ . into( )
508
+ } ) ,
509
+ } ) ) ,
510
+ WidgetHolder :: new( Widget :: PopoverButton ( PopoverButton {
511
+ title: "Overlays" . into( ) ,
512
+ text: "The contents of this popover menu are coming soon" . into( ) ,
513
+ } ) ) ,
514
+ WidgetHolder :: new( Widget :: Separator ( Separator {
515
+ separator_type: SeparatorType :: Unrelated ,
516
+ direction: SeparatorDirection :: Horizontal ,
517
+ } ) ) ,
518
+ WidgetHolder :: new( Widget :: RadioInput ( RadioInput {
519
+ selected_index: if self . view_mode == ViewMode :: Normal { 0 } else { 1 } ,
520
+ entries: vec![
521
+ RadioEntryData {
522
+ value: "normal" . into( ) ,
523
+ icon: "ViewModeNormal" . into( ) ,
524
+ tooltip: "View Mode: Normal" . into( ) ,
525
+ on_update: WidgetCallback :: new( |_| DocumentMessage :: SetViewMode { view_mode: ViewMode :: Normal } . into( ) ) ,
526
+ ..RadioEntryData :: default ( )
527
+ } ,
528
+ RadioEntryData {
529
+ value: "outline" . into( ) ,
530
+ icon: "ViewModeOutline" . into( ) ,
531
+ tooltip: "View Mode: Outline" . into( ) ,
532
+ on_update: WidgetCallback :: new( |_| DocumentMessage :: SetViewMode { view_mode: ViewMode :: Outline } . into( ) ) ,
533
+ ..RadioEntryData :: default ( )
534
+ } ,
535
+ RadioEntryData {
536
+ value: "pixels" . into( ) ,
537
+ icon: "ViewModePixels" . into( ) ,
538
+ tooltip: "View Mode: Pixels" . into( ) ,
539
+ on_update: WidgetCallback :: new( |_| FrontendMessage :: DisplayDialogComingSoon { issue: Some ( 320 ) } . into( ) ) ,
540
+ ..RadioEntryData :: default ( )
541
+ } ,
542
+ ] ,
543
+ } ) ) ,
544
+ WidgetHolder :: new( Widget :: PopoverButton ( PopoverButton {
545
+ title: "View Mode" . into( ) ,
546
+ text: "The contents of this popover menu are coming soon" . into( ) ,
547
+ } ) ) ,
548
+ WidgetHolder :: new( Widget :: Separator ( Separator {
549
+ separator_type: SeparatorType :: Section ,
550
+ direction: SeparatorDirection :: Horizontal ,
551
+ } ) ) ,
552
+ WidgetHolder :: new( Widget :: NumberInput ( NumberInput {
553
+ unit: "°" . into( ) ,
554
+ value: self . movement_handler. tilt / ( std:: f64 :: consts:: PI / 180. ) ,
555
+ increment_factor: 15. ,
556
+ on_update: WidgetCallback :: new( |number_input| {
557
+ MovementMessage :: SetCanvasRotation {
558
+ angle_radians: number_input. value * ( std:: f64 :: consts:: PI / 180. ) ,
559
+ }
560
+ . into( )
561
+ } ) ,
562
+ ..NumberInput :: default ( )
563
+ } ) ) ,
564
+ WidgetHolder :: new( Widget :: Separator ( Separator {
565
+ separator_type: SeparatorType :: Section ,
566
+ direction: SeparatorDirection :: Horizontal ,
567
+ } ) ) ,
568
+ WidgetHolder :: new( Widget :: IconButton ( IconButton {
569
+ size: 24 ,
570
+ icon: "ZoomIn" . into( ) ,
571
+ tooltip: "Zoom In" . into( ) ,
572
+ on_update: WidgetCallback :: new( |_| MovementMessage :: IncreaseCanvasZoom { center_on_mouse: false } . into( ) ) ,
573
+ ..IconButton :: default ( )
574
+ } ) ) ,
575
+ WidgetHolder :: new( Widget :: IconButton ( IconButton {
576
+ size: 24 ,
577
+ icon: "ZoomOut" . into( ) ,
578
+ tooltip: "Zoom Out" . into( ) ,
579
+ on_update: WidgetCallback :: new( |_| MovementMessage :: DecreaseCanvasZoom { center_on_mouse: false } . into( ) ) ,
580
+ ..IconButton :: default ( )
581
+ } ) ) ,
582
+ WidgetHolder :: new( Widget :: IconButton ( IconButton {
583
+ size: 24 ,
584
+ icon: "ZoomReset" . into( ) ,
585
+ tooltip: "Zoom to 100%" . into( ) ,
586
+ on_update: WidgetCallback :: new( |_| MovementMessage :: SetCanvasZoom { zoom_factor: 1. } . into( ) ) ,
587
+ ..IconButton :: default ( )
588
+ } ) ) ,
589
+ WidgetHolder :: new( Widget :: Separator ( Separator {
590
+ separator_type: SeparatorType :: Related ,
591
+ direction: SeparatorDirection :: Horizontal ,
592
+ } ) ) ,
593
+ WidgetHolder :: new( Widget :: NumberInput ( NumberInput {
594
+ unit: "%" . into( ) ,
595
+ value: self . movement_handler. zoom * 100. ,
596
+ min: Some ( 0.000001 ) ,
597
+ max: Some ( 1000000. ) ,
598
+ on_update: WidgetCallback :: new( |number_input| {
599
+ MovementMessage :: SetCanvasZoom {
600
+ zoom_factor: number_input. value / 100. ,
601
+ }
602
+ . into( )
603
+ } ) ,
604
+ increment_behavior: NumberInputIncrementBehavior :: Callback ,
605
+ increment_callback_decrease: WidgetCallback :: new( |_| MovementMessage :: DecreaseCanvasZoom { center_on_mouse: false } . into( ) ) ,
606
+ increment_callback_increase: WidgetCallback :: new( |_| MovementMessage :: IncreaseCanvasZoom { center_on_mouse: false } . into( ) ) ,
607
+ ..NumberInput :: default ( )
608
+ } ) ) ,
609
+ ] ,
610
+ } ] )
611
+ }
612
+ }
613
+
462
614
impl MessageHandler < DocumentMessage , & InputPreprocessorMessageHandler > for DocumentMessageHandler {
463
615
#[ remain:: check]
464
616
fn process_action ( & mut self , message : DocumentMessage , ipp : & InputPreprocessorMessageHandler , responses : & mut VecDeque < Message > ) {
@@ -674,7 +826,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessorMessageHandler> for Docum
674
826
responses. extend ( [ LayerChanged { affected_layer_path } . into ( ) , DocumentStructureChanged . into ( ) ] ) ;
675
827
}
676
828
GroupSelectedLayers => {
677
- let mut new_folder_path: Vec < u64 > = self . graphene_document . shallowest_common_folder ( self . selected_layers ( ) ) . unwrap_or ( & [ ] ) . to_vec ( ) ;
829
+ let mut new_folder_path = self . graphene_document . shallowest_common_folder ( self . selected_layers ( ) ) . unwrap_or ( & [ ] ) . to_vec ( ) ;
678
830
679
831
// Required for grouping parent folders with their own children
680
832
if !new_folder_path. is_empty ( ) && self . selected_layers_contains ( & new_folder_path) {
0 commit comments