diff --git a/bitmaps_png/cursors/cursor-select-lasso.xpm b/bitmaps_png/cursors/cursor-select-lasso.xpm new file mode 100644 index 0000000000..5abfd2c24a --- /dev/null +++ b/bitmaps_png/cursors/cursor-select-lasso.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_select_lasso_xpm[] = { +"32 32 3 1", +" c None", +"! c black", +"# c white", +" # ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" #!# ", +" ##### ##### ", +"#!!!!! !!!!!# ", +" ##### ##### ", +" #!# ", +" #!# ################### ", +" #!# #!!!!!!!!!!!!!!!!!# ", +" #!# #!###############!# ", +" #!# #!# #!# ", +" # #!# #!# ", +" #!# #!# ", +" #!!!# #!# ", +" #!!!!!# #!# ", +" #!!!!!!!# #!# ", +" #!!!!!!!# #!# ", +" #!!!!!!!# #!# ", +" #!!!!!# #!# ", +" #!!!# #!# ", +" #!# #!# ", +" #!# #!# ", +" #!# #!# ", +" #!###############!# ", +" #!!!!!!!!!!!!!!!!!# ", +" ################### ", +" ", +" ", +" "}; \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-select-window.xpm b/bitmaps_png/cursors/cursor-select-window.xpm new file mode 100644 index 0000000000..153812c919 --- /dev/null +++ b/bitmaps_png/cursors/cursor-select-window.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_select_window_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 78f5723945..ded3cd729d 100644 --- a/common/cursors.cpp +++ b/common/cursors.cpp @@ -33,7 +33,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -222,6 +224,22 @@ static const std::vector standard_cursors = { { 32, 32 }, { 7, 10 }, }, + { + KICURSOR::SELECT_LASSO, + nullptr, + nullptr, + cursor_select_lasso_xpm, + { 32, 32 }, + { 7, 10 }, + }, + { + KICURSOR::SELECT_WINDOW, + nullptr, + nullptr, + cursor_select_window_xpm, + { 32, 32 }, + { 7, 10 }, + }, }; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 9cacfa4586..64070daa3f 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -974,6 +974,20 @@ bool EE_SELECTION_TOOL::selectMultiple() while( TOOL_EVENT* evt = Wait() ) { + int width = area.GetEnd().x - area.GetOrigin().x; + + /* Selection mode depends on direction of drag-selection: + * Left > Right : Select objects that are fully enclosed by selection + * Right > Left : Select objects that are crossed by selection + */ + bool windowSelection = width >= 0; + + if( view->IsMirroredX() ) + windowSelection = !windowSelection; + + m_frame->GetCanvas()->SetCurrentCursor( + windowSelection ? KICURSOR::SELECT_WINDOW : KICURSOR::SELECT_LASSO ); + if( evt->IsCancelInteractive() || evt->IsActivate() ) { cancelled = true; @@ -1028,20 +1042,11 @@ bool EE_SELECTION_TOOL::selectMultiple() selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() ); - int width = area.GetEnd().x - area.GetOrigin().x; int height = area.GetEnd().y - area.GetOrigin().y; - /* Selection mode depends on direction of drag-selection: - * Left > Right : Select objects that are fully enclosed by selection - * Right > Left : Select objects that are crossed by selection - */ - bool windowSelection = width >= 0; bool anyAdded = false; bool anySubtracted = false; - if( view->IsMirroredX() ) - windowSelection = !windowSelection; - // Construct an EDA_RECT to determine EDA_ITEM selection EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) ); diff --git a/include/cursors.h b/include/cursors.h index 81a1718926..e44bc5e60a 100644 --- a/include/cursors.h +++ b/include/cursors.h @@ -52,7 +52,9 @@ enum class KICURSOR ZOOM_OUT, NET_LABEL, GLOBAL_LABEL, - COMPONENT + COMPONENT, + SELECT_WINDOW, + SELECT_LASSO }; /** diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index 14071e3d0c..18c50d28ff 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -342,6 +342,17 @@ bool PL_SELECTION_TOOL::selectMultiple() while( TOOL_EVENT* evt = Wait() ) { + int width = area.GetEnd().x - area.GetOrigin().x; + + /* Selection mode depends on direction of drag-selection: + * Left > Right : Select objects that are fully enclosed by selection + * Right > Left : Select objects that are crossed by selection + */ + bool windowSelection = width >= 0 ? true : false; + + m_frame->GetCanvas()->SetCurrentCursor( + windowSelection ? KICURSOR::SELECT_WINDOW : KICURSOR::SELECT_LASSO ); + if( evt->IsCancelInteractive() || evt->IsActivate() ) { cancelled = true; @@ -372,14 +383,8 @@ bool PL_SELECTION_TOOL::selectMultiple() // End drawing the selection box view->SetVisible( &area, false ); - int width = area.GetEnd().x - area.GetOrigin().x; int height = area.GetEnd().y - area.GetOrigin().y; - /* Selection mode depends on direction of drag-selection: - * Left > Right : Select objects that are fully enclosed by selection - * Right > Left : Select objects that are crossed by selection - */ - bool windowSelection = width >= 0 ? true : false; bool anyAdded = false; bool anySubtracted = false; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index c38e0e5513..2385260511 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -643,6 +643,20 @@ bool SELECTION_TOOL::selectMultiple() while( TOOL_EVENT* evt = Wait() ) { + int width = area.GetEnd().x - area.GetOrigin().x; + + /* Selection mode depends on direction of drag-selection: + * Left > Right : Select objects that are fully enclosed by selection + * Right > Left : Select objects that are crossed by selection + */ + bool windowSelection = width >= 0 ? true : false; + + if( view->IsMirroredX() ) + windowSelection = !windowSelection; + + m_frame->GetCanvas()->SetCurrentCursor( + windowSelection ? KICURSOR::SELECT_WINDOW : KICURSOR::SELECT_LASSO ); + if( evt->IsCancelInteractive() || evt->IsActivate() ) { cancelled = true; @@ -683,18 +697,8 @@ bool SELECTION_TOOL::selectMultiple() BOX2I selectionBox = area.ViewBBox(); view->Query( selectionBox, candidates ); // Get the list of nearby items - int width = area.GetEnd().x - area.GetOrigin().x; int height = area.GetEnd().y - area.GetOrigin().y; - /* Selection mode depends on direction of drag-selection: - * Left > Right : Select objects that are fully enclosed by selection - * Right > Left : Select objects that are crossed by selection - */ - bool windowSelection = width >= 0 ? true : false; - - if( view->IsMirroredX() ) - windowSelection = !windowSelection; - // Construct an EDA_RECT to determine BOARD_ITEM selection EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) );