diff --git a/common/gal/gal_display_options.cpp b/common/gal/gal_display_options.cpp index 803adf3d8a..f09cd19d1a 100644 --- a/common/gal/gal_display_options.cpp +++ b/common/gal/gal_display_options.cpp @@ -36,6 +36,7 @@ static const wxString GalGridStyleConfig( "GridStyle" ); static const wxString GalGridLineWidthConfig( "GridLineWidth" ); static const wxString GalGridMaxDensityConfig( "GridMaxDensity" ); static const wxString GalGridAxesEnabledConfig( "GridAxesEnabled" ); +static const wxString GalForceDisplayCursorConfig( "ForceDisplayCursor" ); static const UTIL::CFG_MAP aaModeConfigVals = @@ -60,8 +61,9 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS() : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), m_gridStyle( GRID_STYLE::DOTS ), m_gridLineWidth( 0.5 ), - m_gridMinSpacing( 10 ), - m_axesEnabled( false ) + m_gridMinSpacing( 10.0 ), + m_axesEnabled( false ), + m_forceDisplayCursor( false ) {} @@ -86,6 +88,9 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName ) aCfg->Read( aBaseName + GalGridAxesEnabledConfig, &m_axesEnabled, false ); + aCfg->Read( aBaseName + GalForceDisplayCursorConfig, + &m_forceDisplayCursor, false ); + NotifyChanged(); } @@ -106,6 +111,9 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, wxString aBaseName ) aCfg->Write( aBaseName + GalGridAxesEnabledConfig, m_axesEnabled ); + + aCfg->Write( aBaseName + GalForceDisplayCursorConfig, + m_forceDisplayCursor ); } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index ddcb76309f..b446be5641 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -67,6 +67,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetCursorSize( 80 ); SetCursorEnabled( false ); + forceDisplayCursor = false; strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ); @@ -117,6 +118,12 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) refresh = true; } + if( options.m_forceDisplayCursor != forceDisplayCursor ) + { + forceDisplayCursor = options.m_forceDisplayCursor; + refresh = true; + } + // tell the derived class if the base class needs an update or not return refresh; } diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index e2a551cbbc..bc996bb7c9 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -32,6 +32,13 @@ #include + +static TOOL_ACTION ACT_toggleCursor( "common.Control.toggleCursor", + AS_GLOBAL, MD_CTRL + MD_SHIFT + 'X', + _( "Toggle Always Show Cursor" ), + _( "Toogle display of the cursor, even when not in an interactive tool" ) ); + + COMMON_TOOLS::COMMON_TOOLS() : TOOL_INTERACTIVE( "common.Control" ), m_frame( NULL ) { @@ -188,6 +195,17 @@ int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent ) } +int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent ) +{ + auto& galOpts = m_frame->GetGalDisplayOptions(); + + galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor; + galOpts.NotifyChanged(); + + return 0; +} + + void COMMON_TOOLS::SetTransitions() { Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() ); @@ -201,6 +219,8 @@ void COMMON_TOOLS::SetTransitions() Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() ); Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() ); Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() ); + + Go( &COMMON_TOOLS::ToggleCursor, ACT_toggleCursor.MakeEvent() ); } diff --git a/common/view/view_controls.cpp b/common/view/view_controls.cpp index 4c2e10ac1b..3330653a3d 100644 --- a/common/view/view_controls.cpp +++ b/common/view/view_controls.cpp @@ -39,7 +39,9 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled ) bool VIEW_CONTROLS::IsCursorShown() const { - assert( m_settings.m_showCursor == m_view->GetGAL()->IsCursorEnabled() ); + // this only says if the VIEW_CONTROLS say the cursor should be + // shown: m_view->GetGAL()->IsCursorEnabled() will say if the GAL is + // actually going to do show the cursor or not return m_settings.m_showCursor; } diff --git a/common/widgets/gal_options_panel.cpp b/common/widgets/gal_options_panel.cpp index e18746d07d..20f8bd96ed 100644 --- a/common/widgets/gal_options_panel.cpp +++ b/common/widgets/gal_options_panel.cpp @@ -159,7 +159,7 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI sGridSettings->Add( sGridSettingsGrid, 1, wxALL|wxEXPAND, 5 ); - sLeftSizer->Add( sGridSettings, 1, wxALL | wxEXPAND, 5 ); + sLeftSizer->Add( sGridSettings, 0, wxALL | wxEXPAND, 5 ); // bind the spin buttons and text boxes m_gridSizeIncrementer = std::make_unique( @@ -176,6 +176,18 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI gridMinSpacingStep ); m_gridMinSpacingIncrementer->SetPrecision( 0 ); // restrict to ints } + + { + auto sCursorSettings = new wxStaticBoxSizer( new wxStaticBox( this, + wxID_ANY, _("Cursor Display (OpenGL && Cairo)") ), wxVERTICAL ); + + sLeftSizer->Add( sCursorSettings, 1, wxALL | wxEXPAND, 5 ); + + m_forceCursorDisplay = new wxCheckBox( this, wxID_ANY, _( "Always display cursor" ) ); + + sCursorSettings->Add( m_forceCursorDisplay, 0, wxALL | wxEXPAND, 5 ); + } + } @@ -191,6 +203,8 @@ bool GAL_OPTIONS_PANEL::TransferDataToWindow() m_gridMinSpacingIncrementer->SetValue( m_galOptions.m_gridMinSpacing ); + m_forceCursorDisplay->SetValue( m_galOptions.m_forceDisplayCursor ); + return true; } @@ -207,6 +221,8 @@ bool GAL_OPTIONS_PANEL::TransferDataFromWindow() m_galOptions.m_gridMinSpacing = m_gridMinSpacingIncrementer->GetValue(); + m_galOptions.m_forceDisplayCursor = m_forceCursorDisplay->GetValue(); + m_galOptions.NotifyChanged(); return true; diff --git a/include/gal/gal_display_options.h b/include/gal/gal_display_options.h index 733cb2b918..d9e684b73d 100644 --- a/include/gal/gal_display_options.h +++ b/include/gal/gal_display_options.h @@ -84,6 +84,9 @@ namespace KIGFX ///> Whether or not to draw the coordinate system axes bool m_axesEnabled; + + ///> Force cursor display + bool m_forceDisplayCursor; }; } diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index c9b9fac9b4..341bb149fd 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -904,7 +904,7 @@ public: */ bool IsCursorEnabled() const { - return isCursorEnabled; + return isCursorEnabled || forceDisplayCursor; } /** @@ -1019,6 +1019,7 @@ protected: // Cursor settings bool isCursorEnabled; ///< Is the cursor enabled? + bool forceDisplayCursor; ///< Always show cursor COLOR4D cursorColor; ///< Cursor color unsigned int cursorSize; ///< Size of the cursor in pixels VECTOR2D cursorPosition; ///< Current cursor position (world coordinates) diff --git a/include/tool/common_tools.h b/include/tool/common_tools.h index 9f604026f5..d3dd3836b1 100644 --- a/include/tool/common_tools.h +++ b/include/tool/common_tools.h @@ -51,6 +51,9 @@ public: int ZoomFitScreen( const TOOL_EVENT& aEvent ); int ZoomPreset( const TOOL_EVENT& aEvent ); + // Cursor control + int ToggleCursor( const TOOL_EVENT& aEvent ); + // Grid control int GridNext( const TOOL_EVENT& aEvent ); int GridPrev( const TOOL_EVENT& aEvent ); diff --git a/include/widgets/gal_options_panel.h b/include/widgets/gal_options_panel.h index 94d905f463..8bbfbc51cb 100644 --- a/include/widgets/gal_options_panel.h +++ b/include/widgets/gal_options_panel.h @@ -52,16 +52,21 @@ private: wxBoxSizer* m_mainSizer; wxChoice* m_choiceAntialiasing; + wxRadioBox* m_gridStyle; + wxStaticText* l_gridLineWidth; wxTextCtrl* m_gridLineWidth; wxSpinButton* m_gridLineWidthSpinBtn; wxStaticText* l_gridLineWidthUnits; + wxStaticText* l_gridMinSpacing; wxTextCtrl* m_gridMinSpacing; wxSpinButton* m_gridMinSpacingSpinBtn; wxStaticText* l_gridMinSpacingUnits; + wxCheckBox* m_forceCursorDisplay; + ///> The GAL options to read/write KIGFX::GAL_DISPLAY_OPTIONS& m_galOptions;