Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
|
2015-05-18 11:48:10 +00:00
|
|
|
* Copyright (C) 2013-2015 CERN
|
2022-09-07 11:18:35 +00:00
|
|
|
* Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-02-24 19:53:02 +00:00
|
|
|
*
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2015-05-18 11:48:10 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-05-30 09:16:05 +00:00
|
|
|
#include <pgm_base.h>
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <view/wx_view_controls.h>
|
2018-11-22 16:24:17 +00:00
|
|
|
#include <view/zoom_controller.h>
|
2013-08-28 14:25:42 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2013-09-13 08:26:08 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2020-05-17 00:19:48 +00:00
|
|
|
#include <trace_helpers.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/common_settings.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2022-02-11 16:42:52 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2020-11-05 02:06:36 +00:00
|
|
|
#include <widgets/ui_common.h>
|
2021-04-19 19:03:33 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2022-09-30 18:32:06 +00:00
|
|
|
#include <eda_draw_frame.h>
|
|
|
|
#include <kiway.h>
|
2021-06-07 22:20:47 +00:00
|
|
|
#include <kiplatform/ui.h>
|
|
|
|
#include <wx/log.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
|
2022-09-07 03:07:02 +00:00
|
|
|
#ifdef __WXMSW__
|
2021-01-21 00:35:59 +00:00
|
|
|
#define USE_MOUSE_CAPTURE
|
|
|
|
#endif
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
using namespace KIGFX;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-09-24 14:12:02 +00:00
|
|
|
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
|
|
|
|
|
2018-11-22 16:24:17 +00:00
|
|
|
|
2021-03-21 23:46:23 +00:00
|
|
|
static std::unique_ptr<ZOOM_CONTROLLER> GetZoomControllerForPlatform( bool aAcceleration )
|
2018-11-22 16:24:17 +00:00
|
|
|
{
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// On Apple pointer devices, wheel events occur frequently and with
|
|
|
|
// smaller rotation values. For those devices, let's handle zoom
|
|
|
|
// based on the rotation amount rather than the time difference.
|
|
|
|
return std::make_unique<CONSTANT_ZOOM_CONTROLLER>( CONSTANT_ZOOM_CONTROLLER::MAC_SCALE );
|
2018-11-22 16:30:28 +00:00
|
|
|
#elif __WXGTK3__
|
|
|
|
// GTK3 is similar, but the scale constant is smaller
|
|
|
|
return std::make_unique<CONSTANT_ZOOM_CONTROLLER>( CONSTANT_ZOOM_CONTROLLER::GTK3_SCALE );
|
2018-11-22 16:24:17 +00:00
|
|
|
#else
|
2021-03-21 23:46:23 +00:00
|
|
|
if( aAcceleration )
|
|
|
|
return std::make_unique<ACCELERATING_ZOOM_CONTROLLER>();
|
|
|
|
else
|
|
|
|
return std::make_unique<CONSTANT_ZOOM_CONTROLLER>( CONSTANT_ZOOM_CONTROLLER::MSW_SCALE );
|
2018-11-22 16:24:17 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-19 19:03:33 +00:00
|
|
|
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPanel ) :
|
2019-05-30 09:16:05 +00:00
|
|
|
VIEW_CONTROLS( aView ),
|
|
|
|
m_state( IDLE ),
|
|
|
|
m_parentPanel( aParentPanel ),
|
|
|
|
m_scrollScale( 1.0, 1.0 ),
|
2019-06-17 13:00:56 +00:00
|
|
|
#ifdef __WXGTK3__
|
2019-05-30 09:16:05 +00:00
|
|
|
m_lastTimestamp( 0 ),
|
2019-06-17 13:00:56 +00:00
|
|
|
#endif
|
2019-05-30 09:16:05 +00:00
|
|
|
m_cursorPos( 0, 0 ),
|
2024-03-12 07:31:23 +00:00
|
|
|
m_updateCursor( true ),
|
|
|
|
m_infinitePanWorks( false )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2020-05-17 00:19:48 +00:00
|
|
|
LoadSettings();
|
2019-05-30 09:16:05 +00:00
|
|
|
|
2021-12-05 20:15:18 +00:00
|
|
|
m_MotionEventCounter = std::make_unique<PROF_COUNTER>( "Mouse motion events" );
|
|
|
|
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MOTION,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), nullptr, this );
|
2015-05-21 20:54:29 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MAGNIFY,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onMagnify ), nullptr, this );
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MOUSEWHEEL,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), nullptr, this );
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MIDDLE_UP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_LEFT_UP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2017-09-06 01:28:01 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_RIGHT_UP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2017-09-06 01:28:01 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_RIGHT_DOWN,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
|
2021-01-22 13:57:05 +00:00
|
|
|
#if defined __WXMSW__
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), nullptr, this );
|
2013-04-22 09:08:02 +00:00
|
|
|
#endif
|
2022-09-07 03:09:07 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_LEAVE_WINDOW,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onLeave ), nullptr, this );
|
2015-05-18 11:48:10 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_THUMBTRACK,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2018-06-12 15:52:57 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEUP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2018-06-12 15:52:57 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEDOWN,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2018-12-23 19:17:30 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_BOTTOM,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2018-12-23 19:17:30 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_TOP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2018-12-23 19:17:30 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEUP,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2018-12-23 19:17:30 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEDOWN,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-01-20 19:01:51 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MOUSE_CAPTURE_LOST,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onCaptureLost ), nullptr, this );
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2018-12-23 19:17:30 +00:00
|
|
|
|
2019-01-08 19:47:00 +00:00
|
|
|
m_cursorWarped = false;
|
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
m_panTimer.SetOwner( this );
|
2021-07-15 19:26:35 +00:00
|
|
|
this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), nullptr, this );
|
2018-12-23 17:57:40 +00:00
|
|
|
|
|
|
|
m_settings.m_lastKeyboardCursorPositionValid = false;
|
2020-01-10 17:20:10 +00:00
|
|
|
m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 };
|
|
|
|
m_settings.m_lastKeyboardCursorCommand = 0;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-22 16:24:17 +00:00
|
|
|
WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS()
|
|
|
|
{
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-01-20 19:01:51 +00:00
|
|
|
if( m_parentPanel->HasCapture() )
|
|
|
|
m_parentPanel->ReleaseMouse();
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2018-11-22 16:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-17 00:19:48 +00:00
|
|
|
void WX_VIEW_CONTROLS::LoadSettings()
|
|
|
|
{
|
|
|
|
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
|
|
|
|
|
|
|
m_settings.m_warpCursor = cfg->m_Input.center_on_zoom;
|
2022-09-30 18:32:06 +00:00
|
|
|
m_settings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb;
|
2020-05-17 00:19:48 +00:00
|
|
|
m_settings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan;
|
|
|
|
m_settings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration;
|
|
|
|
m_settings.m_horizontalPan = cfg->m_Input.horizontal_pan;
|
|
|
|
m_settings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration;
|
|
|
|
m_settings.m_zoomSpeed = cfg->m_Input.zoom_speed;
|
|
|
|
m_settings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto;
|
|
|
|
m_settings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom;
|
|
|
|
m_settings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h;
|
|
|
|
m_settings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v;
|
2021-01-11 15:46:41 +00:00
|
|
|
m_settings.m_dragLeft = cfg->m_Input.drag_left;
|
|
|
|
m_settings.m_dragMiddle = cfg->m_Input.drag_middle;
|
|
|
|
m_settings.m_dragRight = cfg->m_Input.drag_right;
|
2023-08-17 19:17:50 +00:00
|
|
|
m_settings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h;
|
2020-05-17 00:19:48 +00:00
|
|
|
|
|
|
|
m_zoomController.reset();
|
|
|
|
|
|
|
|
if( cfg->m_Input.zoom_speed_auto )
|
|
|
|
{
|
2021-03-21 23:46:23 +00:00
|
|
|
m_zoomController = GetZoomControllerForPlatform( cfg->m_Input.zoom_acceleration );
|
2020-05-17 00:19:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( cfg->m_Input.zoom_acceleration )
|
|
|
|
{
|
|
|
|
m_zoomController =
|
|
|
|
std::make_unique<ACCELERATING_ZOOM_CONTROLLER>( cfg->m_Input.zoom_speed );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double scale = CONSTANT_ZOOM_CONTROLLER::MANUAL_SCALE_FACTOR * cfg->m_Input.zoom_speed;
|
|
|
|
|
|
|
|
m_zoomController = std::make_unique<CONSTANT_ZOOM_CONTROLLER>( scale );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2021-12-05 20:15:18 +00:00
|
|
|
( *m_MotionEventCounter )++;
|
|
|
|
|
2023-09-18 09:39:27 +00:00
|
|
|
// Because Weston sends a motion event to previous location after warping the pointer
|
|
|
|
wxPoint mouseRel = m_parentPanel->ScreenToClient( KIPLATFORM::UI::GetMousePosition() );
|
|
|
|
|
|
|
|
bool isAutoPanning = false;
|
|
|
|
int x = mouseRel.x;
|
|
|
|
int y = mouseRel.y;
|
2021-01-18 22:07:59 +00:00
|
|
|
VECTOR2D mousePos( x, y );
|
|
|
|
|
2022-09-30 18:32:06 +00:00
|
|
|
// Automatic focus switching between SCH and PCB windows on canvas mouse motion
|
|
|
|
if( m_settings.m_focusFollowSchPcb )
|
|
|
|
{
|
|
|
|
if( EDA_DRAW_FRAME* frame = m_parentPanel->GetParentEDAFrame() )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER* otherFrame = nullptr;
|
|
|
|
|
|
|
|
if( frame->IsType( FRAME_PCB_EDITOR ) )
|
|
|
|
{
|
|
|
|
otherFrame = frame->Kiway().Player( FRAME_SCH, false );
|
|
|
|
}
|
|
|
|
else if( frame->IsType( FRAME_SCH ) )
|
|
|
|
{
|
|
|
|
otherFrame = frame->Kiway().Player( FRAME_PCB_EDITOR, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( otherFrame && KIPLATFORM::UI::IsWindowActive( otherFrame )
|
|
|
|
&& !KIPLATFORM::UI::IsWindowActive( frame ) )
|
|
|
|
{
|
|
|
|
frame->Raise();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-22 13:57:05 +00:00
|
|
|
if( m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
|
|
|
|
handleCursorCapture( x, y );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2017-11-23 22:04:52 +00:00
|
|
|
if( m_settings.m_autoPanEnabled && m_settings.m_autoPanSettingEnabled )
|
2013-09-02 14:26:42 +00:00
|
|
|
isAutoPanning = handleAutoPanning( aEvent );
|
|
|
|
|
|
|
|
if( !isAutoPanning && aEvent.Dragging() )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-22 16:42:53 +00:00
|
|
|
if( m_state == DRAG_PANNING )
|
|
|
|
{
|
2021-01-18 22:07:59 +00:00
|
|
|
static bool justWarped = false;
|
|
|
|
int warpX = 0;
|
|
|
|
int warpY = 0;
|
|
|
|
wxSize parentSize = m_parentPanel->GetClientSize();
|
|
|
|
|
|
|
|
if( x < 0 )
|
|
|
|
{
|
|
|
|
warpX = parentSize.x;
|
|
|
|
}
|
|
|
|
else if(x >= parentSize.x )
|
|
|
|
{
|
|
|
|
warpX = -parentSize.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( y < 0 )
|
|
|
|
{
|
|
|
|
warpY = parentSize.y;
|
|
|
|
}
|
|
|
|
else if( y >= parentSize.y )
|
|
|
|
{
|
|
|
|
warpY = -parentSize.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !justWarped )
|
|
|
|
{
|
|
|
|
VECTOR2D d = m_dragStartPoint - mousePos;
|
2021-04-28 10:10:06 +00:00
|
|
|
m_dragStartPoint = mousePos;
|
2021-01-18 22:07:59 +00:00
|
|
|
VECTOR2D delta = m_view->ToWorld( d, false );
|
2021-04-28 10:10:06 +00:00
|
|
|
m_view->SetCenter( m_view->GetCenter() + delta );
|
2021-01-18 22:07:59 +00:00
|
|
|
aEvent.StopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( warpX || warpY )
|
|
|
|
{
|
|
|
|
if( !justWarped )
|
|
|
|
{
|
2024-03-12 07:31:23 +00:00
|
|
|
if( m_infinitePanWorks
|
|
|
|
&& KIPLATFORM::UI::WarpPointer( m_parentPanel, x + warpX, y + warpY ) )
|
2023-09-22 02:10:42 +00:00
|
|
|
{
|
|
|
|
m_dragStartPoint += VECTOR2D( warpX, warpY );
|
|
|
|
justWarped = true;
|
|
|
|
}
|
2021-01-18 22:07:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
justWarped = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
justWarped = false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2020-05-17 00:19:48 +00:00
|
|
|
else if( m_state == DRAG_ZOOMING )
|
|
|
|
{
|
2021-01-18 22:07:59 +00:00
|
|
|
static bool justWarped = false;
|
|
|
|
int warpY = 0;
|
|
|
|
wxSize parentSize = m_parentPanel->GetClientSize();
|
|
|
|
|
|
|
|
if( y < 0 )
|
|
|
|
{
|
|
|
|
warpY = parentSize.y;
|
|
|
|
}
|
|
|
|
else if( y >= parentSize.y )
|
|
|
|
{
|
|
|
|
warpY = -parentSize.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !justWarped )
|
|
|
|
{
|
|
|
|
VECTOR2D d = m_dragStartPoint - mousePos;
|
2021-04-28 10:10:06 +00:00
|
|
|
m_dragStartPoint = mousePos;
|
|
|
|
|
2021-01-18 22:07:59 +00:00
|
|
|
double scale = exp( d.y * m_settings.m_zoomSpeed * 0.001 );
|
|
|
|
|
|
|
|
wxLogTrace( traceZoomScroll, wxString::Format( "dy: %f scale: %f", d.y, scale ) );
|
|
|
|
|
2021-04-28 10:10:06 +00:00
|
|
|
m_view->SetScale( m_view->GetScale() * scale, m_view->ToWorld( m_zoomStartPoint ) );
|
2021-01-18 22:07:59 +00:00
|
|
|
aEvent.StopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( warpY )
|
|
|
|
{
|
|
|
|
if( !justWarped )
|
|
|
|
{
|
2022-06-24 16:54:28 +00:00
|
|
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, x, y + warpY );
|
2021-01-18 22:07:59 +00:00
|
|
|
m_dragStartPoint += VECTOR2D( 0, warpY );
|
|
|
|
justWarped = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
justWarped = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
justWarped = false;
|
2020-05-17 00:19:48 +00:00
|
|
|
}
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2017-08-22 13:13:25 +00:00
|
|
|
if( m_updateCursor ) // do not update the cursor position if it was explicitly set
|
2022-02-11 16:42:52 +00:00
|
|
|
m_cursorPos = GetClampedCoords( m_view->ToWorld( mousePos ) );
|
2017-08-22 13:13:25 +00:00
|
|
|
else
|
|
|
|
m_updateCursor = true;
|
|
|
|
|
2015-07-03 18:58:12 +00:00
|
|
|
aEvent.Skip();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2018-12-06 02:23:32 +00:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
if( aEvent.GetTimestamp() == m_lastTimestamp )
|
|
|
|
{
|
|
|
|
aEvent.Skip( false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastTimestamp = aEvent.GetTimestamp();
|
|
|
|
#endif
|
|
|
|
|
2019-05-08 09:49:19 +00:00
|
|
|
const double wheelPanSpeed = 0.001;
|
|
|
|
const int axis = aEvent.GetWheelAxis();
|
2019-05-07 16:17:02 +00:00
|
|
|
|
2020-05-17 00:19:48 +00:00
|
|
|
if( axis == wxMOUSE_WHEEL_HORIZONTAL && !m_settings.m_horizontalPan )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Pick the modifier, if any. Shift beats control beats alt, we don't support more than one.
|
|
|
|
int modifiers =
|
|
|
|
aEvent.ShiftDown() ? WXK_SHIFT :
|
|
|
|
( aEvent.ControlDown() ? WXK_CONTROL : ( aEvent.AltDown() ? WXK_ALT : 0 ) );
|
|
|
|
|
|
|
|
// Restrict zoom handling to the vertical axis, otherwise horizontal
|
|
|
|
// scrolling events (e.g. touchpads and some mice) end up interpreted
|
|
|
|
// as vertical scroll events and confuse the user.
|
2023-02-25 01:58:13 +00:00
|
|
|
if( modifiers == m_settings.m_scrollModifierZoom )
|
2020-05-17 00:19:48 +00:00
|
|
|
{
|
2023-02-25 01:58:13 +00:00
|
|
|
if ( axis == wxMOUSE_WHEEL_VERTICAL )
|
2020-05-17 00:19:48 +00:00
|
|
|
{
|
2023-02-25 01:58:13 +00:00
|
|
|
const int rotation = aEvent.GetWheelRotation();
|
|
|
|
const double zoomScale = m_zoomController->GetScaleForRotation( rotation );
|
|
|
|
|
|
|
|
if( IsCursorWarpingEnabled() )
|
|
|
|
{
|
|
|
|
CenterOnCursor();
|
|
|
|
m_view->SetScale( m_view->GetScale() * zoomScale );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
|
|
|
m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
|
|
|
|
}
|
2020-11-29 16:46:07 +00:00
|
|
|
|
2023-02-25 01:58:13 +00:00
|
|
|
// Refresh the zoom level and mouse position on message panel
|
|
|
|
// (mouse position has not changed, only the zoom level has changed):
|
|
|
|
refreshMouse( true );
|
|
|
|
}
|
2020-05-17 00:19:48 +00:00
|
|
|
}
|
|
|
|
else
|
2013-04-23 10:07:14 +00:00
|
|
|
{
|
|
|
|
// Scrolling
|
2014-05-31 09:48:27 +00:00
|
|
|
VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
|
|
|
|
( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
|
2023-08-17 19:17:50 +00:00
|
|
|
double scrollX = 0.0;
|
|
|
|
double scrollY = 0.0;
|
|
|
|
bool hReverse = false;
|
|
|
|
|
|
|
|
if( axis != wxMOUSE_WHEEL_HORIZONTAL )
|
|
|
|
hReverse = m_settings.m_scrollReversePanH;
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2020-05-17 00:19:48 +00:00
|
|
|
if( axis == wxMOUSE_WHEEL_HORIZONTAL || modifiers == m_settings.m_scrollModifierPanH )
|
2023-08-17 19:17:50 +00:00
|
|
|
{
|
|
|
|
if( hReverse )
|
|
|
|
scrollX = scrollVec.x;
|
|
|
|
else
|
|
|
|
scrollX = ( axis == wxMOUSE_WHEEL_HORIZONTAL ) ? scrollVec.x : -scrollVec.x;
|
|
|
|
}
|
2013-04-23 10:07:14 +00:00
|
|
|
else
|
2023-08-17 19:17:50 +00:00
|
|
|
{
|
2020-05-17 00:19:48 +00:00
|
|
|
scrollY = -scrollVec.y;
|
2023-08-17 19:17:50 +00:00
|
|
|
}
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2016-02-24 19:53:02 +00:00
|
|
|
VECTOR2D delta( scrollX, scrollY );
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
m_view->SetCenter( m_view->GetCenter() + delta );
|
2022-11-28 19:04:03 +00:00
|
|
|
refreshMouse( true );
|
2013-04-23 10:07:14 +00:00
|
|
|
}
|
2013-04-22 09:08:02 +00:00
|
|
|
|
2019-01-04 12:10:34 +00:00
|
|
|
// Do not skip this event, otherwise wxWidgets will fire
|
|
|
|
// 3 wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN (normal wxWidgets behavior)
|
|
|
|
// and we do not want that.
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-21 20:54:29 +00:00
|
|
|
void WX_VIEW_CONTROLS::onMagnify( wxMouseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Scale based on the magnification from our underlying magnification event.
|
|
|
|
VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
2015-05-22 07:37:57 +00:00
|
|
|
m_view->SetScale( m_view->GetScale() * ( aEvent.GetMagnification() + 1.0f ), anchor );
|
2015-05-21 20:54:29 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-07 11:18:35 +00:00
|
|
|
void WX_VIEW_CONTROLS::setState( STATE aNewState )
|
|
|
|
{
|
|
|
|
m_state = aNewState;
|
|
|
|
}
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-22 16:42:53 +00:00
|
|
|
switch( m_state )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-22 16:42:53 +00:00
|
|
|
case IDLE:
|
|
|
|
case AUTO_PANNING:
|
2020-05-17 00:19:48 +00:00
|
|
|
if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::PAN ) ||
|
|
|
|
( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::PAN ) )
|
2013-08-22 16:42:53 +00:00
|
|
|
{
|
|
|
|
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( DRAG_PANNING );
|
2024-03-12 07:31:23 +00:00
|
|
|
m_infinitePanWorks = KIPLATFORM::UI::InfiniteDragPrepareWindow( m_parentPanel );
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-01-20 02:05:42 +00:00
|
|
|
if( !m_parentPanel->HasCapture() )
|
|
|
|
m_parentPanel->CaptureMouse();
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2020-05-17 00:19:48 +00:00
|
|
|
else if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::ZOOM ) ||
|
|
|
|
( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::ZOOM ) )
|
|
|
|
{
|
|
|
|
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
2021-01-18 22:07:59 +00:00
|
|
|
m_zoomStartPoint = m_dragStartPoint;
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( DRAG_ZOOMING );
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-01-20 02:05:42 +00:00
|
|
|
if( !m_parentPanel->HasCapture() )
|
|
|
|
m_parentPanel->CaptureMouse();
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2020-05-17 00:19:48 +00:00
|
|
|
}
|
2013-09-09 11:57:56 +00:00
|
|
|
|
|
|
|
if( aEvent.LeftUp() )
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE ); // Stop autopanning when user release left mouse button
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
|
|
|
|
2020-05-17 00:19:48 +00:00
|
|
|
case DRAG_ZOOMING:
|
2013-08-22 16:42:53 +00:00
|
|
|
case DRAG_PANNING:
|
2017-09-06 01:28:01 +00:00
|
|
|
if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
|
2021-01-18 22:07:59 +00:00
|
|
|
{
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2023-09-17 17:41:58 +00:00
|
|
|
KIPLATFORM::UI::InfiniteDragReleaseWindow();
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-07-04 15:23:23 +00:00
|
|
|
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
|
2021-01-20 02:05:42 +00:00
|
|
|
m_parentPanel->ReleaseMouse();
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2021-01-18 22:07:59 +00:00
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
2013-09-02 14:26:42 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
aEvent.Skip();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
2013-04-22 09:08:02 +00:00
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent )
|
2013-04-22 09:08:02 +00:00
|
|
|
{
|
2020-11-05 02:06:36 +00:00
|
|
|
// Avoid stealing focus from text controls
|
|
|
|
// This is particularly important for users using On-Screen-Keyboards
|
|
|
|
// They may move the mouse over the canvas to reach the keyboard
|
|
|
|
if( KIUI::IsInputControlFocused() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-12 18:05:06 +00:00
|
|
|
#if defined( _WIN32 ) || defined( __WXGTK__ )
|
|
|
|
// Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the mouse regardless
|
2021-07-15 19:26:35 +00:00
|
|
|
// of focus. Forcing the focus here will cause the EDA FRAMES to immediately become the
|
|
|
|
// top level active window.
|
2020-10-17 02:54:36 +00:00
|
|
|
if( m_parentPanel->GetParent() != nullptr )
|
|
|
|
{
|
|
|
|
// this assumes the parent panel's parent is the eda window
|
2021-06-07 22:20:47 +00:00
|
|
|
if( KIPLATFORM::UI::IsWindowActive( m_parentPanel->GetParent() ) )
|
2020-10-17 02:54:36 +00:00
|
|
|
{
|
|
|
|
m_parentPanel->SetFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2013-04-22 09:08:02 +00:00
|
|
|
m_parentPanel->SetFocus();
|
2020-10-17 02:54:36 +00:00
|
|
|
#endif
|
2013-04-22 09:08:02 +00:00
|
|
|
}
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
|
2015-03-10 12:20:38 +00:00
|
|
|
void WX_VIEW_CONTROLS::onLeave( wxMouseEvent& aEvent )
|
|
|
|
{
|
2021-01-21 00:35:59 +00:00
|
|
|
#if !defined USE_MOUSE_CAPTURE
|
|
|
|
onMotion( aEvent );
|
|
|
|
#endif
|
2015-03-10 12:20:38 +00:00
|
|
|
}
|
|
|
|
|
2021-01-20 19:01:51 +00:00
|
|
|
void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent )
|
|
|
|
{
|
2021-04-19 19:03:33 +00:00
|
|
|
// This method must be present to suppress the capture-lost assertion
|
|
|
|
|
|
|
|
// Set the flag to allow calling m_parentPanel->CaptureMouse()
|
2021-07-15 19:26:35 +00:00
|
|
|
// Note: One cannot call m_parentPanel->CaptureMouse() twice, this is not accepted
|
2021-04-19 19:03:33 +00:00
|
|
|
// by wxWidgets (MSW specific) so we need this guard
|
|
|
|
m_parentPanel->m_MouseCapturedLost = true;
|
2021-01-20 19:01:51 +00:00
|
|
|
}
|
2015-03-10 12:20:38 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case AUTO_PANNING:
|
|
|
|
{
|
2018-02-14 08:22:56 +00:00
|
|
|
if( !m_settings.m_autoPanEnabled )
|
2017-03-20 10:45:34 +00:00
|
|
|
{
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2017-03-20 10:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-07 03:07:02 +00:00
|
|
|
#ifdef __WXMSW__
|
2022-09-07 11:18:35 +00:00
|
|
|
// Hackfix: It's possible for the mouse to leave the canvas
|
|
|
|
// without triggering any leave events on windows
|
|
|
|
// Use a MSW only wx function
|
|
|
|
if( !m_parentPanel->IsMouseInWindow() )
|
2022-09-07 03:07:02 +00:00
|
|
|
{
|
|
|
|
m_panTimer.Stop();
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2022-09-07 03:07:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-04 20:04:17 +00:00
|
|
|
if( !m_parentPanel->HasFocus() && !m_parentPanel->StatusPopupHasFocus() )
|
|
|
|
{
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2022-09-04 20:04:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-05-14 07:42:16 +00:00
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
double borderSize = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
|
|
|
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2021-01-19 09:26:33 +00:00
|
|
|
// When the mouse cursor is outside the area with no pan,
|
|
|
|
// m_panDirection is the dist to this area limit ( in pixels )
|
|
|
|
// It will be used also as pan value (the pan speed depends on this dist).
|
2013-08-22 16:42:53 +00:00
|
|
|
VECTOR2D dir( m_panDirection );
|
|
|
|
|
2021-01-19 09:26:33 +00:00
|
|
|
// When the mouse cursor is outside the area with no pan, the pan value
|
|
|
|
// is accelerated depending on the dist between the area and the cursor
|
2020-05-17 00:19:48 +00:00
|
|
|
float accel = 0.5f + ( m_settings.m_autoPanAcceleration / 5.0f );
|
|
|
|
|
2021-01-19 09:26:33 +00:00
|
|
|
// For a small mouse cursor dist to area, just use the distance.
|
|
|
|
// But for a dist > borderSize / 2, use an accelerated pan value
|
|
|
|
|
|
|
|
if( dir.EuclideanNorm() >= borderSize ) // far from area limits
|
|
|
|
dir = dir.Resize( borderSize * accel );
|
|
|
|
else if( dir.EuclideanNorm() > borderSize / 2 ) // Near from area limits
|
2013-08-22 16:42:53 +00:00
|
|
|
dir = dir.Resize( borderSize );
|
|
|
|
|
|
|
|
dir = m_view->ToWorld( dir, false );
|
2020-01-07 19:35:45 +00:00
|
|
|
m_view->SetCenter( m_view->GetCenter() + dir );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2022-11-28 19:04:03 +00:00
|
|
|
refreshMouse( true );
|
2022-11-17 00:30:55 +00:00
|
|
|
|
|
|
|
m_panTimer.Start();
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-02 14:26:42 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
case IDLE: // Just remove unnecessary warnings
|
2013-09-02 14:26:42 +00:00
|
|
|
case DRAG_PANNING:
|
2020-05-17 00:19:48 +00:00
|
|
|
case DRAG_ZOOMING:
|
2013-09-02 14:26:42 +00:00
|
|
|
break;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-18 11:48:10 +00:00
|
|
|
void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
|
|
|
|
{
|
2017-09-14 00:07:29 +00:00
|
|
|
const double linePanDelta = 0.05;
|
|
|
|
const double pagePanDelta = 0.5;
|
|
|
|
|
|
|
|
int type = aEvent.GetEventType();
|
|
|
|
int dir = aEvent.GetOrientation();
|
|
|
|
|
|
|
|
if( type == wxEVT_SCROLLWIN_THUMBTRACK )
|
|
|
|
{
|
2018-08-03 12:00:05 +00:00
|
|
|
auto center = m_view->GetCenter();
|
|
|
|
const auto& boundary = m_view->GetBoundary();
|
2017-09-14 00:07:29 +00:00
|
|
|
|
2018-01-04 21:56:58 +00:00
|
|
|
// Flip scroll direction in flipped view
|
|
|
|
const double xstart = ( m_view->IsMirroredX() ?
|
|
|
|
boundary.GetRight() : boundary.GetLeft() );
|
|
|
|
const double xdelta = ( m_view->IsMirroredX() ? -1 : 1 );
|
|
|
|
|
2017-09-14 00:07:29 +00:00
|
|
|
if( dir == wxHORIZONTAL )
|
2018-01-04 21:56:58 +00:00
|
|
|
center.x = xstart + xdelta * ( aEvent.GetPosition() / m_scrollScale.x );
|
2017-09-14 00:07:29 +00:00
|
|
|
else
|
|
|
|
center.y = boundary.GetTop() + aEvent.GetPosition() / m_scrollScale.y;
|
|
|
|
|
|
|
|
m_view->SetCenter( center );
|
|
|
|
}
|
2023-06-29 22:19:14 +00:00
|
|
|
else if( type == wxEVT_SCROLLWIN_THUMBRELEASE ||
|
|
|
|
type == wxEVT_SCROLLWIN_TOP ||
|
|
|
|
type == wxEVT_SCROLLWIN_BOTTOM )
|
|
|
|
{
|
|
|
|
// Do nothing on thumb release, we don't care about it.
|
|
|
|
// We don't have a concept of top or bottom in our viewport, so ignore those events.
|
|
|
|
}
|
2017-09-14 00:07:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
double dist = 0;
|
|
|
|
|
|
|
|
if( type == wxEVT_SCROLLWIN_PAGEUP )
|
2023-10-29 17:52:05 +00:00
|
|
|
{
|
2017-09-14 00:07:29 +00:00
|
|
|
dist = pagePanDelta;
|
2023-10-29 17:52:05 +00:00
|
|
|
}
|
2017-09-14 00:07:29 +00:00
|
|
|
else if( type == wxEVT_SCROLLWIN_PAGEDOWN )
|
2023-10-29 17:52:05 +00:00
|
|
|
{
|
2017-09-14 00:07:29 +00:00
|
|
|
dist = -pagePanDelta;
|
2023-10-29 17:52:05 +00:00
|
|
|
}
|
2017-09-14 00:07:29 +00:00
|
|
|
else if( type == wxEVT_SCROLLWIN_LINEUP )
|
2023-10-29 17:52:05 +00:00
|
|
|
{
|
2017-09-14 00:07:29 +00:00
|
|
|
dist = linePanDelta;
|
2023-10-29 17:52:05 +00:00
|
|
|
}
|
2017-09-14 00:07:29 +00:00
|
|
|
else if( type == wxEVT_SCROLLWIN_LINEDOWN )
|
2023-10-29 17:52:05 +00:00
|
|
|
{
|
2017-09-14 00:07:29 +00:00
|
|
|
dist = -linePanDelta;
|
2023-10-29 17:52:05 +00:00
|
|
|
}
|
2017-09-15 09:20:07 +00:00
|
|
|
else
|
2023-10-29 17:52:05 +00:00
|
|
|
{
|
2021-07-15 19:26:35 +00:00
|
|
|
wxCHECK_MSG( false, /* void */, wxT( "Unhandled event type" ) );
|
2023-10-29 17:52:05 +00:00
|
|
|
}
|
2017-09-14 00:07:29 +00:00
|
|
|
|
|
|
|
VECTOR2D scroll = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) * dist;
|
|
|
|
|
|
|
|
double scrollX = 0.0;
|
|
|
|
double scrollY = 0.0;
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2017-09-14 00:07:29 +00:00
|
|
|
if ( dir == wxHORIZONTAL )
|
|
|
|
scrollX = -scroll.x;
|
|
|
|
else
|
|
|
|
scrollY = -scroll.y;
|
|
|
|
|
|
|
|
VECTOR2D delta( scrollX, scrollY );
|
|
|
|
|
|
|
|
m_view->SetCenter( m_view->GetCenter() + delta );
|
|
|
|
}
|
2015-05-18 11:48:10 +00:00
|
|
|
|
|
|
|
m_parentPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-22 13:57:05 +00:00
|
|
|
void WX_VIEW_CONTROLS::CaptureCursor( bool aEnabled )
|
2013-08-22 16:42:53 +00:00
|
|
|
{
|
2021-01-21 00:35:59 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-04-19 19:03:33 +00:00
|
|
|
// Note: for some reason, m_parentPanel->HasCapture() can be false even if CaptureMouse()
|
|
|
|
// was called (i.e. mouse was captured, so when need to test m_MouseCapturedLost to be
|
|
|
|
// sure a wxEVT_MOUSE_CAPTURE_LOST event was fired before. Otherwise wxMSW complains
|
|
|
|
if( aEnabled && !m_parentPanel->HasCapture() && m_parentPanel->m_MouseCapturedLost )
|
|
|
|
{
|
2013-08-22 16:42:53 +00:00
|
|
|
m_parentPanel->CaptureMouse();
|
2021-04-19 19:03:33 +00:00
|
|
|
|
|
|
|
// Clear the flag to allow calling m_parentPanel->CaptureMouse()
|
|
|
|
// Calling it without calling ReleaseMouse() is not accepted by wxWidgets (MSW specific)
|
|
|
|
m_parentPanel->m_MouseCapturedLost = false;
|
|
|
|
}
|
2021-01-21 02:44:56 +00:00
|
|
|
else if( !aEnabled && m_parentPanel->HasCapture()
|
|
|
|
&& m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
|
2021-04-19 19:03:33 +00:00
|
|
|
{
|
2013-08-22 16:42:53 +00:00
|
|
|
m_parentPanel->ReleaseMouse();
|
2021-04-19 19:03:33 +00:00
|
|
|
|
|
|
|
// Mouse is released, calling CaptureMouse() is allowed now:
|
|
|
|
m_parentPanel->m_MouseCapturedLost = true;
|
|
|
|
}
|
2021-01-21 00:35:59 +00:00
|
|
|
#endif
|
2021-01-18 22:07:59 +00:00
|
|
|
VIEW_CONTROLS::CaptureCursor( aEnabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-24 17:17:51 +00:00
|
|
|
void WX_VIEW_CONTROLS::CancelDrag()
|
|
|
|
{
|
|
|
|
if( m_state == DRAG_PANNING || m_state == DRAG_ZOOMING )
|
|
|
|
{
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2021-01-24 17:17:51 +00:00
|
|
|
#if defined USE_MOUSE_CAPTURE
|
2021-07-04 15:23:23 +00:00
|
|
|
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
|
2021-01-24 17:17:51 +00:00
|
|
|
m_parentPanel->ReleaseMouse();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-12 13:27:10 +00:00
|
|
|
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
2013-09-16 14:46:02 +00:00
|
|
|
{
|
2018-02-13 08:45:03 +00:00
|
|
|
wxPoint msp = getMouseScreenPosition();
|
2017-08-22 13:13:25 +00:00
|
|
|
VECTOR2D screenPos( msp.x, msp.y );
|
2013-09-16 14:46:02 +00:00
|
|
|
|
2022-02-11 16:42:52 +00:00
|
|
|
return aWorldCoordinates ? GetClampedCoords( m_view->ToWorld( screenPos ) ) : screenPos;
|
2013-09-16 14:46:02 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 08:45:03 +00:00
|
|
|
|
2017-11-15 23:42:40 +00:00
|
|
|
VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const
|
|
|
|
{
|
2020-09-11 03:07:56 +00:00
|
|
|
GAL* gal = m_view->GetGAL();
|
|
|
|
|
|
|
|
if( aEnableSnapping && gal->GetGridSnapping() )
|
2017-11-15 23:42:40 +00:00
|
|
|
{
|
2020-09-11 03:07:56 +00:00
|
|
|
return gal->GetGridPoint( m_cursorPos );
|
2017-11-15 23:42:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_cursorPos;
|
|
|
|
}
|
|
|
|
}
|
2013-09-16 14:46:02 +00:00
|
|
|
|
2018-02-13 08:45:03 +00:00
|
|
|
|
2017-07-12 07:34:20 +00:00
|
|
|
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
|
2014-02-13 19:23:28 +00:00
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_forceCursorPosition )
|
2015-07-15 15:32:30 +00:00
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
return m_settings.m_forcedPosition;
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
{
|
2022-02-11 16:42:52 +00:00
|
|
|
return GetClampedCoords( GetRawCursorPosition( aEnableSnapping ) );
|
2014-02-13 19:23:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-08 19:47:00 +00:00
|
|
|
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView,
|
2019-12-15 14:29:22 +00:00
|
|
|
bool aTriggeredByArrows, long aArrowCommand )
|
2017-08-22 13:13:25 +00:00
|
|
|
{
|
|
|
|
m_updateCursor = false;
|
2019-01-08 19:47:00 +00:00
|
|
|
|
2022-02-11 16:42:52 +00:00
|
|
|
VECTOR2D clampedPosition = GetClampedCoords( aPosition );
|
|
|
|
|
2018-12-23 17:57:40 +00:00
|
|
|
if( aTriggeredByArrows )
|
|
|
|
{
|
|
|
|
m_settings.m_lastKeyboardCursorPositionValid = true;
|
2022-02-11 16:42:52 +00:00
|
|
|
m_settings.m_lastKeyboardCursorPosition = clampedPosition;
|
2019-12-15 14:29:22 +00:00
|
|
|
m_settings.m_lastKeyboardCursorCommand = aArrowCommand;
|
2019-01-08 19:47:00 +00:00
|
|
|
m_cursorWarped = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-23 17:57:40 +00:00
|
|
|
m_settings.m_lastKeyboardCursorPositionValid = false;
|
2020-01-10 17:20:10 +00:00
|
|
|
m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 };
|
|
|
|
m_settings.m_lastKeyboardCursorCommand = 0;
|
2019-01-08 19:47:00 +00:00
|
|
|
m_cursorWarped = true;
|
2018-12-23 17:57:40 +00:00
|
|
|
}
|
2019-01-08 19:47:00 +00:00
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
WarpMouseCursor( clampedPosition, true, aWarpView );
|
2022-02-11 16:42:52 +00:00
|
|
|
m_cursorPos = clampedPosition;
|
2017-08-22 13:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition,
|
|
|
|
bool aWarpView = true )
|
2018-01-17 14:36:04 +00:00
|
|
|
{
|
|
|
|
m_updateCursor = false;
|
|
|
|
|
2022-02-11 16:42:52 +00:00
|
|
|
VECTOR2D clampedPosition = GetClampedCoords( aPosition );
|
|
|
|
|
2018-01-17 14:36:04 +00:00
|
|
|
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
2022-02-11 16:42:52 +00:00
|
|
|
BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
|
|
|
|
VECTOR2D screenPos = m_view->ToScreen( clampedPosition );
|
2018-01-17 14:36:04 +00:00
|
|
|
|
2018-09-09 09:57:36 +00:00
|
|
|
if( aWarpView && !screen.Contains( screenPos ) )
|
2022-02-11 16:42:52 +00:00
|
|
|
m_view->SetCenter( clampedPosition );
|
2018-01-17 14:36:04 +00:00
|
|
|
|
2022-02-11 16:42:52 +00:00
|
|
|
m_cursorPos = clampedPosition;
|
2018-01-17 14:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
void WX_VIEW_CONTROLS::WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
|
|
|
|
bool aWarpView )
|
2015-07-15 15:32:30 +00:00
|
|
|
{
|
|
|
|
if( aWorldCoordinates )
|
|
|
|
{
|
|
|
|
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
2022-02-11 16:42:52 +00:00
|
|
|
BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
|
|
|
|
VECTOR2D clampedPosition = GetClampedCoords( aPosition );
|
|
|
|
VECTOR2D screenPos = m_view->ToScreen( clampedPosition );
|
2015-07-15 15:32:30 +00:00
|
|
|
|
|
|
|
if( !screen.Contains( screenPos ) )
|
|
|
|
{
|
|
|
|
if( aWarpView )
|
|
|
|
{
|
2022-02-11 16:42:52 +00:00
|
|
|
m_view->SetCenter( clampedPosition );
|
2022-06-24 16:54:28 +00:00
|
|
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, screenSize.x / 2, screenSize.y / 2 );
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-24 16:54:28 +00:00
|
|
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, screenPos.x, screenPos.y );
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-24 16:54:28 +00:00
|
|
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y );
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
2017-09-22 09:13:26 +00:00
|
|
|
|
2022-11-28 19:04:03 +00:00
|
|
|
// If we are not refreshing because of mouse movement, don't set the modifiers
|
|
|
|
// because we are refreshing for keyboard movement, which uses the same modifiers for other actions
|
|
|
|
refreshMouse( m_updateCursor );
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-02 09:20:43 +00:00
|
|
|
void WX_VIEW_CONTROLS::CenterOnCursor()
|
2015-07-24 07:42:45 +00:00
|
|
|
{
|
|
|
|
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
2024-04-13 01:48:41 +00:00
|
|
|
VECTOR2D screenCenter( screenSize / 2 );
|
2015-07-24 07:42:45 +00:00
|
|
|
|
2017-06-12 13:27:10 +00:00
|
|
|
if( GetMousePosition( false ) != screenCenter )
|
2015-07-24 07:42:45 +00:00
|
|
|
{
|
2023-09-22 02:10:42 +00:00
|
|
|
VECTOR2D newCenter = GetCursorPosition();
|
|
|
|
|
|
|
|
if( KIPLATFORM::UI::WarpPointer( m_parentPanel, screenCenter.x, screenCenter.y ) )
|
|
|
|
{
|
|
|
|
m_view->SetCenter( newCenter );
|
|
|
|
m_dragStartPoint = screenCenter;
|
|
|
|
}
|
2015-07-24 07:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
void WX_VIEW_CONTROLS::PinCursorInsideNonAutoscrollArea( bool aWarpMouseCursor )
|
|
|
|
{
|
|
|
|
int border = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
|
|
|
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
|
|
|
border += 2;
|
|
|
|
|
|
|
|
VECTOR2D topLeft( border, border );
|
|
|
|
VECTOR2D botRight( m_view->GetScreenPixelSize().x - border,
|
|
|
|
m_view->GetScreenPixelSize().y - border );
|
|
|
|
|
|
|
|
topLeft = m_view->ToWorld( topLeft );
|
|
|
|
botRight = m_view->ToWorld( botRight );
|
|
|
|
|
|
|
|
VECTOR2D pos = GetMousePosition( true );
|
|
|
|
|
|
|
|
if( pos.x < topLeft.x )
|
|
|
|
pos.x = topLeft.x;
|
|
|
|
else if( pos.x > botRight.x )
|
|
|
|
pos.x = botRight.x;
|
|
|
|
|
|
|
|
if( pos.y < topLeft.y )
|
|
|
|
pos.y = topLeft.y;
|
|
|
|
else if( pos.y > botRight.y )
|
|
|
|
pos.y = botRight.y;
|
|
|
|
|
|
|
|
SetCursorPosition( pos, false, false, 0 );
|
|
|
|
|
|
|
|
if( aWarpMouseCursor )
|
|
|
|
WarpMouseCursor( pos, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
2013-08-22 16:42:53 +00:00
|
|
|
{
|
2018-12-23 17:57:40 +00:00
|
|
|
VECTOR2I p( aEvent.GetX(), aEvent.GetY() );
|
|
|
|
VECTOR2I pKey( m_view->ToScreen(m_settings.m_lastKeyboardCursorPosition ) );
|
|
|
|
|
2020-11-10 20:31:52 +00:00
|
|
|
if( m_cursorWarped || ( m_settings.m_lastKeyboardCursorPositionValid && p == pKey ) )
|
2018-12-23 17:57:40 +00:00
|
|
|
{
|
2021-07-15 19:26:35 +00:00
|
|
|
// last cursor move event came from keyboard cursor control. If auto-panning is enabled
|
|
|
|
// and the next position is inside the autopan zone, check if it really came from a mouse
|
|
|
|
// event, otherwise disable autopan temporarily. Also temporarily disable autopan if the
|
|
|
|
// cursor is in the autopan zone because the application warped the cursor.
|
2018-12-23 17:57:40 +00:00
|
|
|
|
2019-01-08 19:47:00 +00:00
|
|
|
m_cursorWarped = false;
|
2018-12-23 17:57:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2019-01-08 19:47:00 +00:00
|
|
|
m_cursorWarped = false;
|
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
// Compute areas where autopanning is active
|
2018-12-23 17:57:40 +00:00
|
|
|
int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
2021-07-15 19:26:35 +00:00
|
|
|
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
2020-01-07 19:35:45 +00:00
|
|
|
borderStart = std::max( borderStart, 2 );
|
2018-12-23 17:57:40 +00:00
|
|
|
int borderEndX = m_view->GetScreenPixelSize().x - borderStart;
|
|
|
|
int borderEndY = m_view->GetScreenPixelSize().y - borderStart;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
if( p.x < borderStart )
|
|
|
|
m_panDirection.x = -( borderStart - p.x );
|
|
|
|
else if( p.x > borderEndX )
|
|
|
|
m_panDirection.x = ( p.x - borderEndX );
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
m_panDirection.x = 0;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
if( p.y < borderStart )
|
|
|
|
m_panDirection.y = -( borderStart - p.y );
|
|
|
|
else if( p.y > borderEndY )
|
|
|
|
m_panDirection.y = ( p.y - borderEndY );
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
m_panDirection.y = 0;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
bool borderHit = ( m_panDirection.x != 0 || m_panDirection.y != 0 );
|
|
|
|
|
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case AUTO_PANNING:
|
|
|
|
if( !borderHit )
|
|
|
|
{
|
|
|
|
m_panTimer.Stop();
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( IDLE );
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
return true;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
case IDLE:
|
|
|
|
if( borderHit )
|
|
|
|
{
|
2022-09-07 11:18:35 +00:00
|
|
|
setState( AUTO_PANNING );
|
2022-11-17 00:30:55 +00:00
|
|
|
m_panTimer.Start( (int) ( 250.0 / 60.0 ), true );
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
return true;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
case DRAG_PANNING:
|
2020-05-17 00:19:48 +00:00
|
|
|
case DRAG_ZOOMING:
|
2013-09-02 14:26:42 +00:00
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-09-02 14:26:42 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
wxCHECK_MSG( false, false, wxT( "This line should never be reached" ) );
|
2022-10-31 14:29:09 +00:00
|
|
|
|
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2015-05-18 11:48:10 +00:00
|
|
|
|
|
|
|
|
2021-01-22 13:57:05 +00:00
|
|
|
void WX_VIEW_CONTROLS::handleCursorCapture( int x, int y )
|
|
|
|
{
|
|
|
|
if( m_settings.m_cursorCaptured )
|
|
|
|
{
|
|
|
|
bool warp = false;
|
|
|
|
wxSize parentSize = m_parentPanel->GetClientSize();
|
|
|
|
|
|
|
|
if( x < 0 )
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
else if( x >= parentSize.x )
|
|
|
|
{
|
|
|
|
x = parentSize.x - 1;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( y < 0 )
|
|
|
|
{
|
|
|
|
y = 0;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
else if( y >= parentSize.y )
|
|
|
|
{
|
|
|
|
y = parentSize.y - 1;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( warp )
|
2022-06-24 16:54:28 +00:00
|
|
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, x, y );
|
2021-01-22 13:57:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-28 19:04:03 +00:00
|
|
|
void WX_VIEW_CONTROLS::refreshMouse( bool aSetModifiers )
|
2017-09-22 09:13:26 +00:00
|
|
|
{
|
|
|
|
// Notify tools that the cursor position has changed in the world coordinates
|
|
|
|
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
|
2018-02-13 08:45:03 +00:00
|
|
|
wxPoint msp = getMouseScreenPosition();
|
|
|
|
moveEvent.SetX( msp.x );
|
|
|
|
moveEvent.SetY( msp.y );
|
2017-09-22 09:13:26 +00:00
|
|
|
|
2022-11-28 19:04:03 +00:00
|
|
|
if( aSetModifiers )
|
|
|
|
{
|
|
|
|
// Set the modifiers state
|
|
|
|
moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) );
|
|
|
|
moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) );
|
|
|
|
moveEvent.SetAltDown( wxGetKeyState( WXK_ALT ) );
|
|
|
|
}
|
2017-09-22 09:13:26 +00:00
|
|
|
|
2022-02-11 16:42:52 +00:00
|
|
|
m_cursorPos = GetClampedCoords( m_view->ToWorld( VECTOR2D( msp.x, msp.y ) ) );
|
2017-09-22 09:13:26 +00:00
|
|
|
wxPostEvent( m_parentPanel, moveEvent );
|
2018-02-13 08:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxPoint WX_VIEW_CONTROLS::getMouseScreenPosition() const
|
|
|
|
{
|
2023-09-18 03:13:09 +00:00
|
|
|
wxPoint msp = KIPLATFORM::UI::GetMousePosition();
|
2018-02-13 08:45:03 +00:00
|
|
|
m_parentPanel->ScreenToClient( &msp.x, &msp.y );
|
|
|
|
return msp;
|
2017-09-22 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-18 11:48:10 +00:00
|
|
|
void WX_VIEW_CONTROLS::UpdateScrollbars()
|
|
|
|
{
|
|
|
|
const BOX2D viewport = m_view->GetViewport();
|
2018-08-03 12:00:05 +00:00
|
|
|
const BOX2D& boundary = m_view->GetBoundary();
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2017-02-06 23:05:07 +00:00
|
|
|
m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often
|
|
|
|
m_scrollScale.y = 2e3 / viewport.GetHeight();
|
|
|
|
VECTOR2I newScroll( ( viewport.Centre().x - boundary.GetLeft() ) * m_scrollScale.x,
|
2021-07-15 19:26:35 +00:00
|
|
|
( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2019-08-22 05:05:15 +00:00
|
|
|
// We add the width of the scroll bar thumb to the range because the scroll range is given by
|
|
|
|
// the full bar while the position is given by the left/top position of the thumb
|
2021-07-15 19:26:35 +00:00
|
|
|
VECTOR2I newRange( m_scrollScale.x * boundary.GetWidth() +
|
|
|
|
m_parentPanel->GetScrollThumb( wxSB_HORIZONTAL ),
|
|
|
|
m_scrollScale.y * boundary.GetHeight() +
|
|
|
|
m_parentPanel->GetScrollThumb( wxSB_VERTICAL ) );
|
2019-08-22 05:05:15 +00:00
|
|
|
|
2018-01-04 21:56:58 +00:00
|
|
|
// Flip scroll direction in flipped view
|
|
|
|
if( m_view->IsMirroredX() )
|
|
|
|
newScroll.x = ( boundary.GetRight() - viewport.Centre().x ) * m_scrollScale.x;
|
|
|
|
|
2019-08-22 05:05:15 +00:00
|
|
|
// Adjust scrollbars only if it is needed. Otherwise there are cases when canvas is continuously
|
2017-02-06 23:05:07 +00:00
|
|
|
// refreshed (Windows)
|
2019-08-22 05:05:15 +00:00
|
|
|
if( m_scrollPos != newScroll || newRange.x != m_parentPanel->GetScrollRange( wxSB_HORIZONTAL )
|
|
|
|
|| newRange.y != m_parentPanel->GetScrollRange( wxSB_VERTICAL ) )
|
2017-02-06 23:05:07 +00:00
|
|
|
{
|
2021-07-15 19:26:35 +00:00
|
|
|
m_parentPanel->SetScrollbars( 1, 1, newRange.x, newRange.y, newScroll.x, newScroll.y,
|
|
|
|
true );
|
2017-02-06 23:05:07 +00:00
|
|
|
m_scrollPos = newScroll;
|
2019-08-22 05:05:15 +00:00
|
|
|
|
2020-11-11 00:59:13 +00:00
|
|
|
#if !defined( __APPLE__ ) && !defined( WIN32 )
|
2019-08-25 19:47:38 +00:00
|
|
|
// Trigger a mouse refresh to get the canvas update in GTK (re-draws the scrollbars).
|
2021-07-15 19:26:35 +00:00
|
|
|
// Note that this causes an infinite loop on OSX and Windows (in certain cases) as it
|
|
|
|
// generates a paint event.
|
2022-11-28 19:04:03 +00:00
|
|
|
refreshMouse( false );
|
2019-08-25 19:47:38 +00:00
|
|
|
#endif
|
2017-02-06 23:05:07 +00:00
|
|
|
}
|
2015-05-18 11:48:10 +00:00
|
|
|
}
|
2018-12-23 17:57:40 +00:00
|
|
|
|
|
|
|
void WX_VIEW_CONTROLS::ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition )
|
|
|
|
{
|
2022-02-11 16:42:52 +00:00
|
|
|
VECTOR2D clampedPosition = GetClampedCoords( aPosition );
|
|
|
|
|
2018-12-23 17:57:40 +00:00
|
|
|
m_settings.m_forceCursorPosition = aEnabled;
|
2022-02-11 16:42:52 +00:00
|
|
|
m_settings.m_forcedPosition = clampedPosition;
|
2018-12-23 17:57:40 +00:00
|
|
|
}
|