diff --git a/bitmaps_png/cursors/README.md b/bitmaps_png/cursors/README.md new file mode 100644 index 0000000000..80e098f5c5 --- /dev/null +++ b/bitmaps_png/cursors/README.md @@ -0,0 +1,7 @@ +The following cursors were borrowed by the Inkspace project https://gitlab.com/inkscape/inkscape/ +- cursor-connector.xpm +- cursor-eraser.xpm +- cursor-measure.xpm +- cursor-pencil.xpm +- cursor-select-m.xpm +- cursor-text.xpm \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-add.xpm b/bitmaps_png/cursors/cursor-add.xpm new file mode 100644 index 0000000000..94e35d4899 --- /dev/null +++ b/bitmaps_png/cursors/cursor-add.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_add_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" # ## ", +" #!!# ", +" ##!!## ", +" #!!!!!!# ", +" #!!!!!!# ", +" ##!!## ", +" #!!# ", +" ## ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-connector.xpm b/bitmaps_png/cursors/cursor-connector.xpm new file mode 100644 index 0000000000..86e8d17535 --- /dev/null +++ b/bitmaps_png/cursors/cursor-connector.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_connector_xpm[] = { +"32 32 3 1 1 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ... ", +"....+.... .+. ", +" .+. .+. ", +" .+. .+. ", +" ... .+. ", +" .+. ", +" .+. ", +" .+. ", +" .+. ", +" ...........+. ", +" .+++++++++++. ", +" .+........... ", +" .+. ", +" .+. ", +" ...+... ", +" .+++++. ", +" .+++. ", +" .+. ", +" . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/bitmaps_png/cursors/cursor-eraser.xpm b/bitmaps_png/cursors/cursor-eraser.xpm new file mode 100644 index 0000000000..b3f8f2d848 --- /dev/null +++ b/bitmaps_png/cursors/cursor-eraser.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_eraser_xpm[] = { +"32 32 3 1 4 4", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ... ", +" .+. .+++. ", +" .+. .+...+. ", +" ... .+.....+. ", +" .+.......+. ", +" .+.........+. ", +" .++..........+. ", +" .++...........+. ", +" .+.+...........+. ", +" .+..+..........++. ", +" .+...+.........++. ", +" .+...+.......+.+. ", +" .+...+.....+..+. ", +" .+...+...+...+. ", +" .+...+++...+. ", +" .+...+...+. ", +" .+..+..+. ", +" .+.+.+. ", +" .+++. ", +" ... ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/bitmaps_png/cursors/cursor-measure.xpm b/bitmaps_png/cursors/cursor-measure.xpm new file mode 100644 index 0000000000..9f6497c651 --- /dev/null +++ b/bitmaps_png/cursors/cursor-measure.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_measure_xpm[] = { +"32 32 3 1 4 4", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. .. ", +" ... .++. ", +" .+..+. ", +" .+....+. ", +" .+..+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+.+. ", +" .+.+.+. ", +" .+.+. ", +" .+. ", +" . ", +" ", +" ", +" ", +" "}; diff --git a/bitmaps_png/cursors/cursor-pencil.xpm b/bitmaps_png/cursors/cursor-pencil.xpm new file mode 100644 index 0000000000..92c6331ab3 --- /dev/null +++ b/bitmaps_png/cursors/cursor-pencil.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_pencil_xpm[] = { +"32 32 3 1 4 4", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. ... ", +" ... .++... ", +" .+++++... ", +" .+++.+++.. ", +" .++.....++. ", +" .+........+. ", +" .+......+.+. ", +" .+....+++..+. ", +" .+...+...+..+. ", +" .+..+....+..+. ", +" .+.++.....+..+. ", +" .+..+.....+. +. ", +" .+..+.....+. ", +" .+..+... .+. ", +" .+..+. . . ", +" .+..+. . ", +" .+ .+. ", +" .+ . ", +" . ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/bitmaps_png/cursors/cursor-select-m.xpm b/bitmaps_png/cursors/cursor-select-m.xpm new file mode 100644 index 0000000000..8dd8fb076f --- /dev/null +++ b/bitmaps_png/cursors/cursor-select-m.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_select_m_xpm[] = { +"32 32 3 1 1 1", +" c None", +". c #000000", +"+ c #FFFFFF", +". ", +".. ", +".+. ", +".++. ", +".+++. ", +".++++. ", +".+++++. ", +".++++++. ", +".+++++++. ", +".++++++++. ", +".+++++++++. ", +".++++++..... ", +".++++++. ", +".++..++. ", +".+. .+++. ", +".. .++. ", +". .+++. + ", +" .+. +.+ ", +" .. +...+ ", +" +.....+ ", +" + ++.++ + ", +" +.+ +.+ +.+ ", +" +..+++.+++..+ ", +" +.............+ ", +" +..+++.+++..+ ", +" +.+ +.+ +.+ ", +" + ++.++ + ", +" +.....+ ", +" +...+ ", +" +.+ ", +" + ", +" "}; diff --git a/bitmaps_png/cursors/cursor-subtract.xpm b/bitmaps_png/cursors/cursor-subtract.xpm new file mode 100644 index 0000000000..fe29eef8da --- /dev/null +++ b/bitmaps_png/cursors/cursor-subtract.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_subtract_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" # ", +" ", +" ###### ", +" #!!!!!!# ", +" #!!!!!!# ", +" ###### ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-text.xpm b/bitmaps_png/cursors/cursor-text.xpm new file mode 100644 index 0000000000..9bdb6f7b8b --- /dev/null +++ b/bitmaps_png/cursors/cursor-text.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_text_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# #### ", +" #!# #!!!!# ", +" #!# #!!!!# ", +" # #!!!!!!# ", +" #!!!!!!# ", +" #!!##!!# ", +" #!!!##!!!# ", +" #!!!##!!!# ", +" #!!!!!!!!# ", +" #!!!!!!!!!!# ", +" #!!!####!!!# ", +" #!!!# #!!!# ", +" #!!!# #!!!# ", +" ### ### ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-xor.xpm b/bitmaps_png/cursors/cursor-xor.xpm new file mode 100644 index 0000000000..7bf4434f73 --- /dev/null +++ b/bitmaps_png/cursors/cursor-xor.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_xor_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# # ", +" # #!# ", +" #!!!# ", +" #!!#!!# ", +" #!!# #!!# ", +" #!# #!# ", +" # # ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c0fbac65ba..4d67b88f3e 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories( ./dialogs ./widgets ./dialog_about + ${CMAKE_SOURCE_DIR}/bitmaps_png ${CMAKE_SOURCE_DIR}/3d-viewer ${CMAKE_SOURCE_DIR}/pcbnew ${INC_AFTER} @@ -310,7 +311,7 @@ set( COMMON_SRCS common.cpp config_params.cpp confirm.cpp - cursor_store.cpp + cursors.cpp dialog_shim.cpp gr_text.cpp dsnlexer.cpp diff --git a/common/cursor_store.cpp b/common/cursor_store.cpp deleted file mode 100644 index 2769f59196..0000000000 --- a/common/cursor_store.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include -#include - - -/** - * Construct a cursor for the given definition. - * - * How to do this depends on the platform, see - * http://docs.wxwidgets.org/trunk/classwx_cursor.html - * - * @param aDef the cursor definition - * @return a newly constructed cursor if the platform is supported, - * else wxNullCursor - */ -wxCursor constructCursor( const CURSOR_STORE::CURSOR_DEF& aDef ) -{ -#if defined( __WXMSW__ ) || defined( __WXMAC__ ) - - wxBitmap img_bitmap( - reinterpret_cast( aDef.m_image_data ), aDef.m_size.x, aDef.m_size.y ); - wxBitmap msk_bitmap( - reinterpret_cast( aDef.m_mask_data ), aDef.m_size.x, aDef.m_size.y ); - img_bitmap.SetMask( new wxMask( msk_bitmap ) ); - - wxImage image( img_bitmap.ConvertToImage() ); - -#if defined( __WXMSW__ ) - image.SetMaskColour( 255, 255, 255 ); -#endif - - image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, aDef.m_hotspot.x ); - image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, aDef.m_hotspot.y ); - - return wxCursor{ image }; - -#elif defined( __WXGTK__ ) || defined( __WXMOTIF__ ) - - return wxCursor{ - reinterpret_cast( aDef.m_image_data ), - aDef.m_size.x, - aDef.m_size.y, - aDef.m_hotspot.x, - aDef.m_hotspot.y, - reinterpret_cast( aDef.m_mask_data ), - }; - -#else - wxASSERT_MSG( false, "Unknown platform for cursor construction." ); - return wxNullCursor; -#endif -} - - -CURSOR_STORE::CURSOR_STORE( const std::vector& aDefs ) -{ - for( const auto& def : aDefs ) - { - m_store[def.m_id_key] = constructCursor( def ); - } -} - - -const wxCursor& CURSOR_STORE::Get( int aIdKey ) const -{ - const auto find_iter = m_store.find( aIdKey ); - - if( find_iter != m_store.end() ) - { - return find_iter->second; - } - - wxASSERT_MSG( false, - wxString::Format( "Could not find cursor with ID %d", static_cast( aIdKey ) ) ); - return wxNullCursor; -} diff --git a/common/cursors.cpp b/common/cursors.cpp new file mode 100644 index 0000000000..7e31e2cbc3 --- /dev/null +++ b/common/cursors.cpp @@ -0,0 +1,313 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * 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, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +static const unsigned char voltage_probe[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x30, 0x06, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x0e, 0x08, 0x00, 0x80, 0x07, 0x08, 0x00, + 0xc0, 0x07, 0x18, 0x00, 0xe0, 0x07, 0x30, 0x00, 0xf0, 0x03, 0x60, 0x00, 0xf8, 0x01, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0xc0, + 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, + 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const unsigned char current_probe[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x60, 0x06, 0x00, + 0x00, 0x30, 0x0c, 0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 0x0f, 0x08, 0x00, 0x80, 0x0f, 0x18, 0x00, + 0xc0, 0x0f, 0x30, 0x80, 0xe1, 0x07, 0x60, 0x80, 0xf1, 0x03, 0x00, 0x80, 0xf9, 0x01, 0x00, 0x80, + 0xfd, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0xc0, + 0x0f, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xc6, 0x01, 0x00, 0x00, 0x83, + 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xfc, + 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00 }; + +static const unsigned char cursor_tune[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, 0x00, + 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, + 0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, + 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + +static const unsigned char cursor_tune_mask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, + 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xfc, 0x07, + 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, + 0x00, 0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + + +static const std::vector standard_cursors = { + { + KICURSOR::VOLTAGE_PROBE, + voltage_probe, + voltage_probe, + nullptr, + { 32, 32 }, + { 1, 31 }, + }, + { + KICURSOR::CURRENT_PROBE, + current_probe, + current_probe, + nullptr, + { 32, 32 }, + { 4, 27 }, + }, + { + KICURSOR::TUNE, + cursor_tune, + cursor_tune_mask, + nullptr, + { 32, 32 }, + { 1, 30 }, + }, + { + KICURSOR::PENCIL, + nullptr, + nullptr, + cursor_pencil_xpm, + { 32, 32 }, + { 4, 4 }, + }, + { + KICURSOR::MOVING, + nullptr, + nullptr, + cursor_select_m_xpm, + { 32, 32 }, + { 1, 1 }, + }, + { + KICURSOR::REMOVE, + nullptr, + nullptr, + cursor_eraser_xpm, + { 32, 32 }, + { 4, 4 }, + }, + { + KICURSOR::WIRE, + nullptr, + nullptr, + cursor_connector_xpm, + { 32, 32 }, + { 1, 1 }, + }, + { + KICURSOR::TEXT, + nullptr, + nullptr, + cursor_text_xpm, + { 32, 32 }, + { 7, 10 }, + }, + { + KICURSOR::MEASURE, + nullptr, + nullptr, + cursor_measure_xpm, + { 32, 32 }, + { 4, 4 }, + }, + { + KICURSOR::ADD, + nullptr, + nullptr, + cursor_add_xpm, + { 32, 32 }, + { 7, 10 }, + }, + { + KICURSOR::SUBTRACT, + nullptr, + nullptr, + cursor_subtract_xpm, + { 32, 32 }, + { 7, 10 }, + }, + { + KICURSOR::XOR, + nullptr, + nullptr, + cursor_xor_xpm, + { 32, 32 }, + { 7, 10 }, + }, +}; + + +/** + * Construct a cursor for the given definition. + * + * How to do this depends on the platform, see + * http://docs.wxwidgets.org/trunk/classwx_cursor.html + * + * @param aDef the cursor definition + * @return a newly constructed cursor if the platform is supported, + * else wxNullCursor + */ +wxCursor constructCursor( const CURSOR_STORE::CURSOR_DEF& aDef ) +{ + if( aDef.m_xpm != nullptr ) + { + wxImage xpmImage = wxImage( aDef.m_xpm ); + + xpmImage.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, aDef.m_hotspot.x ); + xpmImage.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, aDef.m_hotspot.y ); + + return wxCursor( xpmImage ); + } + else if( aDef.m_image_data != nullptr && aDef.m_mask_data != nullptr ) + { +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) + + wxBitmap img_bitmap( + reinterpret_cast( aDef.m_image_data ), aDef.m_size.x, aDef.m_size.y ); + wxBitmap msk_bitmap( + reinterpret_cast( aDef.m_mask_data ), aDef.m_size.x, aDef.m_size.y ); + img_bitmap.SetMask( new wxMask( msk_bitmap ) ); + + wxImage image( img_bitmap.ConvertToImage() ); + +#if defined( __WXMSW__ ) + image.SetMaskColour( 255, 255, 255 ); +#endif + + image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, aDef.m_hotspot.x ); + image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, aDef.m_hotspot.y ); + + return wxCursor{ image }; + +#elif defined( __WXGTK__ ) || defined( __WXMOTIF__ ) + + return wxCursor{ + reinterpret_cast( aDef.m_image_data ), + aDef.m_size.x, + aDef.m_size.y, + aDef.m_hotspot.x, + aDef.m_hotspot.y, + reinterpret_cast( aDef.m_mask_data ), + }; + +#else + wxASSERT_MSG( false, "Unknown platform for cursor construction." ); + return wxNullCursor; +#endif + } + + wxASSERT_MSG( false, "Unknown to find cursor" ); + return wxNullCursor; +} + + +CURSOR_STORE::CURSOR_STORE( const std::vector& aDefs ) +{ + for( const auto& def : aDefs ) + { + m_store[def.m_id_key] = constructCursor( def ); + } +} + + +const wxCursor& CURSOR_STORE::Get( KICURSOR aIdKey ) const +{ + const auto find_iter = m_store.find( aIdKey ); + + if( find_iter != m_store.end() ) + { + return find_iter->second; + } + + wxASSERT_MSG( false, + wxString::Format( "Could not find cursor with ID %d", static_cast( aIdKey ) ) ); + return wxNullCursor; +} + + +const wxCursor CURSOR_STORE::GetCursor( KICURSOR aCursorType ) +{ + wxStockCursor stock = + GetStockCursor( aCursorType ); + if( stock != wxCURSOR_MAX ) + { + return wxCursor( stock ); + } + + static CURSOR_STORE store( standard_cursors ); + return store.Get( aCursorType ); +} + + +const wxStockCursor CURSOR_STORE::GetStockCursor( KICURSOR aCursorType ) +{ + wxStockCursor stockCursor; + switch( aCursorType ) + { + case KICURSOR::MOVING: + stockCursor = wxCURSOR_SIZING; + break; + case KICURSOR::BULLSEYE: + stockCursor = wxCURSOR_BULLSEYE; + break; + case KICURSOR::HAND: + stockCursor = wxCURSOR_HAND; + break; + case KICURSOR::ARROW: + stockCursor = wxCURSOR_ARROW; + break; + default: + stockCursor = wxCURSOR_MAX; + break; + } + + if( !KIPLATFORM::UI::IsStockCursorOk( stockCursor ) ) + { + stockCursor = wxCURSOR_MAX; + } + + return stockCursor; +} \ No newline at end of file diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index a4b241fede..6b51110205 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -64,8 +65,9 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin m_lostFocus( false ), m_stealsFocus( true ) { - m_parent = aParentWindow; - m_currentCursor = wxStockCursor( wxCURSOR_ARROW ); + m_parent = aParentWindow; + m_currentKiCursor = KICURSOR::DEFAULT; + SetCurrentCursor( KICURSOR::ARROW ); SetLayoutDirection( wxLayout_LeftToRight ); @@ -567,18 +569,16 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent ) } -void EDA_DRAW_PANEL_GAL::SetCurrentCursor( wxStockCursor aStockCursorID ) +void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR cursor ) { - if ( aStockCursorID <= wxCURSOR_NONE || aStockCursorID >= wxCURSOR_MAX ) - aStockCursorID = wxCURSOR_ARROW; + if( m_currentKiCursor == cursor ) + { + return; + } - SetCurrentCursor( wxCursor( aStockCursorID ) ); -} + m_currentCursor = CURSOR_STORE::GetCursor( cursor ); + m_currentKiCursor = cursor; - -void EDA_DRAW_PANEL_GAL::SetCurrentCursor( const wxCursor& aCursor ) -{ - m_currentCursor = aCursor; SetCursor( m_currentCursor ); } diff --git a/common/tool/picker_tool.cpp b/common/tool/picker_tool.cpp index c62ea2da40..8f8410fe38 100644 --- a/common/tool/picker_tool.cpp +++ b/common/tool/picker_tool.cpp @@ -179,7 +179,7 @@ void PICKER_TOOL::setTransitions() void PICKER_TOOL::resetPicker() { - m_cursor = wxStockCursor( wxCURSOR_ARROW ); + m_cursor = KICURSOR::ARROW; m_picked = NULLOPT; m_clickHandler = NULLOPT; diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index 10f3fd0f7d..7ff64e0fbe 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -51,7 +51,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); if( evt->IsCancelInteractive() || evt->IsActivate() ) break; diff --git a/cvpcb/tools/cvpcb_fpviewer_selection_tool.cpp b/cvpcb/tools/cvpcb_fpviewer_selection_tool.cpp index 9860d42fc4..4a8665500e 100644 --- a/cvpcb/tools/cvpcb_fpviewer_selection_tool.cpp +++ b/cvpcb/tools/cvpcb_fpviewer_selection_tool.cpp @@ -55,7 +55,7 @@ int CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { if( m_frame->ToolStackIsEmpty() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); // single click? Select single object if( evt->IsClick( BUT_LEFT ) ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index c04054c8a9..efcc5f4c7e 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -293,7 +293,6 @@ if( KICAD_SPICE ) sim/sim_panel_base.cpp sim/spice_simulator.cpp sim/spice_value.cpp - simulation_cursors.cpp dialogs/dialog_signal_list.cpp dialogs/dialog_signal_list_base.cpp dialogs/dialog_sim_settings.cpp diff --git a/eeschema/simulation_cursors.cpp b/eeschema/simulation_cursors.cpp deleted file mode 100644 index aebcd4b733..0000000000 --- a/eeschema/simulation_cursors.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include - -static const unsigned char voltage_probe[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x18, 0x0c, - 0x00, 0x00, 0x0e, 0x08, 0x00, 0x80, 0x07, 0x08, 0x00, 0xc0, 0x07, 0x18, - 0x00, 0xe0, 0x07, 0x30, 0x00, 0xf0, 0x03, 0x60, 0x00, 0xf8, 0x01, 0x00, - 0x00, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, - 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, - 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const unsigned char current_probe[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, - 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x1c, 0x08, - 0x00, 0x00, 0x0f, 0x08, 0x00, 0x80, 0x0f, 0x18, 0x00, 0xc0, 0x0f, 0x30, - 0x80, 0xe1, 0x07, 0x60, 0x80, 0xf1, 0x03, 0x00, 0x80, 0xf9, 0x01, 0x00, - 0x80, 0xfd, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, - 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, - 0xfe, 0x03, 0x00, 0x00, 0xc6, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, - 0x83, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, - 0xfc, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00 }; - -static const unsigned char cursor_tune[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, - 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, - 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, - 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, - 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, - 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, - 0x00, 0xea, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; - -static const unsigned char cursor_tune_mask[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, - 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, - 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, - 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, - 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, - 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, - 0x00, 0xee, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; - -#include - -static const std::vector simulation_cursors = { - { - static_cast( SIM_CURSORS::CURSOR::VOLTAGE_PROBE ), - voltage_probe, - voltage_probe, - { 32, 32 }, - { 1, 31 }, - }, - { - static_cast( SIM_CURSORS::CURSOR::CURRENT_PROBE ), - current_probe, - current_probe, - { 32, 32 }, - { 4, 27 }, - }, - { - static_cast( SIM_CURSORS::CURSOR::TUNE ), - cursor_tune, - cursor_tune_mask, - { 32, 32 }, - { 1, 30 }, - }, -}; - -const wxCursor& SIM_CURSORS::GetCursor( CURSOR aCursorType ) -{ - static CURSOR_STORE store( simulation_cursors ); - return store.Get( static_cast( aCursorType ) ); -} diff --git a/eeschema/simulation_cursors.h b/eeschema/simulation_cursors.h deleted file mode 100644 index ac9505e402..0000000000 --- a/eeschema/simulation_cursors.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * 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, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef EESCHEMA_SIMULATION_CURSORS__H -#define EESCHEMA_SIMULATION_CURSORS__H - -#include - -/** - * Simple class to provide cursors for simulation functions. - * - * For now, it's using simple static-access, but could be made more advanced in future. - */ -class SIM_CURSORS -{ -public: - ///> Probe cursor, used by circuit simulator - enum CURSOR - { - VOLTAGE_PROBE, - CURRENT_PROBE, - WATTAGE_PROBE, - TUNE, - }; - - static const wxCursor& GetCursor( CURSOR aCursorType ); -}; - -#endif // EESCHEMA_SIMULATION_CURSORS__H \ No newline at end of file diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 05c4ac5055..b04db8d1f2 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -763,7 +763,7 @@ void EE_POINT_EDITOR::setEditedPoint( EDIT_POINT* aPoint ) if( aPoint ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); controls->ForceCursorPosition( true, aPoint->GetPosition() ); controls->ShowCursor( true ); } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 9aa0d15de5..924cd60457 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -297,14 +297,14 @@ const KICAD_T movableSymbolItems[] = int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); KIID lastRolloverItem = niluuid; // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - bool displayPencil = false; + bool displayWireCursor = false; KIID rolloverItem = niluuid; m_additive = m_subtractive = m_exclusive_or = false; @@ -315,6 +315,8 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->Modifier( MD_CTRL ) ) m_exclusive_or = true; + bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; + // Is the user requesting that the selection list include all possible // items without removing less likely selection candidates m_skip_heuristics = !!evt->Modifier( MD_ALT ); @@ -335,7 +337,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { narrowSelection( collector, evt->Position(), false ); - if( collector.GetCount() == 1 && !m_isLibEdit ) + if( collector.GetCount() == 1 && !m_isLibEdit && !modifier_enabled ) { // Check if we want to auto start wires VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(), nullptr ); @@ -355,8 +357,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_toolMgr->ProcessEvent( *newEvt ); continueSelect = false; } - else if( collector[0]->Type() == SCH_IREF_T - && !m_additive && !m_subtractive && !m_exclusive_or ) + else if( collector[0]->Type() == SCH_IREF_T ) { wxMenu menu; @@ -428,8 +429,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( auto schframe = dynamic_cast( m_frame ) ) schframe->FocusOnItem( nullptr ); - if( m_additive || m_subtractive || m_exclusive_or - || ( m_selection.Empty() && m_frame->GetDragSelects() ) ) + if( modifier_enabled || ( m_selection.Empty() && m_frame->GetDragSelects() ) ) { selectMultiple(); } @@ -506,17 +506,17 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { narrowSelection( collector, evt->Position(), false ); - if( collector.GetCount() == 1 ) + if( collector.GetCount() == 1 && !modifier_enabled ) { VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(), nullptr ); if( m_frame->eeconfig()->m_Drawing.auto_start_wires && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) ) { - displayPencil = true; + displayWireCursor = true; } - else if( collector[0]->Type() == SCH_IREF_T - && !m_additive && !m_subtractive && !m_exclusive_or ) + else if( collector[0]->Type() == SCH_IREF_T && !m_additive && !m_subtractive + && !m_exclusive_or ) { rolloverItem = collector[0]->m_Uuid; } @@ -550,12 +550,25 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) { - if( displayPencil ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + if( displayWireCursor ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE ); else if( rolloverItem != niluuid ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_HAND ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::HAND ); + else if( !modifier_enabled && !m_selection.Empty() + && !m_frame->GetDragSelects() && evt->HasPosition() + && selectionContains( evt->Position() ) ) //move/drag option prediction + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); else - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + { + if( m_additive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ADD ); + else if( m_subtractive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::SUBTRACT ); + else if( m_exclusive_or ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::XOR ); + else + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + } } } diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 3c925d3868..1e3f284baf 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -76,7 +76,8 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings(); LIB_PIN_TOOL* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool() : nullptr; VECTOR2I cursorPos; - EDA_ITEM* item = nullptr; + EDA_ITEM* item = nullptr; + bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); @@ -92,7 +93,15 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + if( isText ) + { + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT ); + } + else + { + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + } + cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = [&] () { @@ -266,7 +275,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { if( !pointEditor->HasPoint() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); @@ -405,7 +414,7 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); if( evt->IsCancelInteractive() ) { diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index e652e2a358..11568b0b1c 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -307,7 +307,7 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); + picker->SetCursor( KICURSOR::REMOVE ); picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index 5cf3435a27..dc44be626c 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -101,7 +101,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events do { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 6257abf638..3bc21e6d69 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -113,10 +113,12 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) else if( aEvent.HasPosition() ) m_toolMgr->RunAction( EE_ACTIONS::cursorClick ); + m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( component ? wxCURSOR_ARROW : wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::PENCIL ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = [&] () { @@ -302,10 +304,13 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) else if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( image ? KICURSOR::MOVING : KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( image ? wxCURSOR_ARROW : wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( image ? KICURSOR::MOVING : KICURSOR::PENCIL ); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = [&] () { @@ -480,10 +485,13 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); if( evt->IsCancelInteractive() ) @@ -725,6 +733,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { EDA_ITEM* item = nullptr; bool importMode = aEvent.IsAction( &EE_ACTIONS::importSheetPin ); + bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText ); KICAD_T type = aEvent.Parameter(); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); @@ -738,10 +747,13 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = [&] () { @@ -933,11 +945,13 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { if( !pointEditor->HasPoint() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 21a93a3844..2b8788628f 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1110,7 +1110,7 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); + picker->SetCursor( KICURSOR::REMOVE ); picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 8cdc3ca261..e5fb0a06f1 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -631,7 +630,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) ); + picker->SetCursor( KICURSOR::VOLTAGE_PROBE ); picker->SetClickHandler( [this, simFrame] ( const VECTOR2D& aPosition ) @@ -693,9 +692,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) } if( item && item->Type() == SCH_PIN_T ) - picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) ); + picker->SetCursor( KICURSOR::CURRENT_PROBE ); else - picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) ); + picker->SetCursor( KICURSOR::VOLTAGE_PROBE ); if( m_pickerItem != item ) { @@ -747,7 +746,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) ); + picker->SetCursor( KICURSOR::TUNE ); picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) @@ -1138,7 +1137,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); + picker->SetCursor( KICURSOR::BULLSEYE ); picker->SetClickHandler( [this] ( const VECTOR2D& aPos ) diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index a34eb77c63..1258de14fb 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -481,11 +481,13 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType, if( !m_wires.empty() ) segment = m_wires.back(); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - if( !pointEditor->HasPoint() ) // Set wxCursor shape when starting the tool - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); wxPoint cursorPos = wxPoint( grid.BestSnapAnchor( diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index c7e88cf543..993d48a679 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -175,7 +175,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events do { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove ) || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag ) diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index 4cf3c2adc8..fbd0a492d1 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -185,7 +185,7 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { if( m_frame->ToolStackIsEmpty() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_additive = m_subtractive = m_exclusive_or = false; @@ -582,7 +582,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE ); const VECTOR2I cursorPos = controls.GetCursorPosition(); auto clearRuler = diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index 9b69c35c90..d04363ac85 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -36,6 +36,7 @@ #include #include #include +#include class BOARD; class EDA_DRAW_FRAME; @@ -197,8 +198,7 @@ public: * Function SetCurrentCursor * Set the current cursor shape for this panel */ - void SetCurrentCursor( wxStockCursor aStockCursorID ); - void SetCurrentCursor( const wxCursor& aCursor ); + void SetCurrentCursor( KICURSOR cursor ); /** * Returns the bounding box of the view that should be used if model is not valid @@ -244,7 +244,8 @@ protected: static const int MinRefreshPeriod = 17; ///< 60 FPS. - wxCursor m_currentCursor; ///< Current mouse cursor shape id. + wxCursor m_currentCursor; ///< Current mouse cursor shape id. + KICURSOR m_currentKiCursor; wxWindow* m_parent; ///< Pointer to the parent window EDA_DRAW_FRAME* m_edaFrame; ///< Parent EDA_DRAW_FRAME (if available) diff --git a/include/cursor_store.h b/include/cursors.h similarity index 81% rename from include/cursor_store.h rename to include/cursors.h index 151fb6968d..90fe61ad22 100644 --- a/include/cursor_store.h +++ b/include/cursors.h @@ -30,6 +30,26 @@ #include +enum class KICURSOR +{ + DEFAULT, + ARROW, + MOVING, + PENCIL, + REMOVE, + HAND, + BULLSEYE, + VOLTAGE_PROBE, + CURRENT_PROBE, + TUNE, + TEXT, + WIRE, + MEASURE, + ADD, + SUBTRACT, + XOR +}; + /** * Simple class to construct and store cursors against unique ID keys. * @@ -45,7 +65,7 @@ public: struct CURSOR_DEF { ///> The ID key used to uniquely identify a cursor in a given store - int m_id_key; + KICURSOR m_id_key; ///> The image data bitmap const unsigned char* m_image_data; @@ -53,6 +73,8 @@ public: ///> The mask data bitmap const unsigned char* m_mask_data; + const char** m_xpm; + ///> The image size in pixels wxSize m_size; @@ -75,11 +97,15 @@ public: * @param aIdKey the ID key to look up * @return the cursor, if found, else wxNullCursor */ - const wxCursor& Get( int aIdKey ) const; + const wxCursor& Get( KICURSOR aIdKey ) const; + + static const wxCursor GetCursor( KICURSOR aCursorType ); + + static const wxStockCursor GetStockCursor( KICURSOR aCursorType ); private: ///> Internal store of cursors by ID - std::map m_store; + std::map m_store; }; #endif // CURSOR_STORE__H \ No newline at end of file diff --git a/include/tool/picker_tool.h b/include/tool/picker_tool.h index f8ea524eb3..06c2f38d78 100644 --- a/include/tool/picker_tool.h +++ b/include/tool/picker_tool.h @@ -28,6 +28,7 @@ #include #include #include +#include class EDA_DRAW_FRAME; @@ -62,7 +63,7 @@ public: ///> Main event loop. int Main( const TOOL_EVENT& aEvent ); - inline void SetCursor( const wxCursor& aCursor ) { m_cursor = aCursor; } + inline void SetCursor( KICURSOR aCursor ) { m_cursor = aCursor; } /** * Function SetClickHandler() @@ -116,8 +117,8 @@ private: void setTransitions() override; private: - EDA_DRAW_FRAME* m_frame; - wxCursor m_cursor; + EDA_DRAW_FRAME* m_frame; + KICURSOR m_cursor; OPT m_clickHandler; OPT m_motionHandler; diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index 83d4734220..329b10b772 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -47,3 +47,17 @@ void KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( wxWindow *aWindow ) { // Not needed on this platform } + + +bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) +{ + switch( aCursor ) + { + case wxCURSOR_BULLSEYE: + case wxCURSOR_HAND: + case wxCURSOR_ARROW: + return true; + default: + return false; + } +} \ No newline at end of file diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index d9558435ed..9ddd28d96f 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -21,6 +21,8 @@ #ifndef KIPLATFORM_UI_H_ #define KIPLATFORM_UI_H_ +#include + class wxNonOwnedWindow; class wxWindow; @@ -67,6 +69,13 @@ namespace KIPLATFORM * German because the button is &Abbrechen. */ void FixupCancelButtonCmdKeyCollision( wxWindow* aWindow ); + + /** + * Checks if we designated a stock cursor for this OS as "OK" or else we may need to load a custom one + * + * @param aCursor is wxStockCursor we want to see if its acceptable + */ + bool IsStockCursorOk( wxStockCursor aCursor ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 83d4734220..78a7a05115 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -20,6 +20,7 @@ #include +#include #include #include @@ -47,3 +48,18 @@ void KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( wxWindow *aWindow ) { // Not needed on this platform } + + +bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) +{ + switch( aCursor ) + { + case wxCURSOR_SIZING: + case wxCURSOR_BULLSEYE: + case wxCURSOR_HAND: + case wxCURSOR_ARROW: + return true; + default: + return false; + } +} \ No newline at end of file diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index 4de0e5bf7b..0c1a0ad72a 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -71,3 +71,17 @@ void KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( wxWindow *aWindow ) } } + +bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) +{ + switch( aCursor ) + { + case wxCURSOR_SIZING: + case wxCURSOR_BULLSEYE: + case wxCURSOR_HAND: + case wxCURSOR_ARROW: + return true; + default: + return false; + } +} \ No newline at end of file diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index a42d08333a..1401c15953 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -92,7 +92,8 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( + item ? KICURSOR::ARROW : KICURSOR::PENCIL ); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = [&] () { @@ -212,7 +213,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { if( !pointEditor->HasPoint() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 8aaecb2740..fc26a48127 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -121,7 +121,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events do { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) ) @@ -350,7 +350,7 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); + picker->SetCursor( KICURSOR::REMOVE ); m_pickerItem = nullptr; picker->SetClickHandler( diff --git a/pagelayout_editor/tools/pl_point_editor.cpp b/pagelayout_editor/tools/pl_point_editor.cpp index b99fc662a6..a85bebe225 100644 --- a/pagelayout_editor/tools/pl_point_editor.cpp +++ b/pagelayout_editor/tools/pl_point_editor.cpp @@ -399,7 +399,7 @@ void PL_POINT_EDITOR::setEditedPoint( EDIT_POINT* aPoint ) if( aPoint ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); controls->ForceCursorPosition( true, aPoint->GetPosition() ); controls->ShowCursor( true ); } diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index cec25e3025..14071e3d0c 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -113,9 +113,6 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - if( m_frame->ToolStackIsEmpty() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - m_additive = m_subtractive = m_exclusive_or = false; if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) ) @@ -125,6 +122,8 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->Modifier( MD_CTRL ) ) m_exclusive_or = true; + bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; + // Is the user requesting that the selection list include all possible // items without removing less likely selection candidates m_skip_heuristics = !!evt->Modifier( MD_ALT ); @@ -159,7 +158,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them else if( evt->IsDrag( BUT_LEFT ) ) { - if( m_additive || m_subtractive || m_exclusive_or || m_selection.Empty() ) + if( modifier_enabled || m_selection.Empty() ) { selectMultiple(); } @@ -169,7 +168,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( selectionContains( evt->Position() ) ) { // Yes -> run the move tool and wait till it finishes - m_toolMgr->InvokeTool( "plEditor.InteractiveEdit" ); + m_toolMgr->RunAction( "plEditor.InteractiveMove.move", true ); } else { @@ -197,6 +196,25 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else evt->SetPassEvent(); + + + if( m_frame->ToolStackIsEmpty() ) + { + if( !modifier_enabled && !m_selection.Empty() && !m_frame->GetDragSelects() + && evt->HasPosition() && selectionContains( evt->Position() ) ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); + else + { + if( m_additive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ADD ); + else if( m_subtractive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::SUBTRACT ); + else if( m_exclusive_or ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::XOR ); + else + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + } + } } return 0; diff --git a/pcbnew/microwave/microwave_tool.cpp b/pcbnew/microwave/microwave_tool.cpp index 2917a76466..c040b3144e 100644 --- a/pcbnew/microwave/microwave_tool.cpp +++ b/pcbnew/microwave/microwave_tool.cpp @@ -137,7 +137,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) while( auto evt = Wait() ) { - frame.GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + frame.GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); VECTOR2I cursorPos = controls.GetCursorPosition(); auto cleanup = [&] () { diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index ad25892cab..5b90f472ad 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -183,7 +183,7 @@ void LENGTH_TUNER_TOOL::performTuning() while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); if( evt->IsCancelInteractive() || evt->IsActivate() ) { @@ -274,7 +274,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); if( evt->IsCancelInteractive() || evt->IsActivate() ) { diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 06ea920d13..40d0d00a98 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -916,7 +916,7 @@ void ROUTER_TOOL::performRouting() while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); // Don't crash if we missed an operation that cancelled routing. if( !m_router->RoutingInProgress() ) @@ -1095,7 +1095,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); if( evt->IsCancelInteractive() ) { @@ -1429,7 +1429,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); if( evt->IsCancelInteractive() ) { diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 4896cfc10e..f268b637fb 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -420,10 +420,14 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( text ? KICURSOR::ARROW : KICURSOR::TEXT ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( text ? wxCURSOR_ARROW : wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( + text ? KICURSOR::ARROW : KICURSOR::TEXT ); VECTOR2I cursorPos = m_controls->GetCursorPosition(); auto cleanup = [&]() @@ -641,11 +645,13 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->PrimeTool( aEvent.Position() ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - if( !pointEditor->HasPoint() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( m_frame->IsGridVisible() ); @@ -1038,10 +1044,13 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) m_frame->PushTool( tool ); Activate(); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); cursorPos = m_controls->GetCursorPosition(); if( evt->IsCancelInteractive() || evt->IsActivate() ) @@ -1120,9 +1129,12 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) m_controls->SetAutoPan( true ); m_controls->CaptureCursor( false ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); + while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( m_frame->IsGridVisible() ); @@ -1220,12 +1232,13 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE* frame()->SetMsgPanel( graphic ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - if( !pointEditor->HasPoint() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); - + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); m_frame->SetMsgPanel( graphic ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); @@ -1484,13 +1497,17 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool if( aImmediateMode ) m_toolMgr->RunAction( ACTIONS::cursorClick ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + PCB_LAYER_ID layer = m_frame->GetActiveLayer(); graphic->SetLayer( layer ); - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( m_frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic ); @@ -1734,10 +1751,13 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) m_toolMgr->PrimeTool( aEvent.Position() ); + // Set initial cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); LSET layers( m_frame->GetActiveLayer() ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( m_frame->IsGridVisible() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 4860b4b631..8f803761a1 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -408,7 +408,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) do { VECTOR2I movement; - editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index e23864c845..e9b0e129c0 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -296,7 +296,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE ); if( evt->IsCancelInteractive() ) { diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 8e10117ba2..c5a8990855 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -761,10 +761,12 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) else if( aEvent.HasPosition() ) m_toolMgr->RunAction( PCB_ACTIONS::cursorClick ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ); if( reselect && module ) @@ -975,10 +977,12 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) m_frame->PushTool( tool ); Activate(); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ); if( evt->IsCancelInteractive() ) diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index d7bc047ed9..d24b5fac23 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -82,13 +82,19 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, if( aOptions & IPO_SINGLE_CLICK ) makeNewItem( controls()->GetCursorPosition() ); + // Set initial cursor + if( !newItem ) + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); + else + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { if( !newItem ) - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); else - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); VECTOR2I cursorPos = controls()->GetCursorPosition(); aPlacer->m_modifiers = evt->Modifier(); diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index eb89bfa0bc..b86ebed740 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -222,7 +222,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr ); diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 0d0ee26b84..ac72c629a2 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -1724,7 +1724,7 @@ void POINT_EDITOR::setEditedPoint( EDIT_POINT* aPoint ) if( aPoint ) { - frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); controls->ForceCursorPosition( true, aPoint->GetPosition() ); controls->ShowCursor( true ); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 2c17502e8c..fc920f79d3 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -208,9 +208,6 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - if( m_frame->ToolStackIsEmpty() ) - m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - bool dragAlwaysSelects = getEditFrame()->GetDragSelects(); TRACK_DRAG_ACTION dragAction = getEditFrame()->Settings().m_TrackDragAction; m_additive = m_subtractive = m_exclusive_or = false; @@ -228,6 +225,8 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_exclusive_or = true; #endif + bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; + // Is the user requesting that the selection list include all possible // items without removing less likely selection candidates m_skip_heuristics = !!evt->Modifier( MD_ALT ); @@ -287,7 +286,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { m_frame->FocusOnItem( nullptr ); - if( m_additive || m_subtractive || m_exclusive_or || dragAlwaysSelects ) + if( modifier_enabled || dragAlwaysSelects ) { selectMultiple(); } @@ -336,6 +335,26 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else evt->SetPassEvent(); + + + if( m_frame->ToolStackIsEmpty() ) + { + //move cursor prediction + if( !modifier_enabled && !dragAlwaysSelects && !m_selection.Empty() + && evt->HasPosition() && selectionContains( evt->Position() ) ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); + else + { + if( m_additive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ADD ); + else if( m_subtractive ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::SUBTRACT ); + else if( m_exclusive_or ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::XOR ); + else + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + } + } } return 0;