From 8fa42a74bdd4896b3ea85b2028c79f23a02cb47d Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 8 Oct 2020 20:08:44 -0400 Subject: [PATCH] Add zoom cursors --- bitmaps_png/cursors/README.md | 4 ++- bitmaps_png/cursors/cursor-zoom-out.xpm | 38 +++++++++++++++++++++++++ bitmaps_png/cursors/cursor-zoom.xpm | 38 +++++++++++++++++++++++++ common/cursors.cpp | 18 ++++++++++++ common/tool/zoom_tool.cpp | 11 ++++++- include/cursors.h | 4 ++- 6 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 bitmaps_png/cursors/cursor-zoom-out.xpm create mode 100644 bitmaps_png/cursors/cursor-zoom.xpm diff --git a/bitmaps_png/cursors/README.md b/bitmaps_png/cursors/README.md index 7153e0fae9..0278239472 100644 --- a/bitmaps_png/cursors/README.md +++ b/bitmaps_png/cursors/README.md @@ -4,4 +4,6 @@ The following cursors were borrowed from the Inkspace project https://gitlab.com - cursor-measure.xpm - cursor-pencil.xpm - cursor-select-m.xpm -- cursor-text.xpm \ No newline at end of file +- cursor-text.xpm +- cursor-zoom.xpm +- cursor-zoom-out.xpm \ No newline at end of file diff --git a/bitmaps_png/cursors/cursor-zoom-out.xpm b/bitmaps_png/cursors/cursor-zoom-out.xpm new file mode 100644 index 0000000000..8f35ad049e --- /dev/null +++ b/bitmaps_png/cursors/cursor-zoom-out.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_zoom_out_xpm[] = { +"32 32 3 1 6 6", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" ..+++.. ", +" .++ ++. ", +" .+ +. ", +" .+ +. ", +".+ ..... +. ", +".+ +++++ +. ", +".+ ..... +. ", +" .+ +. ", +" .+ +. ", +" .++ ++.+.. ", +" ..+++..+.++. ", +" ... .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .++. ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/bitmaps_png/cursors/cursor-zoom.xpm b/bitmaps_png/cursors/cursor-zoom.xpm new file mode 100644 index 0000000000..e869239d6e --- /dev/null +++ b/bitmaps_png/cursors/cursor-zoom.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const *cursor_zoom_xpm[] = { +"32 32 3 1 6 6", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" ..+++.. ", +" .++ ++. ", +" .+ +. ", +" .+ .+. +. ", +".+ ..+.. +. ", +".+ +++++ +. ", +".+ ..+.. +. ", +" .+ .+. +. ", +" .+ +. ", +" .++ ++.+.. ", +" ..+++..+.++. ", +" ... .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .++. ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/common/cursors.cpp b/common/cursors.cpp index 7e31e2cbc3..87fe8dc276 100644 --- a/common/cursors.cpp +++ b/common/cursors.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include @@ -177,6 +179,22 @@ static const std::vector standard_cursors = { { 32, 32 }, { 7, 10 }, }, + { + KICURSOR::ZOOM_IN, + nullptr, + nullptr, + cursor_zoom_xpm, + { 32, 32 }, + { 6, 6 }, + }, + { + KICURSOR::ZOOM_OUT, + nullptr, + nullptr, + cursor_zoom_out_xpm, + { 32, 32 }, + { 6, 6 }, + }, }; diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index 7ff64e0fbe..d73d0bbb3f 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -49,9 +49,18 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); m_frame->PushTool( tool ); + auto setCursor = + [&]() + { + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ZOOM_IN ); + }; + + // Set initial cursor + setCursor(); + while( TOOL_EVENT* evt = Wait() ) { - m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); + setCursor(); if( evt->IsCancelInteractive() || evt->IsActivate() ) break; diff --git a/include/cursors.h b/include/cursors.h index 90fe61ad22..7b73af8743 100644 --- a/include/cursors.h +++ b/include/cursors.h @@ -47,7 +47,9 @@ enum class KICURSOR MEASURE, ADD, SUBTRACT, - XOR + XOR, + ZOOM_IN, + ZOOM_OUT }; /**