When showing/hiding infobar, keep position

The infobar changes the size of the visible screen, so adding/removing
it will shift the screen center, causing the position of onscreen
objects to move up/down.  This changes the sizing to pin the bottom
corner position when showing/hiding the infobar

Fixes https://gitlab.com/kicad/code/kicad/issues/5776
This commit is contained in:
Seth Hillbrand 2020-09-24 15:13:53 -07:00
parent 672756a018
commit d535a4b833
2 changed files with 24 additions and 0 deletions

View File

@ -42,6 +42,8 @@
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <widgets/infobar.h>
#ifdef PROFILE
#include <profile.h>
#endif /* PROFILE */
@ -262,12 +264,26 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
{
KIGFX::GAL_CONTEXT_LOCKER locker( m_gal );
wxSize clientSize = GetClientSize();
WX_INFOBAR* infobar = GetParentEDAFrame()->GetInfoBar();
if( VECTOR2I( clientSize ) == m_gal->GetScreenPixelSize() )
return;
clientSize.x = std::max( 10, clientSize.x );
clientSize.y = std::max( 10, clientSize.y );
VECTOR2D bottom( 0, 0 );
if( m_view )
bottom = m_view->ToWorld( m_gal->GetScreenPixelSize(), true );
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
if( m_view )
{
if( infobar && infobar->IsLocked() )
m_view->SetCenter( bottom - m_view->ToWorld( clientSize, false ) / 2.0 );
m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}

View File

@ -156,6 +156,14 @@ public:
*/
void QueueDismiss();
/**
* Returns true if the infobar is being updated.
*/
bool IsLocked()
{
return m_updateLock;
}
protected:
/**
* Event handler for showing the infobar using a wxCommandEvent of the type