Redo About dialog notebook for better layout

wxAuiNotebook looks terrible with dark mode
Fix HTML window colors

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5948
Fixes https://gitlab.com/kicad/code/kicad/-/issues/5895
This commit is contained in:
Jon Evans 2020-10-10 12:38:04 -04:00
parent fdeb340d21
commit 351a85033a
5 changed files with 109 additions and 71 deletions

View File

@ -53,15 +53,20 @@ DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo )
{
wxASSERT( aParent != nullptr );
m_picInformation = KiBitmap( info_xpm );
m_picVersion = KiBitmap( recent_xpm );
m_picDevelopers = KiBitmap( preference_xpm );
m_picDocWriters = KiBitmap( editor_xpm );
m_picLibrarians = KiBitmap( library_xpm );
m_picArtists = KiBitmap( palette_xpm );
m_picTranslators = KiBitmap( language_xpm );
m_picLicense = KiBitmap( tools_xpm );
m_picPackagers = KiBitmap( zip_xpm );
// TODO: Change these to 16x16 versions when available
m_images = new wxImageList( 26, 26, false, 9 );
m_images->Add( KiBitmap( info_xpm ) ); // INFORMATION
m_images->Add( KiBitmap( recent_xpm ) ); // VERSION
m_images->Add( KiBitmap( preference_xpm ) ); // DEVELOPERS
m_images->Add( KiBitmap( editor_xpm ) ); // DOCWRITERS
m_images->Add( KiBitmap( library_xpm ) ); // LIBRARIANS
m_images->Add( KiBitmap( palette_xpm ) ); // ARTISTS
m_images->Add( KiBitmap( language_xpm ) ); // TRANSLATORS
m_images->Add( KiBitmap( zip_xpm ) ); // PACKAGERS
m_images->Add( KiBitmap( tools_xpm ) ); // LICENSE
m_notebook->SetImageList( m_images );
if( m_info.GetAppIcon().IsOk() )
{
@ -86,7 +91,6 @@ DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo )
createNotebooks();
GetSizer()->SetSizeHints( this );
m_auiNotebook->Update();
SetFocus();
Centre();
}
@ -94,6 +98,7 @@ DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo )
DIALOG_ABOUT::~DIALOG_ABOUT()
{
delete m_images;
}
@ -110,37 +115,40 @@ wxFlexGridSizer* DIALOG_ABOUT::createFlexGridSizer()
void DIALOG_ABOUT::createNotebooks()
{
createNotebookHtmlPage( m_auiNotebook, _( "About" ), m_picInformation,
createNotebookHtmlPage( m_notebook, _( "About" ), IMAGES::INFORMATION,
m_info.GetDescription() );
wxString version = GetVersionInfoData( m_titleName, true );
createNotebookHtmlPage( m_auiNotebook, _( "Version" ), m_picVersion, version, true );
createNotebookHtmlPage( m_notebook, _( "Version" ), IMAGES::VERSION, version, true );
createNotebookPageByCategory( m_auiNotebook, _( "Developers" ) , m_picDevelopers,
createNotebookPageByCategory( m_notebook, _( "Developers" ) , IMAGES::DEVELOPERS,
m_info.GetDevelopers() );
createNotebookPage( m_auiNotebook, _( "Doc Writers" ), m_picDocWriters,
createNotebookPage( m_notebook, _( "Doc Writers" ), IMAGES::DOCWRITERS,
m_info.GetDocWriters() );
createNotebookPageByCategory( m_auiNotebook, _( "Librarians" ), m_picLibrarians,
createNotebookPageByCategory( m_notebook, _( "Librarians" ), IMAGES::LIBRARIANS,
m_info.GetLibrarians() );
createNotebookPageByCategory( m_auiNotebook, _( "Artists" ), m_picArtists,
createNotebookPageByCategory( m_notebook, _( "Artists" ), IMAGES::ARTISTS,
m_info.GetArtists() );
createNotebookPageByCategory( m_auiNotebook, _( "Translators" ), m_picTranslators,
createNotebookPageByCategory( m_notebook, _( "Translators" ), IMAGES::TRANSLATORS,
m_info.GetTranslators() );
createNotebookPageByCategory( m_auiNotebook, _( "Packagers" ), m_picPackagers,
createNotebookPageByCategory( m_notebook, _( "Packagers" ), IMAGES::PACKAGERS,
m_info.GetPackagers() );
createNotebookHtmlPage( m_auiNotebook, _( "License" ), m_picLicense, m_info.GetLicense() );
createNotebookHtmlPage( m_notebook, _( "License" ), IMAGES::LICENSE, m_info.GetLicense() );
}
void DIALOG_ABOUT::createNotebookPage( wxAuiNotebook* aParent, const wxString& aCaption,
const wxBitmap& aIcon, const CONTRIBUTORS& aContributors )
void DIALOG_ABOUT::createNotebookPage( wxNotebook* aParent, const wxString& aCaption,
IMAGES aIconIndex, const CONTRIBUTORS& aContributors )
{
wxPanel* outerPanel = new wxPanel( aParent );
wxBoxSizer* outerSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL );
wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( aParent, wxID_ANY,
wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( outerPanel, wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxHSCROLL|wxVSCROLL );
@ -193,13 +201,17 @@ void DIALOG_ABOUT::createNotebookPage( wxAuiNotebook* aParent, const wxString& a
m_scrolledWindow1->SetSizer( bSizer );
m_scrolledWindow1->Layout();
bSizer->Fit( m_scrolledWindow1 );
aParent->AddPage( m_scrolledWindow1, aCaption, false, aIcon );
outerSizer->Add( m_scrolledWindow1, 1, wxEXPAND, 0 );
outerPanel->SetSizer( outerSizer );
aParent->AddPage( outerPanel, aCaption, false, static_cast<int>( aIconIndex ) );
}
void DIALOG_ABOUT::createNotebookPageByCategory( wxAuiNotebook* aParent, const wxString& aCaption,
const wxBitmap& aIcon,
const CONTRIBUTORS& aContributors)
void DIALOG_ABOUT::createNotebookPageByCategory( wxNotebook* aParent, const wxString& aCaption,
IMAGES aIconIndex,
const CONTRIBUTORS& aContributors )
{
// The left justification between wxStaticText and wxHyperlinkCtrl is different so
// we must pad to make the alignment look decent.
@ -212,10 +224,12 @@ void DIALOG_ABOUT::createNotebookPageByCategory( wxAuiNotebook* aParent, const w
#if defined( __WXGTK__ )
padding += " ";
#endif
wxPanel* outerPanel = new wxPanel( aParent );
wxBoxSizer* outerSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL );
wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( aParent, wxID_ANY,
wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( outerPanel, wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxHSCROLL|wxVSCROLL );
@ -363,12 +377,16 @@ void DIALOG_ABOUT::createNotebookPageByCategory( wxAuiNotebook* aParent, const w
m_scrolledWindow1->SetSizer( bSizer );
m_scrolledWindow1->Layout();
bSizer->Fit( m_scrolledWindow1 );
aParent->AddPage( m_scrolledWindow1, aCaption, false, aIcon );
outerSizer->Add( m_scrolledWindow1, 1, wxEXPAND, 0 );
outerPanel->SetSizer( outerSizer );
aParent->AddPage( outerPanel, aCaption, false, static_cast<int>( aIconIndex ) );
}
void DIALOG_ABOUT::createNotebookHtmlPage( wxAuiNotebook* aParent, const wxString& aCaption,
const wxBitmap& aIcon, const wxString& html,
void DIALOG_ABOUT::createNotebookHtmlPage( wxNotebook* aParent, const wxString& aCaption,
IMAGES aIconIndex, const wxString& html,
bool aSelection )
{
wxPanel* panel = new wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
@ -381,9 +399,13 @@ void DIALOG_ABOUT::createNotebookHtmlPage( wxAuiNotebook* aParent, const wxStrin
// to have a unique look background color for HTML pages is set to the default as it is
// used for all the other widgets
wxString htmlColor = ( this->GetBackgroundColour() ).GetAsString( wxC2S_HTML_SYNTAX );
wxString textColor = GetForegroundColour().GetAsString( wxC2S_HTML_SYNTAX );
wxString linkColor =
wxSystemSettings::GetColour( wxSYS_COLOUR_HOTLIGHT ).GetAsString( wxC2S_HTML_SYNTAX );
// beginning of HTML structure
htmlPage.Append( wxT( "<html><body bgcolor='" ) + htmlColor + wxT( "'>" ) );
htmlPage.Append( wxString::Format( wxT( "<html><body bgcolor='%s' text='%s' link='%s'>" ),
htmlColor, textColor, linkColor ) );
htmlPage.Append( htmlContent );
@ -407,11 +429,10 @@ void DIALOG_ABOUT::createNotebookHtmlPage( wxAuiNotebook* aParent, const wxStrin
wxHtmlLinkEventHandler( DIALOG_ABOUT::onHtmlLinkClicked ), NULL, this );
// no additional space around the HTML window as it is also the case by the other notebook pages
bSizer->Add( htmlWindow, 1, wxALL|wxEXPAND, 0 );
bSizer->Add( htmlWindow, 1, wxEXPAND, 0 );
panel->SetSizer( bSizer );
panel->Layout();
bSizer->Fit( panel );
aParent->AddPage( panel, aCaption, false, aIcon );
aParent->AddPage( panel, aCaption, false, static_cast<int>( aIconIndex ) );
}
@ -470,3 +491,15 @@ void DIALOG_ABOUT::onReportBug( wxCommandEvent& event )
if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
mgr->RunAction( "common.SuiteControl.reportBug", true );
}
void DIALOG_ABOUT::OnNotebookPageChanged( wxNotebookEvent& aEvent )
{
// Work around wxMac issue where the notebook pages are blank
#ifdef __WXMAC__
int page = aEvent.GetSelection();
if( page >= 0 )
m_notebook->ChangeSelection( static_cast<unsigned>( page ) );
#endif
}

View File

@ -33,6 +33,19 @@
#include "aboutinfo.h"
#include "dialog_about_base.h"
// Used for the notebook image list
enum class IMAGES {
INFORMATION,
VERSION,
DEVELOPERS,
DOCWRITERS,
LIBRARIANS,
ARTISTS,
TRANSLATORS,
PACKAGERS,
LICENSE
};
/**
* About dialog to show application specific information.
* Needs a <code>ABOUT_APP_INFO</code> object that contains the data to be displayed.
@ -40,17 +53,7 @@
class DIALOG_ABOUT : public DIALOG_ABOUT_BASE
{
private:
// Icons for the various tabs of wxAuiNotebook
wxBitmap m_picInformation;
wxBitmap m_picVersion;
wxBitmap m_picDevelopers;
wxBitmap m_picDocWriters;
wxBitmap m_picLibrarians;
wxBitmap m_picArtists;
wxBitmap m_picTranslators;
wxBitmap m_picPackagers;
wxBitmap m_picLicense;
wxImageList* m_images;
wxString m_titleName;
ABOUT_APP_INFO& m_info;
@ -59,9 +62,10 @@ public:
DIALOG_ABOUT( EDA_BASE_FRAME* aParent, ABOUT_APP_INFO& aAppInfo );
~DIALOG_ABOUT();
private:
void initDialog();
protected:
void OnNotebookPageChanged( wxNotebookEvent& aEvent ) override;
private:
void onHtmlLinkClicked( wxHtmlLinkEvent& event );
void onCopyVersionInfo( wxCommandEvent& event ) override;
@ -71,17 +75,17 @@ private:
// Notebook pages
wxFlexGridSizer* createFlexGridSizer();
void createNotebooks();
void createNotebookPage( wxAuiNotebook* aParent,
void createNotebookPage( wxNotebook* aParent,
const wxString& aCaption,
const wxBitmap& aIcon,
IMAGES aIconIndex,
const CONTRIBUTORS& aContributors );
void createNotebookPageByCategory( wxAuiNotebook* aParent,
void createNotebookPageByCategory( wxNotebook* aParent,
const wxString& aCaption,
const wxBitmap& aIcon,
IMAGES aIconIndex,
const CONTRIBUTORS& aContributors );
void createNotebookHtmlPage( wxAuiNotebook* aParent,
void createNotebookHtmlPage( wxNotebook* aParent,
const wxString& aCaption,
const wxBitmap& aIcon,
IMAGES aIconIndex,
const wxString& aHtmlMessage,
bool aSelection = false );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -77,11 +77,11 @@ DIALOG_ABOUT_BASE::DIALOG_ABOUT_BASE( wxWindow* parent, wxWindowID id, const wxS
bSizerMain->Add( bSizerTitle, 0, wxEXPAND, 5 );
m_auiNotebook = new wxAuiNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_SCROLL_BUTTONS );
m_auiNotebook->SetMinSize( wxSize( 750,350 ) );
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_notebook->SetMinSize( wxSize( 750,350 ) );
bSizerMain->Add( m_auiNotebook, 2, wxALL|wxEXPAND, 5 );
bSizerMain->Add( m_notebook, 2, wxEXPAND | wxALL, 5 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxHORIZONTAL );
@ -101,6 +101,7 @@ DIALOG_ABOUT_BASE::DIALOG_ABOUT_BASE( wxWindow* parent, wxWindowID id, const wxS
// Connect Events
m_btCopyVersionInfo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ABOUT_BASE::onCopyVersionInfo ), NULL, this );
m_btReportBug->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ABOUT_BASE::onReportBug ), NULL, this );
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_ABOUT_BASE::OnNotebookPageChanged ), NULL, this );
}
DIALOG_ABOUT_BASE::~DIALOG_ABOUT_BASE()
@ -108,5 +109,6 @@ DIALOG_ABOUT_BASE::~DIALOG_ABOUT_BASE()
// Disconnect Events
m_btCopyVersionInfo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ABOUT_BASE::onCopyVersionInfo ), NULL, this );
m_btReportBug->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ABOUT_BASE::onReportBug ), NULL, this );
m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_ABOUT_BASE::OnNotebookPageChanged ), NULL, this );
}

View File

@ -14,7 +14,6 @@
<property name="file">dialog_about_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">MyProject</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -581,11 +579,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">2</property>
<object class="wxAuiNotebook" expanded="0">
<object class="wxNotebook" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -596,6 +594,7 @@
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmapsize"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
@ -620,7 +619,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size">750,350</property>
<property name="moveable">1</property>
<property name="name">m_auiNotebook</property>
<property name="name">m_notebook</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -630,15 +629,14 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxAUI_NB_SCROLL_BUTTONS</property>
<property name="subclass"></property>
<property name="tab_ctrl_height">-1</property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="uniform_bitmap_size"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnNotebookPageChanged">OnNotebookPageChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -22,7 +22,7 @@
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/aui/auibook.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -42,12 +42,13 @@ class DIALOG_ABOUT_BASE : public wxDialog
wxStaticText* m_staticTextLibVersion;
wxButton* m_btCopyVersionInfo;
wxButton* m_btReportBug;
wxAuiNotebook* m_auiNotebook;
wxNotebook* m_notebook;
wxButton* m_btOk;
// Virtual event handlers, overide them in your derived class
virtual void onCopyVersionInfo( wxCommandEvent& event ) { event.Skip(); }
virtual void onReportBug( wxCommandEvent& event ) { event.Skip(); }
virtual void OnNotebookPageChanged( wxNotebookEvent& event ) { event.Skip(); }
public: