From c6bcfda84c237b9c508d31765cbade574fb0207e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 8 Apr 2023 16:41:41 +0200 Subject: [PATCH] DIALOG_IMAGE_PROPERTIES: fix some issues: - add missing dialog_image_properties_base.fpb file - fix not displayed image. --- common/dialogs/panel_image_editor.cpp | 19 +++++++++++++------ .../dialogs/dialog_image_properties_base.cpp | 3 +-- .../dialogs/dialog_image_properties_base.fbp | 13 +++++++++++-- .../dialogs/dialog_image_properties_base.h | 4 ++-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/common/dialogs/panel_image_editor.cpp b/common/dialogs/panel_image_editor.cpp index 33d2a2a5a9..38fa0e8c16 100644 --- a/common/dialogs/panel_image_editor.cpp +++ b/common/dialogs/panel_image_editor.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2018 jean-pierre.charras - * Copyright (C) 2011-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2011-2023 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -110,12 +110,19 @@ bool PANEL_IMAGE_EDITOR::TransferDataFromWindow() void PANEL_IMAGE_EDITOR::OnRedrawPanel( wxPaintEvent& event ) { wxPaintDC dc( m_panelDraw ); - wxSize size = m_panelDraw->GetClientSize(); - dc.SetDeviceOrigin( size.x / 2, size.y / 2 ); + wxSize display_size = m_panelDraw->GetClientSize(); - double scale = 1.0 / m_workingImage->GetScalingFactor(); - dc.SetUserScale( scale, scale ); - m_workingImage->DrawBitmap( &dc, VECTOR2I( 0, 0 ) ); + double img_scale = 1.0 / m_workingImage->GetScalingFactor(); + VECTOR2I img_size_pixels = m_workingImage->GetSizePixels(); + + // Adjust the display scale to use the full available display area + double scale_X = (double)display_size.x/img_size_pixels.x; + double scale_Y = (double)display_size.y/img_size_pixels.y; + + double display_scale = img_scale * std::min( scale_X, scale_Y ); + + dc.SetUserScale( display_scale, display_scale ); + m_workingImage->DrawBitmap( &dc, VECTOR2I( m_workingImage->GetSize()/2 ) ); } diff --git a/eeschema/dialogs/dialog_image_properties_base.cpp b/eeschema/dialogs/dialog_image_properties_base.cpp index ca106077e3..163c1760e5 100644 --- a/eeschema/dialogs/dialog_image_properties_base.cpp +++ b/eeschema/dialogs/dialog_image_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -79,7 +79,6 @@ DIALOG_IMAGE_PROPERTIES_BASE::DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wx this->SetSizer( m_GeneralBoxSizer ); this->Layout(); - m_GeneralBoxSizer->Fit( this ); this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_image_properties_base.fbp b/eeschema/dialogs/dialog_image_properties_base.fbp index 12aac7b0b3..ea64d374bc 100644 --- a/eeschema/dialogs/dialog_image_properties_base.fbp +++ b/eeschema/dialogs/dialog_image_properties_base.fbp @@ -36,6 +36,7 @@ wxBOTH 1 + 0 1 impl_virtual @@ -47,8 +48,8 @@ DIALOG_IMAGE_PROPERTIES_BASE - - wxDEFAULT_DIALOG_STYLE + 363,281 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h; forward_declare @@ -87,6 +88,7 @@ Dock 0 Left + 0 1 1 @@ -143,6 +145,7 @@ Dock 0 Left + 0 1 1 @@ -231,6 +234,7 @@ Dock 0 Left + 0 1 1 @@ -292,6 +296,7 @@ Dock 0 Left + 0 1 1 @@ -356,6 +361,7 @@ Dock 0 Left + 0 1 1 @@ -417,6 +423,7 @@ Dock 0 Left + 0 1 1 @@ -478,6 +485,7 @@ Dock 0 Left + 0 1 1 @@ -542,6 +550,7 @@ Dock 0 Left + 0 1 1 diff --git a/eeschema/dialogs/dialog_image_properties_base.h b/eeschema/dialogs/dialog_image_properties_base.h index 999c46ec22..96c1a0b12a 100644 --- a/eeschema/dialogs/dialog_image_properties_base.h +++ b/eeschema/dialogs/dialog_image_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -52,7 +52,7 @@ class DIALOG_IMAGE_PROPERTIES_BASE : public DIALOG_SHIM public: - DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 363,281 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_IMAGE_PROPERTIES_BASE();