From d1550b0cdb990ba1f4f32220e110f8ff6331a5f1 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 6 Mar 2017 11:41:06 +0100 Subject: [PATCH] Renamed VIEW_CONTROLS::SETTINGS to VC_SETTINGS. Because nested types cannot be forwarded. --- common/tool/tool_manager.cpp | 2 +- common/view/view_controls.cpp | 6 +- include/view/view_controls.h | 102 ++++++++++++++++++---------------- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index bd0a1e5928..63a1e1fb5d 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -112,7 +112,7 @@ struct TOOL_MANAGER::TOOL_STATE std::vector transitions; /// VIEW_CONTROLS settings to preserve settings when the tools are switched - KIGFX::VIEW_CONTROLS::SETTINGS vcSettings; + KIGFX::VC_SETTINGS vcSettings; void operator=( const TOOL_STATE& aState ) { diff --git a/common/view/view_controls.cpp b/common/view/view_controls.cpp index c5e5b1b00e..ed60d51428 100644 --- a/common/view/view_controls.cpp +++ b/common/view/view_controls.cpp @@ -47,12 +47,12 @@ bool VIEW_CONTROLS::IsCursorShown() const void VIEW_CONTROLS::Reset() { // Get the default settings from the default constructor - SETTINGS dummy; + VC_SETTINGS dummy; ApplySettings( dummy ); } -void VIEW_CONTROLS::SETTINGS::Reset() +void VC_SETTINGS::Reset() { m_showCursor = false; m_forceCursorPosition = false; @@ -67,7 +67,7 @@ void VIEW_CONTROLS::SETTINGS::Reset() } -void VIEW_CONTROLS::ApplySettings( const SETTINGS& aSettings ) +void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings ) { ShowCursor( aSettings.m_showCursor ); CaptureCursor( aSettings.m_cursorCaptured ); diff --git a/include/view/view_controls.h b/include/view/view_controls.h index 1a8aa7a4f8..cd7cb432e5 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -40,6 +40,52 @@ namespace KIGFX { class VIEW; +///> Structure to keep VIEW_CONTROLS settings for easy store/restore operations +struct VC_SETTINGS +{ + VC_SETTINGS() + { + Reset(); + } + + ///> Restores the default settings + void Reset(); + + ///> Flag determining the cursor visibility + bool m_showCursor; + + ///> Forced cursor position (world coordinates) + VECTOR2D m_forcedPosition; + + ///> Is the forced cursor position enabled + bool m_forceCursorPosition; + + ///> Should the cursor be locked within the parent window area + bool m_cursorCaptured; + + ///> Should the cursor snap to grid or move freely + bool m_snappingEnabled; + + ///> Flag for grabbing the mouse cursor + bool m_grabMouse; + + ///> Flag for turning on autopanning + bool m_autoPanEnabled; + + ///> Distance from cursor to VIEW edge when panning is active + float m_autoPanMargin; + + ///> How fast is panning when in auto mode + float m_autoPanSpeed; + + ///> If the cursor is allowed to be warped + bool m_warpCursor; + + ///> Mousewheel (2-finger touchpad) panning + bool m_enableMousewheelPan; +}; + + /** * Class VIEW_CONTROLS * is an interface for classes handling user events controlling the view behaviour @@ -173,6 +219,11 @@ public: m_settings.m_cursorCaptured = aEnabled; } + /** + * Function IsCursorPositionForced() + * Returns true if the cursor position is set by one of the tools. Forced cursor position + * means it does not react to mouse movement. + */ inline bool IsCursorPositionForced() const { return m_settings.m_forceCursorPosition; @@ -242,66 +293,21 @@ public: */ virtual void Reset(); - ///> Structure to keep VIEW_CONTROLS settings for easy store/restore operations - struct SETTINGS - { - SETTINGS() - { - Reset(); - } - - ///> Restores the default settings - void Reset(); - - ///> Flag determining the cursor visibility - bool m_showCursor; - - ///> Forced cursor position (world coordinates) - VECTOR2D m_forcedPosition; - - ///> Is the forced cursor position enabled - bool m_forceCursorPosition; - - ///> Should the cursor be locked within the parent window area - bool m_cursorCaptured; - - ///> Should the cursor snap to grid or move freely - bool m_snappingEnabled; - - ///> Flag for grabbing the mouse cursor - bool m_grabMouse; - - ///> Flag for turning on autopanning - bool m_autoPanEnabled; - - ///> Distance from cursor to VIEW edge when panning is active - float m_autoPanMargin; - - ///> How fast is panning when in auto mode - float m_autoPanSpeed; - - ///> If the cursor is allowed to be warped - bool m_warpCursor; - - ///> Mousewheel (2-finger touchpad) panning - bool m_enableMousewheelPan; - }; - ///> Returns the current VIEW_CONTROLS settings - const SETTINGS& GetSettings() const + const VC_SETTINGS& GetSettings() const { return m_settings; } ///> Applies VIEW_CONTROLS settings from an object - void ApplySettings( const SETTINGS& aSettings ); + void ApplySettings( const VC_SETTINGS& aSettings ); protected: ///> Pointer to controlled VIEW. VIEW* m_view; ///> Current VIEW_CONTROLS settings - SETTINGS m_settings; + VC_SETTINGS m_settings; }; } // namespace KIGFX