diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-27 19:24:50 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-27 19:24:50 +0000 |
commit | 31ff43125b0629b688a36c2a97c233ec878b3fbc (patch) | |
tree | ee46bd3347e0ff80a5f7564854897ddbc9faf381 /tikzit | |
parent | 99e1dbf751882592ee21400c60bdbc8241894f27 (diff) |
GTK: bring forward / send back support
Waiting on the graph changes to be implemented for it to be done properly (currently no undo/redo and the graph doesn't redraw properly)
git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@403 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64
Diffstat (limited to 'tikzit')
-rw-r--r-- | tikzit/src/gtk/Menu.m | 45 | ||||
-rw-r--r-- | tikzit/src/gtk/TikzDocument.h | 4 | ||||
-rw-r--r-- | tikzit/src/gtk/TikzDocument.m | 93 |
3 files changed, 142 insertions, 0 deletions
diff --git a/tikzit/src/gtk/Menu.m b/tikzit/src/gtk/Menu.m index c8fffb9..ea2e333 100644 --- a/tikzit/src/gtk/Menu.m +++ b/tikzit/src/gtk/Menu.m @@ -224,6 +224,30 @@ static void flip_vert_cb (GtkAction *action, MainWindow *window) { [pool drain]; } +static void bring_forward_cb (GtkAction *action, MainWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[window activeDocument] bringSelectionForward]; + [pool drain]; +} + +static void send_backward_cb (GtkAction *action, MainWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[window activeDocument] sendSelectionBackward]; + [pool drain]; +} + +static void bring_to_front_cb (GtkAction *action, MainWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[window activeDocument] bringSelectionToFront]; + [pool drain]; +} + +static void send_to_back_cb (GtkAction *action, MainWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[window activeDocument] sendSelectionToBack]; + [pool drain]; +} + #ifdef HAVE_POPPLER static void show_preferences_cb (GtkAction *action, MainWindow *window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -351,6 +375,13 @@ static const gchar ui_info[] = " <separator/>" " <menuitem action='FlipVert'/>" " <menuitem action='FlipHoriz'/>" +" <separator/>" +" <menu action='Arrange'>" +" <menuitem action='SendToBack'/>" +" <menuitem action='SendBackward'/>" +" <menuitem action='BringForward'/>" +" <menuitem action='BringToFront'/>" +" </menu>" #ifdef HAVE_POPPLER " <separator/>" " <menuitem action='ShowPreferences'/>" @@ -446,6 +477,8 @@ static GtkActionEntry static_entries[] = { /* EditMenu */ { "Tool", NULL, N_("_Tool") }, + { "Arrange", NULL, N_("_Arrange") }, + #ifdef HAVE_POPPLER { "ShowPreferences", GTK_STOCK_PREFERENCES, NULL, NULL, N_("Edit the TikZiT preferences"), G_CALLBACK (show_preferences_cb) }, @@ -528,6 +561,18 @@ static GtkActionEntry document_entries[] = { { "FlipVert", NULL, N_("Flip nodes _vertically"), NULL, N_("Flip the selected nodes vertically"), G_CALLBACK (flip_vert_cb) }, + { "SendToBack", NULL, N_("Send to _back"), NULL, + N_("Send the selected nodes and edges to the back of the graph"), G_CALLBACK (send_to_back_cb) }, + + { "SendBackward", NULL, N_("Send b_ackward"), NULL, + N_("Send the selected nodes and edges backward"), G_CALLBACK (send_backward_cb) }, + + { "BringForward", NULL, N_("Bring f_orward"), NULL, + N_("Bring the selected nodes and edges forward"), G_CALLBACK (bring_forward_cb) }, + + { "BringToFront", NULL, N_("Bring to _front"), NULL, + N_("Bring the selected nodes and edges to the front of the graph"), G_CALLBACK (bring_to_front_cb) }, + /* ViewMenu */ #ifdef HAVE_POPPLER { "ShowPreview", NULL, N_("_Preview"), "<control>L", diff --git a/tikzit/src/gtk/TikzDocument.h b/tikzit/src/gtk/TikzDocument.h index 2e29677..93e6173 100644 --- a/tikzit/src/gtk/TikzDocument.h +++ b/tikzit/src/gtk/TikzDocument.h @@ -153,6 +153,10 @@ - (void) insertGraph:(Graph*)g; - (void) flipSelectedNodesHorizontally; - (void) flipSelectedNodesVertically; +- (void) bringSelectionForward; +- (void) bringSelectionToFront; +- (void) sendSelectionBackward; +- (void) sendSelectionToBack; - (BOOL) saveCopyToPath: (NSString*)path error: (NSError**)error; - (BOOL) saveToPath: (NSString*)path error: (NSError**)error; diff --git a/tikzit/src/gtk/TikzDocument.m b/tikzit/src/gtk/TikzDocument.m index 5ccdb98..8672266 100644 --- a/tikzit/src/gtk/TikzDocument.m +++ b/tikzit/src/gtk/TikzDocument.m @@ -690,6 +690,95 @@ } } +// FIXME: undo +- (void) bringSelectionForward { + BOOL hasNodeSelection = [[pickSupport selectedNodes] count] > 0; + BOOL hasEdgeSelection = [[pickSupport selectedEdges] count] > 0; + if (!hasNodeSelection && !hasEdgeSelection) + return; + + //[self startUndoGroup]; + if (hasNodeSelection) { + /*GraphChange *change =*/ + [graph bringNodesForward:[pickSupport selectedNodes]]; + //[self registerUndoForChange:change]; + } + if (hasEdgeSelection) { + /*GraphChange *change =*/ + [graph bringEdgesForward:[pickSupport selectedEdges]]; + //[self registerUndoForChange:change]; + } + //[self nameAndEndUndoGroup:@"Bring forward"]; + [self regenerateTikz]; + //[self postGraphChange:change]; +} + +- (void) bringSelectionToFront { + BOOL hasNodeSelection = [[pickSupport selectedNodes] count] > 0; + BOOL hasEdgeSelection = [[pickSupport selectedEdges] count] > 0; + if (!hasNodeSelection && !hasEdgeSelection) + return; + + //[self startUndoGroup]; + if (hasNodeSelection) { + /*GraphChange *change =*/ + [graph bringNodesToFront:[pickSupport selectedNodes]]; + //[self registerUndoForChange:change]; + } + if (hasEdgeSelection) { + /*GraphChange *change =*/ + [graph bringEdgesToFront:[pickSupport selectedEdges]]; + //[self registerUndoForChange:change]; + } + //[self nameAndEndUndoGroup:@"Bring to front"]; + [self regenerateTikz]; + //[self postGraphChange:change]; +} + +- (void) sendSelectionBackward { + BOOL hasNodeSelection = [[pickSupport selectedNodes] count] > 0; + BOOL hasEdgeSelection = [[pickSupport selectedEdges] count] > 0; + if (!hasNodeSelection && !hasEdgeSelection) + return; + + //[self startUndoGroup]; + if (hasNodeSelection) { + /*GraphChange *change =*/ + [graph sendNodesBackward:[pickSupport selectedNodes]]; + //[self registerUndoForChange:change]; + } + if (hasEdgeSelection) { + /*GraphChange *change =*/ + [graph sendNodesBackward:[pickSupport selectedEdges]]; + //[self registerUndoForChange:change]; + } + //[self nameAndEndUndoGroup:@"Send backward"]; + [self regenerateTikz]; + //[self postGraphChange:change]; +} + +- (void) sendSelectionToBack { + BOOL hasNodeSelection = [[pickSupport selectedNodes] count] > 0; + BOOL hasEdgeSelection = [[pickSupport selectedEdges] count] > 0; + if (!hasNodeSelection && !hasEdgeSelection) + return; + + //[self startUndoGroup]; + if (hasNodeSelection) { + /*GraphChange *change =*/ + [graph sendNodesToBack:[pickSupport selectedNodes]]; + //[self registerUndoForChange:change]; + } + if (hasEdgeSelection) { + /*GraphChange *change =*/ + [graph sendNodesToBack:[pickSupport selectedEdges]]; + //[self registerUndoForChange:change]; + } + //[self nameAndEndUndoGroup:@"Send to back"]; + [self regenerateTikz]; + //[self postGraphChange:change]; +} + - (BOOL) saveCopyToPath: (NSString*)p error: (NSError**)error { if (!p) { [NSException raise:@"No document path" format:@"No path given"]; @@ -785,6 +874,10 @@ } - (void) completedGraphChange:(GraphChange*)change withName:(NSString*)name { + if (change == nil) { + NSLog(@"No graph change given for change %@", name); + return; + } [self registerUndoGroupForChange:change withName:name]; [self regenerateTikz]; [self postGraphChange:change]; |