@@ -38,6 +38,11 @@ enum UserMode
3838 Create ,
3939 Move
4040 }
41+ enum ImportMode
42+ {
43+ Add ,
44+ Override
45+ }
4146 enum CreateMode
4247 {
4348 Line ,
@@ -74,6 +79,7 @@ enum CreateMode
7479
7580 UserMode _userMode ;
7681 CreateMode _createMode ;
82+ ImportMode _importMode ;
7783
7884 ImGuiController _ImGuiController ;
7985
@@ -462,9 +468,9 @@ public void OnLeftMouseEnter() // TODO: Rename this
462468 case UserMode . Create : // Create mode
463469 _selectedShape = _createMode switch
464470 {
465- CreateMode . Line => new SVGLine ( ( int ) MouseState . X , ( int ) MouseState . Y , ( int ) MouseState . X , ( int ) MouseState . Y ) ,
471+ CreateMode . Line => new SVGLine ( ( int ) MouseState . X , ( int ) MouseState . Y , ( int ) MouseState . X , ( int ) MouseState . Y , "#000000FF" ) ,
466472 CreateMode . Rectangle => new SVGRectangle ( 0 , 0 , ( int ) MouseState . X , ( int ) MouseState . Y ) ,
467- CreateMode . Circle => new SVGCircle ( 0 , ( int ) MouseState . X , ( int ) MouseState . Y ) ,
473+ CreateMode . Circle => new SVGCircle ( 0 , ( int ) MouseState . X , ( int ) MouseState . Y , "#000000FF" ) ,
468474 _ => throw new Exception ( "A create mode need to be selected" ) ,
469475 } ;
470476 _shapes . Add ( _selectedShape ) ;
@@ -823,15 +829,45 @@ public void ShowUI()
823829 ImGui . SetWindowPos ( new System . Numerics . Vector2 ( ClientSize . X - ImGui . GetWindowWidth ( ) , ClientSize . Y / 2 ) ) ;
824830 ImGui . Text ( "Tree View" ) ;
825831 ImGui . Spacing ( ) ;
826- foreach ( Shape shape in _shapes )
832+ for ( int i = _shapes . Count - 1 ; i >= 0 ; i -- )
827833 {
828- if ( ImGui . Selectable ( String . Format ( "{0}##{1 }" , shape . GetType ( ) . Name , shape . GetHashCode ( ) ) , _selectedShape == shape ) )
834+ if ( ImGui . Selectable ( String . Format ( "{0} - {1} ##{2 }" , _shapes [ i ] . ShortId , _shapes [ i ] . GetType ( ) . Name , _shapes [ i ] . GetHashCode ( ) ) , _selectedShape == _shapes [ i ] ) )
829835 {
830- _selectedShape = shape ;
831- _selector . Select ( shape ) ;
836+ _selectedShape = _shapes [ i ] ;
837+ _selector . Select ( _shapes [ i ] ) ;
832838 _userMode = UserMode . Edit ;
833839 Console . WriteLine ( "New shape selected through tree view" ) ;
834840 }
841+ if ( i - 1 >= 0 )
842+ {
843+ if ( ImGui . ArrowButton ( String . Format ( "Down##d{0}" , i ) , ImGuiDir . Down ) )
844+ {
845+ InvertShape ( i , i - 1 ) ;
846+ SelectShape ( _shapes [ i - 1 ] ) ;
847+ }
848+ }
849+ if ( i + 1 < _shapes . Count )
850+ {
851+ if ( i - 1 >= 0 )
852+ ImGui . SameLine ( ) ;
853+ if ( ImGui . ArrowButton ( String . Format ( "Up##u{0}" , i ) , ImGuiDir . Up ) )
854+ {
855+ InvertShape ( i , i + 1 ) ;
856+ SelectShape ( _shapes [ i + 1 ] ) ;
857+ }
858+ }
859+ ImGui . Separator ( ) ;
860+ }
861+ foreach ( Shape shape in _shapes )
862+ {
863+ //ImGui.Text(String.Format("{0}", shape.GetType().Name));
864+ //if (ImGui.Selectable(String.Format("{0}##{1}", shape.GetType().Name, shape.GetHashCode()), _selectedShape == shape))
865+ //{
866+ // _selectedShape = shape;
867+ // _selector.Select(shape);
868+ // _userMode = UserMode.Edit;
869+ // Console.WriteLine("New shape selected through tree view");
870+ //}
835871 }
836872 ImGui . End ( ) ;
837873
@@ -1061,9 +1097,15 @@ public void ShowUI()
10611097 if ( ImGui . BeginMenu ( "Open" ) )
10621098 {
10631099 if ( ImGui . MenuItem ( "New project" , "Ctrl+O" ) )
1100+ {
10641101 _dialogFilePicker = true ;
1102+ _importMode = ImportMode . Override ;
1103+ }
10651104 if ( ImGui . MenuItem ( "Import a file" , "Ctrl+I" ) )
1066- { }
1105+ {
1106+ _dialogFilePicker = true ;
1107+ _importMode = ImportMode . Add ;
1108+ }
10671109 ImGui . EndMenu ( ) ;
10681110 }
10691111 if ( ImGui . BeginMenu ( "Save" ) )
@@ -1121,7 +1163,19 @@ public void ShowUI()
11211163 {
11221164 ResetSelection ( ) ;
11231165 ResetTimeline ( ) ;
1124- ( _shapes , bool compatibilityFlag ) = Importer . ImportFromFile ( picker . SelectedFile ) ;
1166+ bool compatibilityFlag ;
1167+
1168+ switch ( _importMode )
1169+ {
1170+ case ImportMode . Add :
1171+ ( List < Shape > newShapes , compatibilityFlag ) = Importer . ImportFromFile ( picker . SelectedFile ) ;
1172+ _shapes . AddRange ( newShapes ) ;
1173+ break ;
1174+ case ImportMode . Override :
1175+ default :
1176+ ( _shapes , compatibilityFlag ) = Importer . ImportFromFile ( picker . SelectedFile ) ;
1177+ break ;
1178+ }
11251179 FilePicker . RemoveFilePicker ( this ) ;
11261180 if ( compatibilityFlag )
11271181 _dialogCompatibility = true ;
@@ -1147,6 +1201,18 @@ public void ShowUI()
11471201 }
11481202 ImGui . End ( ) ;
11491203 }
1204+ public void SelectShape ( Shape shape )
1205+ {
1206+ _selectedShape = shape ;
1207+ _selector . Select ( shape ) ;
1208+ _userMode = UserMode . Edit ;
1209+ }
1210+ public void InvertShape ( int index1 , int index2 )
1211+ {
1212+ Shape tmpShape = _shapes [ index2 ] . Clone ( ) ;
1213+ _shapes [ index2 ] = _shapes [ index1 ] . Clone ( ) ;
1214+ _shapes [ index1 ] = tmpShape ;
1215+ }
11501216
11511217 static void HelpMarker ( string desc )
11521218 {
@@ -1193,7 +1259,7 @@ public void RenderInterpolation()
11931259
11941260 int timelineIndex = _ioTimeline ;
11951261
1196-
1262+
11971263
11981264 if ( timelineIndex >= keys [ keys . Length - 1 ] )
11991265 {
@@ -1248,7 +1314,7 @@ public void RenderInterpolation()
12481314 Shape first = _timeline [ nearest . first ] . Find ( x => x . Id == shape . Id ) ! ; // can't be null
12491315 Shape second = _timeline [ nearest . second ] . Find ( x => x . Id == shape . Id ) ! ; // can't be null;
12501316 // If reverse and loop invert the two shape every odd
1251-
1317+
12521318
12531319 //if (first != null && second != null)
12541320 {
0 commit comments