Commit 65c11662 authored by Maciej Suminski's avatar Maciej Suminski

Added support for changing the cursor size.

parent 15f5c228
...@@ -75,6 +75,9 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -75,6 +75,9 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetSize( aParent->GetSize() ); SetSize( aParent->GetSize() );
screenSize = VECTOR2I( aParent->GetSize() ); screenSize = VECTOR2I( aParent->GetSize() );
cursorPixels = NULL;
cursorPixelsSaved = NULL;
initCursor(); initCursor();
// Grid color settings are different in Cairo and OpenGL // Grid color settings are different in Cairo and OpenGL
...@@ -808,6 +811,13 @@ void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget ) ...@@ -808,6 +811,13 @@ void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget )
} }
void CAIRO_GAL::SetCursorSize( unsigned int aCursorSize )
{
GAL::SetCursorSize( aCursorSize );
initCursor();
}
void CAIRO_GAL::DrawCursor( const VECTOR2D& aCursorPosition ) void CAIRO_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
{ {
// Now we should only store the position of the mouse cursor // Now we should only store the position of the mouse cursor
...@@ -890,6 +900,12 @@ void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent ) ...@@ -890,6 +900,12 @@ void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent )
void CAIRO_GAL::initCursor() void CAIRO_GAL::initCursor()
{ {
if( cursorPixels )
delete cursorPixels;
if( cursorPixelsSaved )
delete cursorPixelsSaved;
cursorPixels = new wxBitmap( cursorSize, cursorSize ); cursorPixels = new wxBitmap( cursorSize, cursorSize );
cursorPixelsSaved = new wxBitmap( cursorSize, cursorSize ); cursorPixelsSaved = new wxBitmap( cursorSize, cursorSize );
......
...@@ -229,6 +229,9 @@ public: ...@@ -229,6 +229,9 @@ public:
// Cursor // Cursor
// ------- // -------
/// @copydoc GAL::SetCursorSize()
virtual void SetCursorSize( unsigned int aCursorSize );
/// @copydoc GAL::DrawCursor() /// @copydoc GAL::DrawCursor()
virtual void DrawCursor( const VECTOR2D& aCursorPosition ); virtual void DrawCursor( const VECTOR2D& aCursorPosition );
......
...@@ -783,12 +783,22 @@ public: ...@@ -783,12 +783,22 @@ public:
cursorColor = aCursorColor; cursorColor = aCursorColor;
} }
/**
* @brief Returns the cursor size.
*
* @return The current cursor size (in pixels).
*/
inline unsigned int GetCursorSize() const
{
return cursorSize;
}
/** /**
* @brief Set the cursor size. * @brief Set the cursor size.
* *
* @param aCursorSize is the size of the cursor expressed in pixels. * @param aCursorSize is the size of the cursor expressed in pixels.
*/ */
inline void SetCursorSize( unsigned int aCursorSize ) virtual inline void SetCursorSize( unsigned int aCursorSize )
{ {
cursorSize = aCursorSize; cursorSize = aCursorSize;
} }
......
...@@ -29,13 +29,16 @@ ...@@ -29,13 +29,16 @@
// Selection tool actions // Selection tool actions
TOOL_ACTION COMMON_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection", TOOL_ACTION COMMON_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection",
AS_GLOBAL, 0, "", "", AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere AS_GLOBAL, 0,
"", "", AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION COMMON_ACTIONS::selectionSingle( "pcbnew.InteractiveSelection.Single", TOOL_ACTION COMMON_ACTIONS::selectionSingle( "pcbnew.InteractiveSelection.Single",
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION COMMON_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear", TOOL_ACTION COMMON_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear",
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
// Edit tool actions // Edit tool actions
...@@ -287,6 +290,10 @@ TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", ...@@ -287,6 +290,10 @@ TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords",
AS_GLOBAL, ' ', AS_GLOBAL, ' ',
"", "" ); "", "" );
TOOL_ACTION COMMON_ACTIONS::switchCursor( "pcbnew.Control.switchCursor",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.Control.switchUnits", TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.Control.switchUnits",
AS_GLOBAL, MD_CTRL + int( 'U' ), AS_GLOBAL, MD_CTRL + int( 'U' ),
"", "" ); "", "" );
...@@ -304,7 +311,8 @@ TOOL_ACTION COMMON_ACTIONS::routerActivate( "pcbnew.InteractiveRouter", ...@@ -304,7 +311,8 @@ TOOL_ACTION COMMON_ACTIONS::routerActivate( "pcbnew.InteractiveRouter",
"Run push & shove router", "Run push & shove router", AF_ACTIVATE ); "Run push & shove router", "Run push & shove router", AF_ACTIVATE );
TOOL_ACTION COMMON_ACTIONS::pointEditorUpdate( "pcbnew.PointEditor.update", TOOL_ACTION COMMON_ACTIONS::pointEditorUpdate( "pcbnew.PointEditor.update",
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
// Placement tool // Placement tool
...@@ -420,6 +428,9 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId ) ...@@ -420,6 +428,9 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
return COMMON_ACTIONS::highContrastMode.MakeEvent(); return COMMON_ACTIONS::highContrastMode.MakeEvent();
case ID_TB_OPTIONS_SELECT_CURSOR:
return COMMON_ACTIONS::switchCursor.MakeEvent();
case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
case ID_PCB_DELETE_ITEM_BUTT: case ID_PCB_DELETE_ITEM_BUTT:
...@@ -427,7 +438,6 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId ) ...@@ -427,7 +438,6 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
case ID_PCB_SHOW_1_RATSNEST_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT:
case ID_PCB_PLACE_OFFSET_COORD_BUTT: case ID_PCB_PLACE_OFFSET_COORD_BUTT:
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST: case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
case ID_TB_OPTIONS_SELECT_CURSOR:
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE: case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR: case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR:
case ID_MICROWAVE_V_TOOLBAR: case ID_MICROWAVE_V_TOOLBAR:
......
...@@ -189,6 +189,7 @@ public: ...@@ -189,6 +189,7 @@ public:
// Miscellaneous // Miscellaneous
static TOOL_ACTION resetCoords; static TOOL_ACTION resetCoords;
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits; static TOOL_ACTION switchUnits;
static TOOL_ACTION showHelp; static TOOL_ACTION showHelp;
static TOOL_ACTION toBeDone; static TOOL_ACTION toBeDone;
......
...@@ -541,6 +541,24 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) ...@@ -541,6 +541,24 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent )
} }
int PCBNEW_CONTROL::SwitchCursor( TOOL_EVENT& aEvent )
{
const unsigned int BIG_CURSOR = 4000;
const unsigned int SMALL_CURSOR = 80;
KIGFX::GAL* gal = getEditFrame<PCB_BASE_FRAME>()->GetGalCanvas()->GetGAL();
if( gal->GetCursorSize() == BIG_CURSOR )
gal->SetCursorSize( SMALL_CURSOR );
else
gal->SetCursorSize( BIG_CURSOR );
setTransitions();
return 0;
}
int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent )
{ {
// TODO should not it be refactored to pcb_frame member function? // TODO should not it be refactored to pcb_frame member function?
...@@ -621,6 +639,7 @@ void PCBNEW_CONTROL::setTransitions() ...@@ -621,6 +639,7 @@ void PCBNEW_CONTROL::setTransitions()
// Miscellaneous // Miscellaneous
Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() ); Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() );
Go( &PCBNEW_CONTROL::SwitchCursor, COMMON_ACTIONS::switchCursor.MakeEvent() );
Go( &PCBNEW_CONTROL::SwitchUnits, COMMON_ACTIONS::switchUnits.MakeEvent() ); Go( &PCBNEW_CONTROL::SwitchUnits, COMMON_ACTIONS::switchUnits.MakeEvent() );
Go( &PCBNEW_CONTROL::ShowHelp, COMMON_ACTIONS::showHelp.MakeEvent() ); Go( &PCBNEW_CONTROL::ShowHelp, COMMON_ACTIONS::showHelp.MakeEvent() );
Go( &PCBNEW_CONTROL::ToBeDone, COMMON_ACTIONS::toBeDone.MakeEvent() ); Go( &PCBNEW_CONTROL::ToBeDone, COMMON_ACTIONS::toBeDone.MakeEvent() );
......
...@@ -90,6 +90,7 @@ public: ...@@ -90,6 +90,7 @@ public:
// Miscellaneous // Miscellaneous
int ResetCoords( TOOL_EVENT& aEvent ); int ResetCoords( TOOL_EVENT& aEvent );
int SwitchCursor( TOOL_EVENT& aEvent );
int SwitchUnits( TOOL_EVENT& aEvent ); int SwitchUnits( TOOL_EVENT& aEvent );
int ShowHelp( TOOL_EVENT& aEvent ); int ShowHelp( TOOL_EVENT& aEvent );
int ToBeDone( TOOL_EVENT& aEvent ); int ToBeDone( TOOL_EVENT& aEvent );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment