Commit be1c9b14 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Merge branch "krita-canvasinteraction-ahiemstra"

REVIEW: 105250

Squashed commit of the following:

commit 626645f6e68f7423c9422b569ae8979805664eea
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 15 14:31:50 2012 +0200

    Add support for wheel events and try to improve shortcut recognition.

commit 6103da39983cfde245e7219a90618dd6e4452ff3
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 15 14:31:27 2012 +0200

    Add support for shortcuts to KisShortcut.

commit b68bc1725d35bdb0d1c0ca1f0a34249f16c7cff8
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 15 14:29:49 2012 +0200

    Ensure we update the mouse position correctly.

commit c8f2268af524df2f4769d37367c79f02d14164bc
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 15 14:29:09 2012 +0200

    Reduce rotation speed and ensure we update the mouse position correctly

commit 60dcab504e8289a1e6b17906541680dfeb660251
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 15 14:27:18 2012 +0200

    Fix building with GCC < 4.7

commit a77c9562e665638730f11459273cd7c6d78e5357
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 14 13:36:03 2012 +0200

    Clean up and comment.

commit 9466ab130380e455da7c5620cbc58c634eb48181
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 14 13:35:41 2012 +0200

    Document all the classes.

commit 7f34cffa41068fe907ec3c4de9596a8d563a02a7
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 14 12:23:34 2012 +0200

    Remove obsolete input related code.

commit 7a316502466b7389c261714a3ee2f8663279bcaf
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 14 12:21:48 2012 +0200

    Update AbstractInputAction to a more clean API.

commit 6b871419e67b0a267a2a4d7794ae1b33423dea3f
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Wed Jun 13 14:47:53 2012 +0200

    Implement Change Primary Setting action.

commit 5e0e8d25661d3f498fc1fcf39e0ae36e72028fbc
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Wed Jun 13 14:47:20 2012 +0200

    Implement alternate invocation by simulating mouse events for now.

commit 8de97d3ed35397cc9c54444e347e33df45fcf36f
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Wed Jun 13 14:46:43 2012 +0200

    Add a description to the Tool Invocation action.

commit c0d4caf157d9941d6fa1675e4d3f185bf12c1a90
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Wed Jun 13 14:46:04 2012 +0200

    Add a description method to abstract input aciton.

commit 57fde74b2b94a42e0450e76d1684beee0046c1a6
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 12 17:05:59 2012 +0200

    Enable previously disabled actions again.

commit 5568539f5803655762d9533c3d9f56d2a8733bca
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 12 17:05:06 2012 +0200

    Update Show Palette action

commit 9db2dc5e19ed4d08a578180ba940ff120f9ee022
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 12 17:04:29 2012 +0200

    Update Rotate Canvas action and add support for some shortcut keys

commit 42f086e4010c2d5e856421189d1643ff3539a1b0
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 12 17:03:44 2012 +0200

    Update Alternate invocation to new API and start implementing it.

commit 06b47a22f40f96c701f4134743f0cce020591374
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 21:55:21 2012 +0200

    Update zoom action and add several zoom related shortcuts.

commit 6640467ad90980e4142b1823ab063c7cc4f96822
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 21:54:52 2012 +0200

    Update Pan Action and make it possible to pan with keys.

commit 9338db9428c80577c7db568408620a6f9595e6bf
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 21:54:20 2012 +0200

    Update the Tool Invocation action to the changed API.

commit 4bd161e6ae015b4670e5d3cb3933fb64c6d188b7
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 21:53:03 2012 +0200

    Change the actions to support different shortcuts.

commit 41a63d2ec1c1b021e636a5cab1d781c174ef01df
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 15:01:30 2012 +0200

    Invert the zoom direction.

    Now drag up is zoom in, drag down zoom out. Far more intuitive.

commit 817e63b8b78e3ec74a35cee79b9024b7c6205dbe
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 11 15:00:34 2012 +0200

    Make tablet events work properly.

    Now the intial event is sent as a tablet event and so has proper
    pressure.

commit 20972cb62b5d69fd2e6ce4c47c6d1d4739dc601a
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 7 16:41:25 2012 +0200

    Attempt to handle tablet events properly.

    Only supports TabletMove at the moment, the initial TabletPress still
    needs to be converted.

commit 26044ac16f2048008c56d9c3cc7e912e6a4e7dc1
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 7 16:38:56 2012 +0200

    Add a zoom and open palette action

commit 1351977ee0d49cbe0f39d4f9038ca6d0b88eb80a
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu Jun 7 16:37:07 2012 +0200

    Prevent the canvas from handling tablet events

    This ensures we get Mouse events when we do not handle a tablet event.

commit a21d061b288cb00fb50685ac6efbcb6729eddd8b
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 5 16:58:04 2012 +0200

    Fix shortcuts not resetting properly and ignore auto repeat events.

commit c666e9f4b6af87a03c50d7999c6e1d90fe3e9e95
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 5 16:05:59 2012 +0200

    Add a rotate canvas action

commit d47a9d3ed6d3c04ae49dd2d711de069bdf69ef9a
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 5 16:04:50 2012 +0200

    Update the tool invocation action to use the proper API.

commit aedbd3fa662d8a7f13c4a74e8a4f5e7d93143a31
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 5 16:01:20 2012 +0200

    Update the pan action to use widget coordinates.

commit 8ee99aecf4d8f80a7c7b7b5595938eb2da8bf2cb
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Tue Jun 5 15:57:56 2012 +0200

    Perform the matching in KisShortcut instead of KisInputManager

    This avoids several duplications of loops and allows us to reuse the
    matching code.

commit 5d164edbee9cd4ca73386b7408bc105bf90ea520
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 4 15:17:06 2012 +0200

    Use the correct position for the tool invocaton action.

commit 0eef2584959ba7bfaea96c9ed04074b1956d0f4e
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 4 15:16:38 2012 +0200

    Use document position for movement instead of view

commit c49a1652d7706256445c81631113fb0391116d09
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 4 15:16:01 2012 +0200

    Set mousePosition to the document position instead of the view.

commit 211451754454b766bcf707b5ebe88cb8af2cd156
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 4 14:40:55 2012 +0200

    Implement a basic Pan action.

commit 23c8800bdbf1253029320dbaae351412e16e28a3
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Mon Jun 4 13:13:10 2012 +0200

    Restore basic painting functionality.

    Still a little off position-wise, but the basics now at least work.

commit 25d4f706577a69d3379eae30e4434d3e43e742e0
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 1 11:26:21 2012 +0200

    Add missing files

commit 6d2fc262dc42444dd2c9d66330eb0658179a8e9e
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Fri Jun 1 11:25:17 2012 +0200

    Update recognition code; use KisShortcut more directly

commit feac32a42c35d6e16920ab8a1c197f445040bfbb
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Thu May 31 15:53:17 2012 +0200

    Very basic action detection working.

    Still no conflict resolution or anything, just selection based on a
    single input event. Still, the design seems to work.

commit 2b4c7bb4c33ac7b2e90b1e357581d09a6396de78
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date:   Wed May 30 14:51:52 2012 +0200

    Add a basic InputManager class that catches all input events.
parent 03bc852c
include_directories( ${KOTEXT_INCLUDES}
include_directories( ${KOTEXT_INCLUDES}
${TEXTLAYOUT_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/pigment/colorprofiles
${CMAKE_CURRENT_SOURCE_DIR}/flake
${CMAKE_CURRENT_SOURCE_DIR}/flake
${CMAKE_CURRENT_SOURCE_DIR}/pigment/resources
${CMAKE_CURRENT_SOURCE_DIR}/widgets/resources
${CMAKE_CURRENT_SOURCE_DIR}/openrastertk
${CMAKE_SOURCE_DIR}/krita/image/metadata
${CMAKE_SOURCE_DIR}/krita/image/metadata
${EXIV2_INCLUDE_DIR} )
add_subdirectory( tests )
......@@ -16,22 +16,22 @@ configure_file(config-processor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-proce
include(kdefx.cmake)
set(kritaui_LIB_SRCS
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas2.cpp
canvas/kis_canvas_controller.cpp
canvas/kis_tool_proxy.cpp
canvas/kis_canvas_decoration.cc
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
canvas/kis_grid_painter_configuration.cpp
canvas/kis_perspective_grid_manager.cpp
canvas/kis_perspective_grid_manager.cpp
canvas/kis_prescaled_projection.cpp
canvas/kis_qpainter_canvas.cpp
canvas/kis_projection_backend.cpp
canvas/kis_update_info.cpp
canvas/kis_image_patch.cpp
canvas/kis_image_pyramid.cpp
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adjustment_layer.cc
dialogs/kis_dlg_filter.cpp
dialogs/kis_dlg_generator_layer.cpp
......@@ -44,21 +44,21 @@ set(kritaui_LIB_SRCS
flake/kis_node_shapes_graph.cpp
flake/kis_node_shape.cpp
flake/kis_shape_controller.cpp
flake/kis_shape_layer.cc
flake/kis_shape_layer_canvas.cpp
flake/kis_shape_layer.cc
flake/kis_shape_layer_canvas.cpp
flake/kis_shape_selection.cpp
flake/kis_shape_selection_canvas.cpp
flake/kis_shape_selection_model.cpp
flake/kis_shape_selection_model.cpp
kis_autogradient.cc
kis_autogradient_resource.cc
kis_bookmarked_configurations_editor.cc
kis_bookmarked_configurations_model.cc
kis_bookmarked_filter_configurations_model.cc
kis_canvas_resource_provider.cpp
kis_canvas_resource_provider.cpp
kis_categorized_item_delegate.cpp
kis_clipboard.cc
kis_clipboard.cc
kis_config.cc
kis_config_notifier.cpp
kis_config_notifier.cpp
kis_color_data_list.cpp
kis_control_frame.cpp
kis_composite_ops_model.cc
......@@ -66,38 +66,38 @@ set(kritaui_LIB_SRCS
kis_cursor.cc
kis_custom_palette.cc
kis_custom_pattern.cc
kis_doc2.cc
kis_exposure_visitor.cc
kis_doc2.cc
kis_exposure_visitor.cc
kis_factory2.cc
kis_filter_handler.cc
kis_filter_manager.cc
kis_filter_handler.cc
kis_filter_manager.cc
kis_filters_model.cc
kis_histogram_view.cc
kis_histogram_view.cc
kis_image_manager.cc
kis_image_view_converter.cpp
kis_import_catcher.cc
kis_import_catcher.cc
kis_layer_manager.cc
kis_mask_manager.cc
kis_mimedata.cpp
kis_node_commands_adapter.cpp
kis_node_manager.cpp
kis_node_manager.cpp
kis_node_model.cpp
kis_model_index_converter_base.cpp
kis_model_index_converter.cpp
kis_model_index_converter_show_all.cpp
kis_painting_assistant.cc
kis_painting_assistants_manager.cc
kis_paintop_box.cc
kis_painting_assistant.cc
kis_painting_assistants_manager.cc
kis_paintop_box.cc
kis_palette_manager.cpp
kis_popup_palette.cpp
kis_png_converter.cpp
kis_preference_set_registry.cpp
kis_print_job.cpp
kis_resource_server_provider.cpp
kis_resource_server_provider.cpp
kis_selection_decoration.cc
kis_selection_manager.cc
kis_selection_manager.cc
kis_statusbar.cc
kis_view2.cpp
kis_view2.cpp
kis_zoom_manager.cc
thememanager.cpp
ko_favorite_resource_manager.cpp
......@@ -108,11 +108,11 @@ set(kritaui_LIB_SRCS
kisexiv2/kis_xmp_io.cpp
kra/kis_kra_utils.cpp
kra/kis_kra_load_visitor.cpp
kra/kis_kra_loader.cpp
kra/kis_kra_save_visitor.cpp
kra/kis_kra_loader.cpp
kra/kis_kra_save_visitor.cpp
kra/kis_kra_saver.cpp
kra/kis_kra_savexml_visitor.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl_canvas2.cpp
opengl/kis_opengl_image_textures.cpp
opengl/kis_texture_tile.cpp
......@@ -127,17 +127,17 @@ set(kritaui_LIB_SRCS
recorder/kis_recorded_filter_action_editor.cc
recorder/kis_recorded_filter_action_creator.cpp
recorder/kis_recorded_paint_action_editor.cc
tool/kis_selection_tool_helper.cpp
tool/kis_selection_tool_config_widget_helper.cpp
tool/kis_shape_tool_helper.cpp
tool/kis_tool.cc
tool/kis_tool_freehand.cc
tool/kis_selection_tool_helper.cpp
tool/kis_selection_tool_config_widget_helper.cpp
tool/kis_shape_tool_helper.cpp
tool/kis_tool.cc
tool/kis_tool_freehand.cc
tool/kis_painting_information_builder.cpp
tool/kis_tool_freehand_helper.cpp
tool/kis_tool_multihand_helper.cpp
tool/kis_figure_painting_tool_helper.cpp
tool/kis_recording_adapter.cpp
tool/kis_tool_paint.cc
tool/kis_tool_paint.cc
tool/kis_tool_shape.cc
tool/kis_tool_select_base.cpp
tool/kis_tool_ellipse_base.cpp
......@@ -147,36 +147,36 @@ set(kritaui_LIB_SRCS
tool/kis_resources_snapshot.cpp
tool/strokes/freehand_stroke.cpp
tool/strokes/kis_painter_based_stroke_strategy.cpp
widgets/kis_channelflags_widget.cpp
widgets/kis_channelflags_widget.cpp
widgets/kis_cmb_composite.cc
widgets/kis_paintop_list_widget.cpp
widgets/kis_cmb_idlist.cc
widgets/kis_cmb_idlist.cc
widgets/kis_color_space_selector.cc
widgets/kis_curve_widget.cpp
widgets/kis_custom_image_widget.cc
widgets/kis_custom_image_widget.cc
widgets/kis_double_widget.cc
widgets/kis_filter_selector_widget.cc
widgets/kis_gradient_chooser.cc
widgets/kis_gradient_chooser.cc
widgets/kis_gradient_slider_widget.cc
widgets/kis_gradient_slider.cpp
widgets/kis_iconwidget.cc
widgets/kis_mask_widgets.cpp
widgets/kis_iconwidget.cc
widgets/kis_mask_widgets.cpp
widgets/kis_meta_data_merge_strategy_chooser_widget.cc
widgets/kis_multi_bool_filter_widget.cc
widgets/kis_multi_double_filter_widget.cc
widgets/kis_multi_integer_filter_widget.cc
widgets/kis_multipliers_double_slider_spinbox.cpp
widgets/kis_paintop_presets_popup.cpp
widgets/kis_paintop_presets_popup.cpp
widgets/kis_paintop_presets_chooser_popup.cpp
widgets/kis_pattern_chooser.cc
widgets/kis_popup_button.cc
widgets/kis_popup_button.cc
widgets/kis_preset_chooser.cpp
widgets/kis_progress_widget.cpp
widgets/kis_selection_options.cc
widgets/kis_selection_options.cc
widgets/kis_scratch_pad.cpp
widgets/kis_scratch_pad_event_filter.cpp
widgets/kis_preset_selector_strip.cpp
widgets/kis_tree_view_popup.cc
widgets/kis_tree_view_popup.cc
widgets/kis_slider_spin_box.cpp
widgets/kis_wdg_generator.cpp
widgets/kis_workspace_chooser.cpp
......@@ -187,6 +187,16 @@ set(kritaui_LIB_SRCS
widgets/kis_floating_message.cpp
# widgets/kis_light_source.cpp
# widgets/kis_light_stage.cpp
input/kis_input_manager.cpp
input/kis_shortcut.cpp
input/kis_abstract_input_action.cpp
input/kis_tool_invocation_action.cpp
input/kis_pan_action.cpp
input/kis_alternate_invocation_action.cpp
input/kis_rotate_canvas_action.cpp
input/kis_zoom_action.cpp
input/kis_show_palette_action.cpp
input/kis_change_primary_setting_action.cpp
)
if(HAVE_OPENGL)
......
......@@ -65,6 +65,8 @@
#include <ko_favorite_resource_manager.h>
#include <kis_paintop_box.h>
#include "input/kis_input_manager.h"
struct KisCanvas2::KisCanvas2Private
{
......@@ -103,6 +105,8 @@ public:
#endif
KisPrescaledProjectionSP prescaledProjection;
bool vastScrolling;
KisInputManager* inputManager;
};
KisCanvas2::KisCanvas2(KisCoordinatesConverter* coordConverter, KisView2 * view, KoShapeBasedDocumentBase * sc)
......@@ -111,6 +115,9 @@ KisCanvas2::KisCanvas2(KisCoordinatesConverter* coordConverter, KisView2 * view,
{
// a bit of duplication from slotConfigChanged()
KisConfig cfg;
m_d->inputManager = new KisInputManager(this, m_d->toolProxy);
m_d->vastScrolling = cfg.vastScrolling();
createCanvas(cfg.useOpenGL());
......@@ -161,6 +168,7 @@ void KisCanvas2::setCanvasWidget(QWidget * widget)
widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setMouseTracking(true);
widget->setAcceptDrops(true);
widget->installEventFilter(m_d->inputManager);
KoCanvasControllerWidget *controller = dynamic_cast<KoCanvasControllerWidget*>(canvasController());
if (controller) {
Q_ASSERT(controller->canvas() == this);
......
......@@ -55,7 +55,7 @@ public:
const KoViewConverter * viewConverter;
KoToolProxy * toolProxy;
QTimer blockMouseEvent;
bool ignorenextMouseEventExceptRightMiddleClick; // HACK work around Qt bug not sending tablet right/dblclick http://bugreports.qt.nokia.com/browse/QTBUG-8598
QColor borderColor;
};
......@@ -180,110 +180,6 @@ KoToolProxy *KisCanvasWidgetBase::toolProxy()
return m_d->toolProxy;
}
QPointF KisCanvasWidgetBase::mouseEventWidgetToDocument(const QPoint& mousePosition) const
{
const qreal PIXEL_CENTRE_OFFSET = 0.5;
const QPointF pixelCentre(mousePosition.x() + PIXEL_CENTRE_OFFSET,
mousePosition.y() + PIXEL_CENTRE_OFFSET);
return m_d->coordinatesConverter->widgetToDocument(pixelCentre);
}
void KisCanvasWidgetBase::processMouseMoveEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick )
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseMoveEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processContextMenuEvent(QContextMenuEvent *e)
{
Q_UNUSED(e);
// m_d->canvas->view()->unplugActionList("flake_tool_actions");
// m_d->canvas->view()->plugActionList("flake_tool_actions",
// m_d->toolProxy->popupActionList());
// QMenu *menu = dynamic_cast<QMenu*>(m_d->canvas->view()->factory()->container("image_popup", m_d->canvas->view()));
// if (menu)
// menu->exec(e->globalPos());
}
void KisCanvasWidgetBase::processMousePressEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick)
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mousePressEvent(e, mouseEventWidgetToDocument(e->pos()));
}
e->setAccepted(true);
return;
}
if (m_d->blockMouseEvent.isActive()) {
e->setAccepted(true);
return;
}
m_d->toolProxy->mousePressEvent(e, mouseEventWidgetToDocument(e->pos()));
e->setAccepted(true);
}
void KisCanvasWidgetBase::processMouseReleaseEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick)
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mouseReleaseEvent(e, mouseEventWidgetToDocument(e->pos()));
}
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseReleaseEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processMouseDoubleClickEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick )
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mouseDoubleClickEvent(e, mouseEventWidgetToDocument(e->pos()));
}
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseDoubleClickEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processKeyPressEvent(QKeyEvent *e)
{
m_d->toolProxy->keyPressEvent(e);
if (! e->isAccepted()) {
if (e->key() == Qt::Key_Backtab
|| (e->key() == Qt::Key_Tab && (e->modifiers() & Qt::ShiftModifier)))
callFocusNextPrevChild(false);
else if (e->key() == Qt::Key_Tab)
callFocusNextPrevChild(true);
}
}
void KisCanvasWidgetBase::processKeyReleaseEvent(QKeyEvent *e)
{
m_d->toolProxy->keyReleaseEvent(e);
}
QVariant KisCanvasWidgetBase::processInputMethodQuery(Qt::InputMethodQuery query) const
{
if (query == Qt::ImMicroFocus) {
......@@ -299,24 +195,3 @@ void KisCanvasWidgetBase::processInputMethodEvent(QInputMethodEvent *event)
{
m_d->toolProxy->inputMethodEvent(event);
}
void KisCanvasWidgetBase::processTabletEvent(QTabletEvent *e)
{
widget()->setFocus(Qt::OtherFocusReason);
m_d->blockMouseEvent.start(100);
const QPointF pos = e->hiResGlobalPos() - widget()->mapToGlobal(QPoint(0, 0));
m_d->toolProxy->tabletEvent(e, m_d->coordinatesConverter->widgetToDocument(pos));
// HACK
e->ignore();
m_d->ignorenextMouseEventExceptRightMiddleClick = true;
// HACK
}
void KisCanvasWidgetBase::processWheelEvent(QWheelEvent *e)
{
m_d->toolProxy->wheelEvent(e, m_d->coordinatesConverter->widgetToDocument(e->pos()));
}
......@@ -78,34 +78,16 @@ protected:
KisCoordinatesConverter* coordinatesConverter();
/**
* Convert a mouse event widget coordinate to a document
* coordinate, applying an offset to convert the integer
* coordinate to floating point.
*
* @param mousePosition mouse event coordinate
*/
QPointF mouseEventWidgetToDocument(const QPoint& mousePosition) const;
/**
* Event handlers to be called by derived canvas event handlers.
* All common event processing is carried out by these
* All common event processing is carried out by these
* functions.
*/
void processKeyPressEvent(QKeyEvent *e);
void processKeyReleaseEvent(QKeyEvent *e);
void processMousePressEvent(QMouseEvent *e);
void processMouseMoveEvent(QMouseEvent *e);
void processMouseReleaseEvent(QMouseEvent *e);
void processMouseDoubleClickEvent(QMouseEvent *e);
void processContextMenuEvent(QContextMenuEvent *e);
void processTabletEvent(QTabletEvent *e);
void processWheelEvent(QWheelEvent *e);
QVariant processInputMethodQuery(Qt::InputMethodQuery query) const;
void processInputMethodEvent(QInputMethodEvent *event);
void notifyConfigChanged();
/// To be implemented by the derived canvas
/// To be implemented by the derived canvas
virtual bool callFocusNextPrevChild(bool next) = 0;
private:
......
......@@ -178,56 +178,6 @@ bool KisQPainterCanvas::event(QEvent *e)
return QWidget::event(e);
}
void KisQPainterCanvas::enterEvent(QEvent* e)
{
if(!hasFocus()) {
setFocus();
}
QWidget::enterEvent(e);
}
void KisQPainterCanvas::leaveEvent(QEvent* e)
{
QWidget::leaveEvent(e);
}
void KisQPainterCanvas::mouseMoveEvent(QMouseEvent *e)
{
processMouseMoveEvent(e);
}
void KisQPainterCanvas::contextMenuEvent(QContextMenuEvent *e)
{
processContextMenuEvent(e);
}
void KisQPainterCanvas::mousePressEvent(QMouseEvent *e)
{
m_d->smooth = false;
processMousePressEvent(e);
}
void KisQPainterCanvas::mouseReleaseEvent(QMouseEvent *e)
{
m_d->smooth = true;
processMouseReleaseEvent(e);
}
void KisQPainterCanvas::mouseDoubleClickEvent(QMouseEvent *e)
{
processMouseDoubleClickEvent(e);
}
void KisQPainterCanvas::keyPressEvent(QKeyEvent *e)
{
processKeyPressEvent(e);
}
void KisQPainterCanvas::keyReleaseEvent(QKeyEvent *e)
{
processKeyReleaseEvent(e);
}
QVariant KisQPainterCanvas::inputMethodQuery(Qt::InputMethodQuery query) const
{
return processInputMethodQuery(query);
......@@ -238,16 +188,6 @@ void KisQPainterCanvas::inputMethodEvent(QInputMethodEvent *event)
processInputMethodEvent(event);
}
void KisQPainterCanvas::tabletEvent(QTabletEvent *e)
{
processTabletEvent(e);
}
void KisQPainterCanvas::wheelEvent(QWheelEvent *e)
{
processWheelEvent(e);
}
void KisQPainterCanvas::resizeEvent(QResizeEvent *e)
{
QSize size(e->size());
......
......@@ -61,42 +61,9 @@ public: // QWidget
/// reimplemented method from superclass
bool event(QEvent *);
/// reimplemented method from superclass
void enterEvent(QEvent* e);
/// reimplemented method from superclass
void leaveEvent(QEvent* e);
/// reimplemented method from superclass
void keyPressEvent(QKeyEvent *e);
/// reimplemented method from superclass
void mouseMoveEvent(QMouseEvent *e);
/// reimplemented method from superclass
void contextMenuEvent(QContextMenuEvent *e);
/// reimplemented method from superclass
void mousePressEvent(QMouseEvent *e);
/// reimplemented method from superclass
void mouseReleaseEvent(QMouseEvent *e);
/// reimplemented method from superclass
void mouseDoubleClickEvent(QMouseEvent *e);
/// reimplemented method from superclass
void keyReleaseEvent(QKeyEvent *e);
/// reimplemented method from superclass
void paintEvent(QPaintEvent * ev);
/// reimplemented method from superclass
void tabletEvent(QTabletEvent *e);
/// reimplemented method from superclass
void wheelEvent(QWheelEvent *e);
/// reimplemented method from superclass
void resizeEvent(QResizeEvent *e);
......
/* This file is part of the KDE project
* Copyright (C) 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_abstract_input_action.h"
#include <KLocalizedString>
class KisAbstractInputAction::Private
{
public:
KisInputManager* inputManager;
QString name;
QString description;
QHash<QString, int> indexes;
};
KisAbstractInputAction::KisAbstractInputAction(KisInputManager* manager) : d(new Private)
{
d->inputManager = manager;
d->indexes.insert(i18n("Activate"), 0);
}
KisAbstractInputAction::~KisAbstractInputAction()
{
}
bool KisAbstractInputAction::handleTablet() const
{
return false;
}
KisInputManager* KisAbstractInputAction::inputManager() const