From 6cf4016a64a952a2df37992f55753119e913903f Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 8 Oct 2020 20:40:03 -0400 Subject: [PATCH] Add net and global label cursors --- bitmaps_png/cursors/cursor-global-label.xpm | 38 +++++++++++++++++++++ bitmaps_png/cursors/cursor-net-label.xpm | 38 +++++++++++++++++++++ common/cursors.cpp | 18 ++++++++++ eeschema/tools/sch_drawing_tools.cpp | 20 +++++++---- include/cursors.h | 4 ++- 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 bitmaps_png/cursors/cursor-global-label.xpm create mode 100644 bitmaps_png/cursors/cursor-net-label.xpm diff --git a/bitmaps_png/cursors/cursor-global-label.xpm b/bitmaps_png/cursors/cursor-global-label.xpm new file mode 100644 index 0000000000..2ed538d2af --- /dev/null +++ b/bitmaps_png/cursors/cursor-global-label.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_global_label_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" # ############## ", +" #!!!!!!!!!!!!!!# ", +" #! #### !# ", +" #! #!!!!# !# ", +" #! #!!!!# !# ", +" #! #!!!!!!# !# ", +" #! #!!!!!!# !# ", +" #! #!!##!!# !# ", +" #! #!!!##!!!# !#", +" #! #!!!##!!!# !", +" #! #!!!!!!!!# !#", +" #! #!!!!!!!!!!# !# ", +" #! #!!!####!!!# !# ", +" #!#!!!# #!!!# !# ", +" #!#!!!# #!!!# !# ", +" #! ### ### !# ", +" #! !# ", +" #!!!!!!!!!!!!!!# "}; \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-net-label.xpm b/bitmaps_png/cursors/cursor-net-label.xpm new file mode 100644 index 0000000000..d432ffbeb6 --- /dev/null +++ b/bitmaps_png/cursors/cursor-net-label.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_net_label_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ", +" #!# #### ", +" #!# #!!!!# ", +" #!# #!!!!# ", +" # #!!!!!!# ", +" #!!!!!!# ", +" #!!##!!# ", +" #!!!##!!!# ", +" #!!!##!!!# ", +" #!!!!!!!!# ", +" #!!!!!!!!!!# ", +" #!!!####!!!# ", +" #!!!# #!!!# ", +" #!!!# #!!!# ", +" ### ### ", +" ", +" !!!!!!!!!!!!!!!!!!!!! ", +" !!!!!!!!!!!!!!!!!!!!! ", +" ##################### ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/common/cursors.cpp b/common/cursors.cpp index 87fe8dc276..9331eb2176 100644 --- a/common/cursors.cpp +++ b/common/cursors.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -195,6 +197,22 @@ static const std::vector standard_cursors = { { 32, 32 }, { 6, 6 }, }, + { + KICURSOR::NET_LABEL, + nullptr, + nullptr, + cursor_net_label_xpm, + { 32, 32 }, + { 7, 10 }, + }, + { + KICURSOR::GLOBAL_LABEL, + nullptr, + nullptr, + cursor_global_label_xpm, + { 32, 32 }, + { 7, 10 }, + }, }; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index bf96e620c4..742809247f 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -810,10 +810,12 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType 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(); + EDA_ITEM* item = nullptr; + bool isImportMode = aEvent.IsAction( &EE_ACTIONS::importSheetPin ); + bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText ); + bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel ); + bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel ); + KICAD_T type = aEvent.Parameter(); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); @@ -831,8 +833,14 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { if( item ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); + else if( isText ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT ); + else if( isGlobalLabel ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::GLOBAL_LABEL ); + else if( isNetLabel ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::NET_LABEL ); else - m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL ); + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL ); }; // Set initial cursor @@ -922,7 +930,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) break; } - if( importMode ) + if( isImportMode ) { label = m_frame->ImportHierLabel( sheet ); diff --git a/include/cursors.h b/include/cursors.h index 7b73af8743..38dee3742b 100644 --- a/include/cursors.h +++ b/include/cursors.h @@ -49,7 +49,9 @@ enum class KICURSOR SUBTRACT, XOR, ZOOM_IN, - ZOOM_OUT + ZOOM_OUT, + NET_LABEL, + GLOBAL_LABEL }; /**