From c4a4862e8f5323832164ef5e1b156ee14982bf33 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 16 Dec 2021 07:56:21 +0300 Subject: [PATCH] Try with KIPLATFORM --- eeschema/dialogs/dialog_symbol_fields_table.cpp | 11 +++-------- libs/kiplatform/gtk/ui.cpp | 7 +++++++ libs/kiplatform/include/kiplatform/ui.h | 8 ++++++++ libs/kiplatform/msw/ui.cpp | 6 ++++++ libs/kiplatform/osx/ui.mm | 7 +++++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/eeschema/dialogs/dialog_symbol_fields_table.cpp b/eeschema/dialogs/dialog_symbol_fields_table.cpp index 38d769f9e3..8ee7d247c6 100644 --- a/eeschema/dialogs/dialog_symbol_fields_table.cpp +++ b/eeschema/dialogs/dialog_symbol_fields_table.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1170,14 +1171,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnTableItemContextMenu( wxGridEvent& event ) void DIALOG_SYMBOL_FIELDS_TABLE::OnSizeFieldList( wxSizeEvent& event ) { - // GetClientSize subtracts scrollbars width on Windows. - // On other platforms, the visible area must be computed manually. -#ifdef __WINDOWS__ - int nameColWidth = m_fieldsCtrl->GetClientSize().x - m_showColWidth - m_groupByColWidth; -#else - int nameColWidth = event.GetSize().GetX() - m_showColWidth - m_groupByColWidth - - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ); -#endif + int nameColWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsCtrl ).x - m_showColWidth + - m_groupByColWidth; // GTK loses its head and messes these up when resizing the splitter bar: m_fieldsCtrl->GetColumn( SHOW_FIELD_COLUMN )->SetWidth( m_showColWidth ); diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index c4367019a4..0140dbcec3 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -120,3 +120,10 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow ) return val; } + + +wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow ) +{ + return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ), + aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) ); +} diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index 9074b9ee44..e9f422a880 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -101,6 +101,14 @@ namespace KIPLATFORM * @return System scale factor in use, defaulting to the wxWidgets method */ double GetSystemScaleFactor( const wxWindow* aWindow ); + + /** + * Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl, wxGrid) + * that won't be obscured by scrollbars. + * @param aWindow pointer to the scrollable widget to check + * @return Viewport size that won't be obscured by scrollbars + */ + wxSize GetUnobscuredSize( const wxWindow* aWindow ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 14d886b128..d6cef3d52f 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -120,3 +120,9 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow ) { return aWindow->GetContentScaleFactor(); } + + +wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow ) +{ + return aWindow->GetClientSize(); +} diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index ff5f06884e..e47ce28bd2 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -119,3 +119,10 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow ) { return aWindow->GetContentScaleFactor(); } + + +wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow ) +{ + return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ), + aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) ); +}