diff options
| author | Martin Owens <doctormo@gmail.com> | 2013-07-05 15:53:45 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2013-07-05 15:53:45 +0000 |
| commit | 4327870d81193b63ae3a7394aa39f01da24e0f7e (patch) | |
| tree | 922add0b0087e4ba0377709f3b6b7e3019a3450d /src | |
| parent | Merge: Command-line and DBus refactoring to improve inkscapes ability to be r... (diff) | |
| parent | Adjust sizes of lists (diff) | |
| download | inkscape-4327870d81193b63ae3a7394aa39f01da24e0f7e.tar.gz inkscape-4327870d81193b63ae3a7394aa39f01da24e0f7e.zip | |
Merge: scale, rotate and skew handles refactoring
(bzr r12403)
Diffstat (limited to 'src')
| -rw-r--r-- | src/pixmaps/handles.xpm | 178 | ||||
| -rw-r--r-- | src/select-context.cpp | 28 | ||||
| -rw-r--r-- | src/seltrans-handles.cpp | 14 | ||||
| -rw-r--r-- | src/seltrans.h | 2 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 12 |
5 files changed, 38 insertions, 196 deletions
diff --git a/src/pixmaps/handles.xpm b/src/pixmaps/handles.xpm index f2afa026b..b61ad377c 100644 --- a/src/pixmaps/handles.xpm +++ b/src/pixmaps/handles.xpm @@ -1,5 +1,5 @@ -/* XPM */ -static char const *handle_scale_nw_xpm[] = { +/* XPM North-West */ +static char const *handle_scale_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -18,28 +18,8 @@ static char const *handle_scale_nw_xpm[] = { " ....... ", " "}; -/* XPM */ -static char const *handle_scale_ne_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ....... ", -" ..+++. ", -" .++++. ", -" .+++++. ", -" . .+++++.. ", -" ...+++++... ", -" ..+++++. . ", -" .+++++. ", -" .++++. ", -" .+++.. ", -" ....... ", -" "}; - -/* XPM */ -static char const *handle_scale_h_xpm[] = { +/* XPM Vertical */ +static char const *handle_stretch_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -58,28 +38,8 @@ static char const *handle_scale_h_xpm[] = { " ", " "}; -/* XPM */ -static char const *handle_scale_v_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -" ..+++++.. ", -" .+++. ", -" .+++. ", -" .+++. ", -" ..+++++.. ", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_nw_xpm[] = { +/* XPM North-West */ +static char const *handle_rotate_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -98,8 +58,8 @@ static char const *handle_rotate_nw_xpm[] = { " ... ", " . "}; -/* XPM */ -static char const *handle_rotate_n_xpm[] = { +/* XPM North */ +static char const *handle_skew_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -119,127 +79,6 @@ static char const *handle_rotate_n_xpm[] = { " "}; /* XPM */ -static char const *handle_rotate_ne_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" .. ", -" .... ", -" ..++... ", -"..++++++. ", -" .+++++++. ", -" .+..++++. ", -" . .+++. ", -" .+++...", -" .++++.. ", -" .++.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_e_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -" ...+++...", -" .+++. ", -" .+++. ", -" .+++. ", -" ...+++...", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_se_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" .++.. ", -" .++++.. ", -" .+++...", -" . .+++. ", -" .+..++++. ", -" .+++++++. ", -"..++++++. ", -" ..++... ", -" .... ", -" .. ", -" . "}; - - -/* XPM */ -static char const *handle_rotate_s_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" . . ", -" .. .. ", -" ......... ", -" ..+++++++.. ", -"..+++++++++..", -" ..+++++++.. ", -" ......... ", -" .. .. ", -" . . "}; - -/* XPM */ -static char const *handle_rotate_sw_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..++. ", -" ..++++. ", -"...+++. ", -" .+++. . ", -" .++++..+. ", -" .+++++++. ", -" .++++++..", -" ...++.. ", -" .... ", -" .. ", -" . "}; - -/* XPM */ -static char const *handle_rotate_w_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -"...+++... ", -" .+++. ", -" .+++. ", -" .+++. ", -"...+++. . ", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ static char const *handle_center_xpm[] = { "13 13 3 1", " c None", @@ -258,3 +97,4 @@ static char const *handle_center_xpm[] = { " . ", " . ", " "}; + diff --git a/src/select-context.cpp b/src/select-context.cpp index 3df047368..b4b01bf15 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -91,6 +91,16 @@ sp_select_context_class_init(SPSelectContextClass *klass) event_context_class->item_handler = sp_select_context_item_handler; } +//Creates rotated variations for handles +static void +sp_load_handles(int start, int count, char const **xpm) { + handles[start] = gdk_pixbuf_new_from_xpm_data((gchar const **)xpm); + for(int i = start + 1; i < start + count; i++) { + // We use either the original at *start or previous loop item to rotate + handles[i] = gdk_pixbuf_rotate_simple(handles[i-1], GDK_PIXBUF_ROTATE_CLOCKWISE); + } +} + static void sp_select_context_init(SPSelectContext *sc) { @@ -111,19 +121,11 @@ sp_select_context_init(SPSelectContext *sc) CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1); CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1); // selection handles - handles[0] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_nw_xpm); - handles[1] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_ne_xpm); - handles[2] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_h_xpm); - handles[3] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_v_xpm); - handles[4] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_nw_xpm); - handles[5] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_n_xpm); - handles[6] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_ne_xpm); - handles[7] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_e_xpm); - handles[8] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_se_xpm); - handles[9] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_s_xpm); - handles[10] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_sw_xpm); - handles[11] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_w_xpm); - handles[12] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_center_xpm); + sp_load_handles(0, 2, handle_scale_xpm); + sp_load_handles(2, 2, handle_stretch_xpm); + sp_load_handles(4, 4, handle_rotate_xpm); + sp_load_handles(8, 4, handle_skew_xpm); + sp_load_handles(12, 1, handle_center_xpm); } static void diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index bacb1301e..6dd94d297 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -16,7 +16,7 @@ SPSelTransTypeInfo const handtypes[] = { SPSelTransHandle const hands[] = { //center handle will be 0 so we can reference it quickly. {HANDLE_CENTER, SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, 0.5, 0.5}, -//handle-type anchor cursor control x y +//handle-type anchor-nudge cursor image x y {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, @@ -25,14 +25,14 @@ SPSelTransHandle const hands[] = { {HANDLE_SCALE, SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, 1, 1}, {HANDLE_SCALE, SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, 1, 0}, {HANDLE_SCALE, SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, 0, 0}, - {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 5, 0.5, 1}, - {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 7, 1, 0.5}, - {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 9, 0.5, 0}, + {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, + {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, + {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, {HANDLE_ROTATE, SP_ANCHOR_SE, GDK_EXCHANGE, 4, 0, 1}, - {HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 6, 1, 1}, - {HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 8, 1, 0}, - {HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 10, 0, 0}, + {HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 5, 1, 1}, + {HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 6, 1, 0}, + {HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 7, 0, 0}, }; /* diff --git a/src/seltrans.h b/src/seltrans.h index 667dedaf0..880f30c94 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -180,7 +180,7 @@ private: bool _center_is_set; ///< we've already set _center, no need to reread it from items int _center_handle; - SPKnot *knots[27]; // Only some as shown at any time + SPKnot *knots[17]; SPCanvasItem *_norm; SPCanvasItem *_grip; SPCtrlLine *_l[4]; diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..30963cabd 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -458,9 +458,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 4) { - case 0: return Glib::wrap(handles[10], true); - case 1: return Glib::wrap(handles[8], true); - case 2: return Glib::wrap(handles[6], true); + case 0: return Glib::wrap(handles[7], true); + case 1: return Glib::wrap(handles[6], true); + case 2: return Glib::wrap(handles[5], true); default: return Glib::wrap(handles[4], true); } } @@ -605,9 +605,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _side_to_pixbuf(unsigned s) { sp_select_context_get_type(); switch (s % 4) { - case 0: return Glib::wrap(handles[9], true); - case 1: return Glib::wrap(handles[7], true); - case 2: return Glib::wrap(handles[5], true); + case 0: return Glib::wrap(handles[10], true); + case 1: return Glib::wrap(handles[9], true); + case 2: return Glib::wrap(handles[8], true); default: return Glib::wrap(handles[11], true); } } |
