From 1397718f835a7540e52571c618a5be1bcdceedfc Mon Sep 17 00:00:00 2001 From: buliabyak Date: Wed, 21 Nov 2007 03:45:10 +0000 Subject: [PATCH] use gobble_key_events to speed up keyboard moves --- src/gradient-context.cpp | 40 ++++++++++++++++++++++++---------------- src/node-context.cpp | 40 ++++++++++++++++++++++++---------------- src/select-context.cpp | 40 ++++++++++++++++++++++++---------------- src/text-context.cpp | 24 ++++++++++++++++-------- 4 files changed, 88 insertions(+), 56 deletions(-) diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index df4726967..24742885d 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -703,13 +703,15 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Left: case GDK_KP_4: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) drag->selected_move_screen(-10, 0); // shift - else drag->selected_move_screen(-1, 0); // no shift + if (MOD__SHIFT) drag->selected_move_screen(mul*-10, 0); // shift + else drag->selected_move_screen(mul*-1, 0); // no shift } else { // no alt - if (MOD__SHIFT) drag->selected_move(-10*nudge, 0); // shift - else drag->selected_move(-nudge, 0); // no shift + if (MOD__SHIFT) drag->selected_move(mul*-10*nudge, 0); // shift + else drag->selected_move(mul*-nudge, 0); // no shift } ret = TRUE; } @@ -718,13 +720,15 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Up: case GDK_KP_8: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) drag->selected_move_screen(0, 10); // shift - else drag->selected_move_screen(0, 1); // no shift + if (MOD__SHIFT) drag->selected_move_screen(0, mul*10); // shift + else drag->selected_move_screen(0, mul*1); // no shift } else { // no alt - if (MOD__SHIFT) drag->selected_move(0, 10*nudge); // shift - else drag->selected_move(0, nudge); // no shift + if (MOD__SHIFT) drag->selected_move(0, mul*10*nudge); // shift + else drag->selected_move(0, mul*nudge); // no shift } ret = TRUE; } @@ -733,13 +737,15 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Right: case GDK_KP_6: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) drag->selected_move_screen(10, 0); // shift - else drag->selected_move_screen(1, 0); // no shift + if (MOD__SHIFT) drag->selected_move_screen(mul*10, 0); // shift + else drag->selected_move_screen(mul*1, 0); // no shift } else { // no alt - if (MOD__SHIFT) drag->selected_move(10*nudge, 0); // shift - else drag->selected_move(nudge, 0); // no shift + if (MOD__SHIFT) drag->selected_move(mul*10*nudge, 0); // shift + else drag->selected_move(mul*nudge, 0); // no shift } ret = TRUE; } @@ -748,13 +754,15 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Down: case GDK_KP_2: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) drag->selected_move_screen(0, -10); // shift - else drag->selected_move_screen(0, -1); // no shift + if (MOD__SHIFT) drag->selected_move_screen(0, mul*-10); // shift + else drag->selected_move_screen(0, mul*-1); // no shift } else { // no alt - if (MOD__SHIFT) drag->selected_move(0, -10*nudge); // shift - else drag->selected_move(0, -nudge); // no shift + if (MOD__SHIFT) drag->selected_move(0, mul*-10*nudge); // shift + else drag->selected_move(0, mul*-nudge); // no shift } ret = TRUE; } diff --git a/src/node-context.cpp b/src/node-context.cpp index 56b6dd760..3e7903227 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -486,13 +486,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Left: case GDK_KP_4: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(-10, 0); // shift - else nc->shape_editor->move_nodes_screen(-1, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(mul*-10, 0); // shift + else nc->shape_editor->move_nodes_screen(mul*-1, 0); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(-10*nudge, 0); // shift - else nc->shape_editor->move_nodes(-nudge, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*-10*nudge, 0); // shift + else nc->shape_editor->move_nodes(mul*-nudge, 0); // no shift } ret = TRUE; } @@ -501,13 +503,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Up: case GDK_KP_8: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, 10); // shift - else nc->shape_editor->move_nodes_screen(0, 1); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, mul*10); // shift + else nc->shape_editor->move_nodes_screen(0, mul*1); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(0, 10*nudge); // shift - else nc->shape_editor->move_nodes(0, nudge); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*10*nudge); // shift + else nc->shape_editor->move_nodes(0, mul*nudge); // no shift } ret = TRUE; } @@ -516,13 +520,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Right: case GDK_KP_6: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(10, 0); // shift - else nc->shape_editor->move_nodes_screen(1, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(mul*10, 0); // shift + else nc->shape_editor->move_nodes_screen(mul*1, 0); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(10*nudge, 0); // shift - else nc->shape_editor->move_nodes(nudge, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*10*nudge, 0); // shift + else nc->shape_editor->move_nodes(mul*nudge, 0); // no shift } ret = TRUE; } @@ -531,13 +537,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Down: case GDK_KP_2: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, -10); // shift - else nc->shape_editor->move_nodes_screen(0, -1); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, mul*-10); // shift + else nc->shape_editor->move_nodes_screen(0, mul*-1); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(0, -10*nudge); // shift - else nc->shape_editor->move_nodes(0, -nudge); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*-10*nudge); // shift + else nc->shape_editor->move_nodes(0, mul*-nudge); // no shift } ret = TRUE; } diff --git a/src/select-context.cpp b/src/select-context.cpp index c8186b1fd..f0972acc8 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -712,13 +712,15 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Left: case GDK_KP_4: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) sp_selection_move_screen(-10, 0); // shift - else sp_selection_move_screen(-1, 0); // no shift + if (MOD__SHIFT) sp_selection_move_screen(mul*-10, 0); // shift + else sp_selection_move_screen(mul*-1, 0); // no shift } else { // no alt - if (MOD__SHIFT) sp_selection_move(-10*nudge, 0); // shift - else sp_selection_move(-nudge, 0); // no shift + if (MOD__SHIFT) sp_selection_move(mul*-10*nudge, 0); // shift + else sp_selection_move(mul*-nudge, 0); // no shift } ret = TRUE; } @@ -727,13 +729,15 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Up: case GDK_KP_8: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) sp_selection_move_screen(0, 10); // shift - else sp_selection_move_screen(0, 1); // no shift + if (MOD__SHIFT) sp_selection_move_screen(0, mul*10); // shift + else sp_selection_move_screen(0, mul*1); // no shift } else { // no alt - if (MOD__SHIFT) sp_selection_move(0, 10*nudge); // shift - else sp_selection_move(0, nudge); // no shift + if (MOD__SHIFT) sp_selection_move(0, mul*10*nudge); // shift + else sp_selection_move(0, mul*nudge); // no shift } ret = TRUE; } @@ -742,13 +746,15 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Right: case GDK_KP_6: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) sp_selection_move_screen(10, 0); // shift - else sp_selection_move_screen(1, 0); // no shift + if (MOD__SHIFT) sp_selection_move_screen(mul*10, 0); // shift + else sp_selection_move_screen(mul*1, 0); // no shift } else { // no alt - if (MOD__SHIFT) sp_selection_move(10*nudge, 0); // shift - else sp_selection_move(nudge, 0); // no shift + if (MOD__SHIFT) sp_selection_move(mul*10*nudge, 0); // shift + else sp_selection_move(mul*nudge, 0); // no shift } ret = TRUE; } @@ -757,13 +763,15 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Down: case GDK_KP_2: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) sp_selection_move_screen(0, -10); // shift - else sp_selection_move_screen(0, -1); // no shift + if (MOD__SHIFT) sp_selection_move_screen(0, mul*-10); // shift + else sp_selection_move_screen(0, mul*-1); // no shift } else { // no alt - if (MOD__SHIFT) sp_selection_move(0, -10*nudge); // shift - else sp_selection_move(0, -nudge); // no shift + if (MOD__SHIFT) sp_selection_move(0, mul*-10*nudge); // shift + else sp_selection_move(0, mul*-nudge); // no shift } ret = TRUE; } diff --git a/src/text-context.cpp b/src/text-context.cpp index 579309c1e..6ebd6c959 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -999,10 +999,12 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons case GDK_KP_4: if (tc->text) { if (MOD__ALT) { + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__SHIFT) - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(-10, 0)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*-10, 0)); else - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(-1, 0)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*-1, 0)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, @@ -1019,10 +1021,12 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons case GDK_KP_6: if (tc->text) { if (MOD__ALT) { + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__SHIFT) - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(10, 0)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*10, 0)); else - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(1, 0)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*1, 0)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, @@ -1039,10 +1043,12 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons case GDK_KP_8: if (tc->text) { if (MOD__ALT) { + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__SHIFT) - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, -10)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*-10)); else - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, -1)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*-1)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, @@ -1060,10 +1066,12 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons case GDK_KP_2: if (tc->text) { if (MOD__ALT) { + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__SHIFT) - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, 10)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*10)); else - sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, 1)); + sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*1)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, -- 2.30.2