Check if scaling factor has changed when top-level window is moved
Fixes #2592
This commit is contained in:
parent
96da45f12f
commit
712ae5a953
|
@ -55,6 +55,7 @@ BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
|
||||||
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuOpen )
|
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuOpen )
|
||||||
EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuOpen )
|
EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuOpen )
|
||||||
EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuOpen )
|
EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuOpen )
|
||||||
|
EVT_MOVE( EDA_BASE_FRAME::OnMove )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
|
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
|
||||||
|
|
|
@ -317,6 +317,23 @@ double EDA_DRAW_FRAME::GetZoom()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
|
||||||
|
{
|
||||||
|
// If the window is moved to a different display, the scaling factor may change
|
||||||
|
double oldFactor = m_galDisplayOptions.m_scaleFactor;
|
||||||
|
m_galDisplayOptions.UpdateScaleFactor();
|
||||||
|
|
||||||
|
if( oldFactor != m_galDisplayOptions.m_scaleFactor )
|
||||||
|
{
|
||||||
|
wxSize clientSize = GetClientSize();
|
||||||
|
GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
|
||||||
|
GetCanvas()->GetView()->MarkDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
aEvent.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::AddStandardSubMenus( TOOL_MENU& aToolMenu )
|
void EDA_DRAW_FRAME::AddStandardSubMenus( TOOL_MENU& aToolMenu )
|
||||||
{
|
{
|
||||||
COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
|
COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
|
||||||
|
|
|
@ -53,6 +53,7 @@ static const wxChar* traceGalDispOpts = wxT( "KICAD_GAL_DISPLAY_OPTIONS" );
|
||||||
GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
|
GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
|
||||||
: gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
|
: gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
|
||||||
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
|
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
|
||||||
|
m_dpi( nullptr, nullptr ),
|
||||||
m_gridStyle( GRID_STYLE::DOTS ),
|
m_gridStyle( GRID_STYLE::DOTS ),
|
||||||
m_gridLineWidth( 1.0 ),
|
m_gridLineWidth( 1.0 ),
|
||||||
m_gridMinSpacing( 10.0 ),
|
m_gridMinSpacing( 10.0 ),
|
||||||
|
@ -89,12 +90,10 @@ void GAL_DISPLAY_OPTIONS::ReadCommonConfig( COMMON_SETTINGS& aSettings, wxWindow
|
||||||
cairo_antialiasing_mode = static_cast<KIGFX::CAIRO_ANTIALIASING_MODE>(
|
cairo_antialiasing_mode = static_cast<KIGFX::CAIRO_ANTIALIASING_MODE>(
|
||||||
aSettings.m_Graphics.cairo_aa_mode );
|
aSettings.m_Graphics.cairo_aa_mode );
|
||||||
|
|
||||||
{
|
m_dpi = DPI_SCALING( &aSettings, aWindow );
|
||||||
const DPI_SCALING dpi{ &aSettings, aWindow };
|
|
||||||
m_scaleFactor = dpi.GetScaleFactor();
|
|
||||||
}
|
|
||||||
|
|
||||||
NotifyChanged();
|
// Also calls NotifyChanged
|
||||||
|
UpdateScaleFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,6 +121,13 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GAL_DISPLAY_OPTIONS::UpdateScaleFactor()
|
||||||
|
{
|
||||||
|
m_scaleFactor = m_dpi.GetScaleFactor();
|
||||||
|
NotifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GAL_DISPLAY_OPTIONS::NotifyChanged()
|
void GAL_DISPLAY_OPTIONS::NotifyChanged()
|
||||||
{
|
{
|
||||||
wxLogTrace( traceGalDispOpts, "Change notification" );
|
wxLogTrace( traceGalDispOpts, "Change notification" );
|
||||||
|
|
|
@ -290,6 +290,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void OnMenuOpen( wxMenuEvent& event );
|
void OnMenuOpen( wxMenuEvent& event );
|
||||||
|
|
||||||
|
virtual void OnMove( wxMoveEvent& aEvent )
|
||||||
|
{
|
||||||
|
aEvent.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void SetAutoSaveInterval( int aInterval );
|
void SetAutoSaveInterval( int aInterval );
|
||||||
|
|
||||||
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
|
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
|
||||||
|
|
|
@ -320,6 +320,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void OnSize( wxSizeEvent& event );
|
virtual void OnSize( wxSizeEvent& event );
|
||||||
|
|
||||||
|
void OnMove( wxMoveEvent& aEvent ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild the GAL and redraws the screen. Call when something went wrong.
|
* Rebuild the GAL and redraws the screen. Call when something went wrong.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#ifndef GAL_DISPLAY_OPTIONS_H__
|
#ifndef GAL_DISPLAY_OPTIONS_H__
|
||||||
#define GAL_DISPLAY_OPTIONS_H__
|
#define GAL_DISPLAY_OPTIONS_H__
|
||||||
|
|
||||||
|
#include <dpi_scaling.h>
|
||||||
#include <observable.h>
|
#include <observable.h>
|
||||||
|
|
||||||
class COMMON_SETTINGS;
|
class COMMON_SETTINGS;
|
||||||
|
@ -102,12 +103,16 @@ namespace KIGFX
|
||||||
|
|
||||||
void WriteConfig( WINDOW_SETTINGS& aCfg );
|
void WriteConfig( WINDOW_SETTINGS& aCfg );
|
||||||
|
|
||||||
|
void UpdateScaleFactor();
|
||||||
|
|
||||||
void NotifyChanged();
|
void NotifyChanged();
|
||||||
|
|
||||||
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode;
|
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode;
|
||||||
|
|
||||||
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode;
|
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode;
|
||||||
|
|
||||||
|
DPI_SCALING m_dpi;
|
||||||
|
|
||||||
///> The grid style to draw the grid in
|
///> The grid style to draw the grid in
|
||||||
KIGFX::GRID_STYLE m_gridStyle;
|
KIGFX::GRID_STYLE m_gridStyle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue