Renamed VIEW_CONTROLS::SETTINGS to VC_SETTINGS.

Because nested types cannot be forwarded.
This commit is contained in:
Maciej Suminski 2017-03-06 11:41:06 +01:00
parent 3174573361
commit d1550b0cdb
3 changed files with 58 additions and 52 deletions

View File

@ -112,7 +112,7 @@ struct TOOL_MANAGER::TOOL_STATE
std::vector<TRANSITION> transitions; std::vector<TRANSITION> transitions;
/// VIEW_CONTROLS settings to preserve settings when the tools are switched /// 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 ) void operator=( const TOOL_STATE& aState )
{ {

View File

@ -47,12 +47,12 @@ bool VIEW_CONTROLS::IsCursorShown() const
void VIEW_CONTROLS::Reset() void VIEW_CONTROLS::Reset()
{ {
// Get the default settings from the default constructor // Get the default settings from the default constructor
SETTINGS dummy; VC_SETTINGS dummy;
ApplySettings( dummy ); ApplySettings( dummy );
} }
void VIEW_CONTROLS::SETTINGS::Reset() void VC_SETTINGS::Reset()
{ {
m_showCursor = false; m_showCursor = false;
m_forceCursorPosition = 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 ); ShowCursor( aSettings.m_showCursor );
CaptureCursor( aSettings.m_cursorCaptured ); CaptureCursor( aSettings.m_cursorCaptured );

View File

@ -40,6 +40,52 @@ namespace KIGFX
{ {
class VIEW; 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 * Class VIEW_CONTROLS
* is an interface for classes handling user events controlling the view behaviour * is an interface for classes handling user events controlling the view behaviour
@ -173,6 +219,11 @@ public:
m_settings.m_cursorCaptured = aEnabled; 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 inline bool IsCursorPositionForced() const
{ {
return m_settings.m_forceCursorPosition; return m_settings.m_forceCursorPosition;
@ -242,66 +293,21 @@ public:
*/ */
virtual void Reset(); 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 ///> Returns the current VIEW_CONTROLS settings
const SETTINGS& GetSettings() const const VC_SETTINGS& GetSettings() const
{ {
return m_settings; return m_settings;
} }
///> Applies VIEW_CONTROLS settings from an object ///> Applies VIEW_CONTROLS settings from an object
void ApplySettings( const SETTINGS& aSettings ); void ApplySettings( const VC_SETTINGS& aSettings );
protected: protected:
///> Pointer to controlled VIEW. ///> Pointer to controlled VIEW.
VIEW* m_view; VIEW* m_view;
///> Current VIEW_CONTROLS settings ///> Current VIEW_CONTROLS settings
SETTINGS m_settings; VC_SETTINGS m_settings;
}; };
} // namespace KIGFX } // namespace KIGFX