From e73bec504e2cd5e99db44223d2f9a77176bfb2bb Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 3 Jan 2025 17:41:37 +0000 Subject: [PATCH] Separate Edit/Delete buttons for jobset outputs. --- kicad/dialogs/panel_jobs.cpp | 71 +++++++------ kicad/dialogs/panel_jobs_base.cpp | 46 +++++---- kicad/dialogs/panel_jobs_base.fbp | 163 ++++++++++++++++++++---------- kicad/dialogs/panel_jobs_base.h | 11 +- 4 files changed, 184 insertions(+), 107 deletions(-) diff --git a/kicad/dialogs/panel_jobs.cpp b/kicad/dialogs/panel_jobs.cpp index 12186782fd..336ec8f9bf 100644 --- a/kicad/dialogs/panel_jobs.cpp +++ b/kicad/dialogs/panel_jobs.cpp @@ -353,11 +353,10 @@ public: m_frame( aFrame ), m_panelParent( aPanelParent ) { - m_buttonOutputRun->SetBitmap( KiBitmapBundle( BITMAPS::sim_run ) ); - m_buttonOutputOptions->SetBitmap( KiBitmapBundle( BITMAPS::preference ) ); + m_buttonProperties->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) ); + m_buttonDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); - m_buttonOutputOptions->Connect( wxEVT_MENU, - wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this ); + Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this ); if( jobTypeInfos.contains( aOutput->m_type ) ) { @@ -372,8 +371,7 @@ public: ~PANEL_JOB_OUTPUT() { - m_buttonOutputOptions->Disconnect( - wxEVT_MENU, wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this ); + Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this ); } void UpdateStatus() @@ -398,11 +396,11 @@ public: m_statusBitmap->SetBitmap( wxNullBitmap ); } - m_buttonOutputRun->Enable( !m_jobsFile->GetJobsForOutput( m_output ).empty() ); + m_buttonGenerate->Enable( !m_jobsFile->GetJobsForOutput( m_output ).empty() ); } - virtual void OnOutputRunClick( wxCommandEvent& event ) override + virtual void OnGenerate( wxCommandEvent& event ) override { CallAfter( [this]() @@ -425,28 +423,44 @@ public: } ); } - virtual void OnLastStatusClick(wxMouseEvent& event) override + virtual void OnLastStatusClick( wxMouseEvent& aEvent ) override { DIALOG_OUTPUT_RUN_RESULTS dialog( m_frame, m_jobsFile, m_output ); dialog.ShowModal(); } - virtual void OnOutputOptionsClick( wxCommandEvent& event ) override + void OnRightDown( wxMouseEvent& aEvent ) override { wxMenu menu; - menu.Append( wxID_EDIT, _( "Edit..." ) ); - menu.Append( wxID_DELETE, _( "Delete" ) ); + menu.Append( wxID_EDIT, _( "Edit Output Options..." ) ); + menu.Append( wxID_DELETE, _( "Delete Output" ) ); - if( m_output->m_lastRunSuccess.has_value() ) - { - menu.AppendSeparator(); - menu.Append( wxID_VIEW_DETAILS, _( "View last run results..." ) ); - } + menu.AppendSeparator(); + menu.Append( wxID_VIEW_DETAILS, _( "View Last Run Results..." ) ); - m_buttonOutputOptions->PopupMenu( &menu ); + menu.Enable( wxID_VIEW_DETAILS, m_output->m_lastRunSuccess.has_value() ); + + PopupMenu( &menu ); } + void OnProperties( wxCommandEvent& aEvent ) override + { + DIALOG_JOB_OUTPUT dialog( m_frame, m_jobsFile, m_output ); + + if( dialog.ShowModal() == wxID_OK ) + { + m_textOutputType->SetLabel( m_output->GetDescription() ); + m_jobsFile->SetDirty(); + m_panelParent->UpdateTitle(); + } + } + + virtual void OnDelete( wxCommandEvent& aEvent ) override + { + m_panelParent->RemoveOutput( m_output ); + } + private: void onMenu( wxCommandEvent& aEvent ) { @@ -454,32 +468,31 @@ private: { case wxID_EDIT: { - DIALOG_JOB_OUTPUT dialog( m_frame, m_jobsFile, m_output ); - if( dialog.ShowModal() == wxID_OK ) - { - m_textOutputType->SetLabel( m_output->GetDescription() ); - m_jobsFile->SetDirty(); - m_panelParent->UpdateTitle(); - } + wxCommandEvent dummy; + OnProperties( dummy ); } break; case wxID_DELETE: - m_panelParent->RemoveOutput( m_output ); + { + wxCommandEvent dummy; + OnDelete( dummy ); + } break; case wxID_VIEW_DETAILS: { - DIALOG_OUTPUT_RUN_RESULTS dialog( m_frame, m_jobsFile, m_output ); - dialog.ShowModal(); + wxMouseEvent dummy; + OnLastStatusClick( dummy ); } - break; + break; default: wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) ); } } +private: JOBSET* m_jobsFile; JOBSET_OUTPUT* m_output; KICAD_MANAGER_FRAME* m_frame; diff --git a/kicad/dialogs/panel_jobs_base.cpp b/kicad/dialogs/panel_jobs_base.cpp index 11705fa832..f2aed35fe2 100644 --- a/kicad/dialogs/panel_jobs_base.cpp +++ b/kicad/dialogs/panel_jobs_base.cpp @@ -158,10 +158,10 @@ PANEL_JOB_OUTPUT_BASE::PANEL_JOB_OUTPUT_BASE( wxWindow* parent, wxWindowID id, c this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxHORIZONTAL ); + bSizerMain = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgSizer3; - fgSizer3 = new wxFlexGridSizer( 2, 4, 5, 5 ); + fgSizer3 = new wxFlexGridSizer( 1, 3, 5, 5 ); fgSizer3->AddGrowableCol( 1 ); fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -178,23 +178,23 @@ PANEL_JOB_OUTPUT_BASE::PANEL_JOB_OUTPUT_BASE( wxWindow* parent, wxWindowID id, c m_statusBitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); fgSizer3->Add( m_statusBitmap, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonOutputRun = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - fgSizer3->Add( m_buttonOutputRun, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerMain->Add( fgSizer3, 0, wxEXPAND|wxALL, 5 ); + + wxBoxSizer* bSizerButtons; + bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonProperties = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bSizerButtons->Add( m_buttonProperties, 0, wxALL, 5 ); + + m_buttonDelete = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bSizerButtons->Add( m_buttonDelete, 0, wxALL, 5 ); + + m_buttonGenerate = new wxButton( this, wxID_ANY, _("Generate"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButtons->Add( m_buttonGenerate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_buttonOutputOptions = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - fgSizer3->Add( m_buttonOutputOptions, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - bSizerMain->Add( fgSizer3, 1, wxALL, 5 ); + bSizerMain->Add( bSizerButtons, 0, wxEXPAND, 5 ); this->SetSizer( bSizerMain ); @@ -202,17 +202,21 @@ PANEL_JOB_OUTPUT_BASE::PANEL_JOB_OUTPUT_BASE( wxWindow* parent, wxWindowID id, c bSizerMain->Fit( this ); // Connect Events + this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PANEL_JOB_OUTPUT_BASE::OnRightDown ) ); m_statusBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_JOB_OUTPUT_BASE::OnLastStatusClick ), NULL, this ); - m_buttonOutputRun->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnOutputRunClick ), NULL, this ); - m_buttonOutputOptions->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnOutputOptionsClick ), NULL, this ); + m_buttonProperties->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnProperties ), NULL, this ); + m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnDelete ), NULL, this ); + m_buttonGenerate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnGenerate ), NULL, this ); } PANEL_JOB_OUTPUT_BASE::~PANEL_JOB_OUTPUT_BASE() { // Disconnect Events + this->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PANEL_JOB_OUTPUT_BASE::OnRightDown ) ); m_statusBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_JOB_OUTPUT_BASE::OnLastStatusClick ), NULL, this ); - m_buttonOutputRun->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnOutputRunClick ), NULL, this ); - m_buttonOutputOptions->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnOutputOptionsClick ), NULL, this ); + m_buttonProperties->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnProperties ), NULL, this ); + m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnDelete ), NULL, this ); + m_buttonGenerate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOB_OUTPUT_BASE::OnGenerate ), NULL, this ); } diff --git a/kicad/dialogs/panel_jobs_base.fbp b/kicad/dialogs/panel_jobs_base.fbp index a8d9771ad8..631cbcb8f5 100644 --- a/kicad/dialogs/panel_jobs_base.fbp +++ b/kicad/dialogs/panel_jobs_base.fbp @@ -855,7 +855,7 @@ - + 0 wxAUI_MGR_DEFAULT wxSYS_COLOUR_3DLIGHT @@ -879,17 +879,18 @@ wxBORDER_SIMPLE|wxTAB_TRAVERSAL - + OnRightDown + bSizerMain - wxHORIZONTAL + wxVERTICAL none - + 5 - wxALL - 1 - - 4 + wxEXPAND|wxALL + 0 + + 3 wxBOTH 1 @@ -898,7 +899,7 @@ fgSizer3 wxFLEX_GROWMODE_SPECIFIED none - 2 + 1 5 5 @@ -1081,11 +1082,22 @@ OnLastStatusClick - + + + + 5 + wxEXPAND + 0 + + + bSizerButtons + wxHORIZONTAL + none + 5 - wxALIGN_CENTER_VERTICAL + wxALL 0 - + 1 1 1 @@ -1120,7 +1132,7 @@ 0 0 wxID_ANY - Run + Edit Output Properties 0 @@ -1130,7 +1142,7 @@ 0 1 - m_buttonOutputRun + m_buttonProperties 1 @@ -1143,7 +1155,7 @@ 1 - + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 @@ -1153,44 +1165,14 @@ - OnOutputRunClick + OnProperties - + 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL + wxALL 0 - + 1 1 1 @@ -1225,7 +1207,7 @@ 0 0 wxID_ANY - Options + Delete Oputput 0 @@ -1235,7 +1217,7 @@ 0 1 - m_buttonOutputOptions + m_buttonDelete 1 @@ -1248,7 +1230,7 @@ 1 - + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 @@ -1258,7 +1240,82 @@ - OnOutputOptionsClick + OnDelete + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Generate + + 0 + + 0 + + + 0 + + 1 + m_buttonGenerate + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnGenerate diff --git a/kicad/dialogs/panel_jobs_base.h b/kicad/dialogs/panel_jobs_base.h index 241d786df2..ecc09ca192 100644 --- a/kicad/dialogs/panel_jobs_base.h +++ b/kicad/dialogs/panel_jobs_base.h @@ -91,13 +91,16 @@ class PANEL_JOB_OUTPUT_BASE : public wxPanel wxStaticBitmap* m_bitmapOutputType; wxStaticText* m_textOutputType; wxStaticBitmap* m_statusBitmap; - wxBitmapButton* m_buttonOutputRun; - wxBitmapButton* m_buttonOutputOptions; + STD_BITMAP_BUTTON* m_buttonProperties; + STD_BITMAP_BUTTON* m_buttonDelete; + wxButton* m_buttonGenerate; // Virtual event handlers, override them in your derived class + virtual void OnRightDown( wxMouseEvent& event ) { event.Skip(); } virtual void OnLastStatusClick( wxMouseEvent& event ) { event.Skip(); } - virtual void OnOutputRunClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOutputOptionsClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnProperties( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDelete( wxCommandEvent& event ) { event.Skip(); } + virtual void OnGenerate( wxCommandEvent& event ) { event.Skip(); } public: