diff --git a/src/gui/build.mk b/src/gui/build.mk index 855ffa34..f949f017 100644 --- a/src/gui/build.mk +++ b/src/gui/build.mk @@ -8,6 +8,7 @@ FLUXENGINE_GUI_SRCS = \ src/gui/fileviewerwindow.cc \ src/gui/fluxviewercontrol.cc \ src/gui/fluxviewerwindow.cc \ + src/gui/iconbutton.cc \ src/gui/idlepanel.cc \ src/gui/imagerpanel.cc \ src/gui/jobqueue.cc \ diff --git a/src/gui/iconbutton.cc b/src/gui/iconbutton.cc new file mode 100644 index 00000000..9d419193 --- /dev/null +++ b/src/gui/iconbutton.cc @@ -0,0 +1,54 @@ +#include "lib/globals.h" +#include "gui.h" +#include "iconbutton.h" +#include + +IconButton::IconButton(wxWindow* parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name): + wxPanel(parent, id, pos, size, style, name) +{ + _sizer = new wxFlexGridSizer(1, 0, 0); + SetSizer(_sizer); + + _bitmap = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap); + _sizer->Add(_bitmap, 0, wxALL | wxEXPAND, 0, nullptr); + + _text = new wxStaticText(this, + wxID_ANY, + "", + wxDefaultPosition, + wxDefaultSize, + wxALIGN_CENTRE_HORIZONTAL); + _sizer->Add(_text, 0, wxALL | wxEXPAND, 0, nullptr); + + _text->SetFont(_text->GetFont().MakeSmaller().MakeSmaller().MakeSmaller()); + + Bind(wxEVT_LEFT_DOWN, &IconButton::OnMouseClick, this); + _bitmap->Bind(wxEVT_LEFT_DOWN, &IconButton::OnMouseClick, this); + _text->Bind(wxEVT_LEFT_DOWN, &IconButton::OnMouseClick, this); +} + +void IconButton::SetSelected(bool selected) +{ + _selected = selected; + wxColor bg = wxSystemSettings::GetColour( + _selected ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_WINDOW); + SetBackgroundColour(bg); +} + +void IconButton::OnMouseClick(wxMouseEvent&) +{ + auto* event = new wxCommandEvent(wxEVT_BUTTON, 0); + wxQueueEvent(this, event); +} + +void IconButton::SetBitmapAndLabel( + const wxBitmap bitmap, const std::string text) +{ + _bitmap->SetBitmap(bitmap); + _text->SetLabel(text); +} diff --git a/src/gui/iconbutton.h b/src/gui/iconbutton.h new file mode 100644 index 00000000..ccd03fc6 --- /dev/null +++ b/src/gui/iconbutton.h @@ -0,0 +1,26 @@ +#pragma once + +class wxToggleButton; + +class IconButton : public wxPanel +{ +public: + IconButton(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL, + const wxString& name = wxPanelNameStr); + + void SetBitmapAndLabel(const wxBitmap bitmap, const std::string text); + void SetSelected(bool selected); + +private: + void OnMouseClick(wxMouseEvent& e); + +private: + wxFlexGridSizer* _sizer; + wxStaticBitmap* _bitmap; + wxStaticText* _text; + bool _selected; +}; diff --git a/src/gui/idlepanel.cc b/src/gui/idlepanel.cc index 36562bb6..d0d41cc2 100644 --- a/src/gui/idlepanel.cc +++ b/src/gui/idlepanel.cc @@ -11,6 +11,7 @@ #include "lib/imagewriter/imagewriter.h" #include "layout.h" #include "texteditorwindow.h" +#include "iconbutton.h" #include #include #include @@ -91,17 +92,12 @@ public: parent->AddPage(this, "idle"); - auto* sourceList = sourceListBook->GetListView(); - sourceList->SetFont( - sourceList->GetFont().MakeSmaller().MakeSmaller().MakeSmaller()); - _imageList.Add( createBitmap(extras_hardware_png, sizeof(extras_hardware_png))); _imageList.Add( createBitmap(extras_fluxfile_png, sizeof(extras_fluxfile_png))); _imageList.Add( createBitmap(extras_imagefile_png, sizeof(extras_imagefile_png))); - sourceListBook->SetImageList(&_imageList); UpdateSources(); } @@ -361,7 +357,6 @@ private: /* Triggers SaveConfig */ _dontSaveConfig = false; - wxCommandEvent dummyEvent; } void SaveConfig() @@ -408,21 +403,25 @@ private: void UpdateSources() { - sourceListBook->DeleteAllPages(); + sourceBook->DeleteAllPages(); + sourceIconPanel->DestroyChildren(); + int page = 0; for (auto& device : _devices) { for (int drive = 0; drive <= 1; drive++) { - auto* panel = new HardwareSourcePanelGen(sourceListBook); - sourceListBook->AddPage(panel, - fmt::format("{}\ndrive:{}", device->serial, drive), - false, - ICON_HARDWARE); + auto* panel = new HardwareSourcePanelGen(sourceBook); + sourceBook->AddPage(panel, ""); - panel->Bind(PAGE_SELECTED_EVENT, - [=](wxCommandEvent& e) + auto* button = AddIcon(ICON_HARDWARE, + fmt::format( + "{}\ndrive:{}", device->serial.substr(0, 10), drive)); + button->Bind(wxEVT_BUTTON, + [=](auto& e) { + SwitchToPage(page); + _selectedSource = SELECTEDSOURCE_REAL; _selectedDevice = device->serial; _selectedDrive = drive; @@ -447,16 +446,21 @@ private: panel->fortyTrackDriveToggle->GetValue(); OnControlsChanged(e); }); + + page++; } } { - auto* panel = new FluxfileSourcePanelGen(sourceListBook); - sourceListBook->AddPage(panel, "Flux file", false, ICON_FLUXFILE); + auto* panel = new FluxfileSourcePanelGen(sourceBook); + sourceBook->AddPage(panel, ""); - panel->Bind(PAGE_SELECTED_EVENT, - [=](wxCommandEvent& e) + auto* button = AddIcon(ICON_FLUXFILE, "Flux file"); + button->Bind(wxEVT_BUTTON, + [=](auto& e) { + SwitchToPage(page); + _selectedSource = SELECTEDSOURCE_FLUX; OnControlsChanged(e); }); @@ -468,15 +472,20 @@ private: _selectedFluxfilename = e.GetPath(); OnControlsChanged(e); }); + + page++; } { - auto* panel = new ImagefileSourcePanelGen(sourceListBook); - sourceListBook->AddPage(panel, "Disk image", false, ICON_IMAGEFILE); + auto* panel = new ImagefileSourcePanelGen(sourceBook); + sourceBook->AddPage(panel, ""); - panel->Bind(PAGE_SELECTED_EVENT, - [=](wxCommandEvent& e) + auto* button = AddIcon(ICON_IMAGEFILE, "Disk image"); + button->Bind(wxEVT_BUTTON, + [=](auto& e) { + SwitchToPage(page); + _selectedSource = SELECTEDSOURCE_IMAGE; OnControlsChanged(e); }); @@ -488,19 +497,34 @@ private: _selectedImagefilename = e.GetPath(); OnControlsChanged(e); }); + + page++; } - sourceListBook->Fit(); - sourceListBook->Layout(); + Fit(); + Layout(); } - void OnSourceListPageChanged(wxBookCtrlEvent& e) + IconButton* AddIcon(int bitmapIndex, const std::string text) { - auto* page = sourceListBook->GetPage(e.GetSelection()); - auto* event = new wxCommandEvent(PAGE_SELECTED_EVENT, 0); - wxQueueEvent(page, event); + auto* button = new IconButton(sourceIconPanel, wxID_ANY); + button->SetBitmapAndLabel(_imageList.GetBitmap(bitmapIndex), text); + sourceIconPanel->GetSizer()->Add(button, 0, wxALL|wxEXPAND, 5, nullptr); + return button; } + void SwitchToPage(int page) { + int i = 0; + for (auto* window : sourceIconPanel->GetChildren()) { + IconButton* button = dynamic_cast(window); + if (button) + button->SetSelected(i == page); + i++; + } + + sourceBook->ChangeSelection(page); + } + void UpdateFormatOptions() { assert(!wxGetApp().IsWorkerThreadRunning()); @@ -609,7 +633,7 @@ private: formatOptionsContainer->SetSizerAndFit(sizer); Layout(); - SafeFit(); + SafeFit(); } } diff --git a/src/gui/layout.cpp b/src/gui/layout.cpp index 9b8a572f..5abecd86 100644 --- a/src/gui/layout.cpp +++ b/src/gui/layout.cpp @@ -515,15 +515,29 @@ IdlePanelGen::IdlePanelGen( wxWindow* parent, wxWindowID id, const wxPoint& pos, wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Source / destination") ), wxVERTICAL ); - sourceListBook = new wxListbook( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT|wxLB_TOP|wxBORDER_THEME ); - wxSize sourceListBookImageSize = wxSize( 48,48 ); - int sourceListBookIndex = 0; - wxImageList* sourceListBookImages = new wxImageList( sourceListBookImageSize.GetWidth(), sourceListBookImageSize.GetHeight() ); - sourceListBook->AssignImageList( sourceListBookImages ); - wxBitmap sourceListBookBitmap; - wxImage sourceListBookImage; + wxFlexGridSizer* fgSizer12; + fgSizer12 = new wxFlexGridSizer( 0, 1, 0, 0 ); + fgSizer12->AddGrowableCol( 0 ); + fgSizer12->AddGrowableRow( 1 ); + fgSizer12->SetFlexibleDirection( wxBOTH ); + fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - sbSizer1->Add( sourceListBook, 1, wxALL|wxEXPAND, 5 ); + sourceIconPanel = new wxPanel( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxWrapSizer* wSizer3; + wSizer3 = new wxWrapSizer( wxHORIZONTAL, 0 ); + + + sourceIconPanel->SetSizer( wSizer3 ); + sourceIconPanel->Layout(); + wSizer3->Fit( sourceIconPanel ); + fgSizer12->Add( sourceIconPanel, 1, wxEXPAND | wxALL, 5 ); + + sourceBook = new wxSimplebook( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + fgSizer12->Add( sourceBook, 1, wxEXPAND | wxALL, 5 ); + + + sbSizer1->Add( fgSizer12, 1, wxEXPAND, 5 ); fgSizer8->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 ); @@ -619,8 +633,6 @@ IdlePanelGen::IdlePanelGen( wxWindow* parent, wxWindowID id, const wxPoint& pos, fgSizer8->Fit( this ); // Connect Events - sourceListBook->Connect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, wxListbookEventHandler( IdlePanelGen::OnSourceListPageChanged ), NULL, this ); - sourceListBook->Connect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, wxListbookEventHandler( IdlePanelGen::OnSourceListPageChanging ), NULL, this ); formatChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( IdlePanelGen::OnControlsChanged ), NULL, this ); customConfigurationButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IdlePanelGen::OnCustomConfigurationButton ), NULL, this ); readButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IdlePanelGen::OnReadButton ), NULL, this ); @@ -633,8 +645,6 @@ IdlePanelGen::IdlePanelGen( wxWindow* parent, wxWindowID id, const wxPoint& pos, IdlePanelGen::~IdlePanelGen() { // Disconnect Events - sourceListBook->Disconnect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, wxListbookEventHandler( IdlePanelGen::OnSourceListPageChanged ), NULL, this ); - sourceListBook->Disconnect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, wxListbookEventHandler( IdlePanelGen::OnSourceListPageChanging ), NULL, this ); formatChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( IdlePanelGen::OnControlsChanged ), NULL, this ); customConfigurationButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IdlePanelGen::OnCustomConfigurationButton ), NULL, this ); readButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IdlePanelGen::OnReadButton ), NULL, this ); @@ -988,6 +998,14 @@ HardwareSourcePanelGen::HardwareSourcePanelGen( wxWindow* parent, wxWindowID id, wxBoxSizer* bSizer3; bSizer3 = new wxBoxSizer( wxVERTICAL ); + m_staticText30 = new wxStaticText( this, wxID_ANY, wxT("Read from or write to real floppy disk:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText30->Wrap( -1 ); + bSizer3->Add( m_staticText30, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5 ); + + label = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + label->Wrap( -1 ); + bSizer3->Add( label, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5 ); + highDensityToggle = new wxCheckBox( this, wxID_ANY, wxT("This is a high density disk"), wxDefaultPosition, wxDefaultSize, 0 ); highDensityToggle->SetToolTip( wxT("If you are using a high density disk, select this.\nThis can be detected automatically for 3.5\"\ndisks but needs to be set manually for everything\nelse.") ); @@ -1011,6 +1029,10 @@ FluxfileSourcePanelGen::FluxfileSourcePanelGen( wxWindow* parent, wxWindowID id, wxBoxSizer* bSizer8; bSizer8 = new wxBoxSizer( wxVERTICAL ); + m_staticText28 = new wxStaticText( this, wxID_ANY, wxT("Read flux-level data from file:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText28->Wrap( -1 ); + bSizer8->Add( m_staticText28, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5 ); + fluxImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); fluxImagePicker->SetToolTip( wxT("Path to a .flux, .scp or other flux file.") ); @@ -1031,6 +1053,10 @@ ImagefileSourcePanelGen::ImagefileSourcePanelGen( wxWindow* parent, wxWindowID i wxBoxSizer* bSizer9; bSizer9 = new wxBoxSizer( wxVERTICAL ); + m_staticText29 = new wxStaticText( this, wxID_ANY, wxT("Read sector-level data from file:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText29->Wrap( -1 ); + bSizer9->Add( m_staticText29, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5 ); + diskImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); diskImagePicker->SetToolTip( wxT("The path to the disk image.") ); diff --git a/src/gui/layout.fbp b/src/gui/layout.fbp index e6826a61..d33e3493 100644 --- a/src/gui/layout.fbp +++ b/src/gui/layout.fbp @@ -2857,64 +2857,143 @@ none 5 - wxALL|wxEXPAND + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - 48,48 - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + + 1 + wxBOTH + 0 + 1 + 0 - 1 - sourceListBook - 1 - - - protected - 1 - - Resizable - 1 - - wxLB_DEFAULT|wxLB_TOP - ; ; forward_declare - 0 - - - - wxBORDER_THEME - OnSourceListPageChanged - OnSourceListPageChanging + fgSizer12 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + sourceIconPanel + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + + wSizer3 + wxHORIZONTAL + none + + + + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + sourceBook + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + @@ -3672,11 +3751,11 @@ - + 5 wxEXPAND 1 - + 2 0 @@ -3684,11 +3763,11 @@ none 0 0 - + 5 wxEXPAND 1 - + 1 0 @@ -5824,6 +5903,130 @@ bSizer3 wxVERTICAL none + + 5 + wxALIGN_LEFT|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Read from or write to real floppy disk: + 0 + + 0 + + + 0 + + 1 + m_staticText30 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_LEFT|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + + 0 + + 1 + label + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL|wxEXPAND @@ -5985,6 +6188,68 @@ bSizer8 wxVERTICAL none + + 5 + wxALIGN_LEFT|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Read flux-level data from file: + 0 + + 0 + + + 0 + + 1 + m_staticText28 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL|wxEXPAND @@ -6082,6 +6347,68 @@ bSizer9 wxVERTICAL none + + 5 + wxALIGN_LEFT|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Read sector-level data from file: + 0 + + 0 + + + 0 + + 1 + m_staticText29 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL|wxEXPAND diff --git a/src/gui/layout.h b/src/gui/layout.h index aa10948d..fcc0f8fe 100644 --- a/src/gui/layout.h +++ b/src/gui/layout.h @@ -33,9 +33,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include @@ -312,7 +310,8 @@ class IdlePanelGen : public wxPanel protected: wxStaticBitmap* applicationBitmap; - wxListbook* sourceListBook; + wxPanel* sourceIconPanel; + wxSimplebook* sourceBook; wxChoice* formatChoice; wxButton* customConfigurationButton; wxPanel* formatOptionsContainer; @@ -323,8 +322,6 @@ class IdlePanelGen : public wxPanel wxButton* exploreButton; // Virtual event handlers, override them in your derived class - virtual void OnSourceListPageChanged( wxListbookEvent& event ) { event.Skip(); } - virtual void OnSourceListPageChanging( wxListbookEvent& event ) { event.Skip(); } virtual void OnControlsChanged( wxCommandEvent& event ) { event.Skip(); } virtual void OnCustomConfigurationButton( wxCommandEvent& event ) { event.Skip(); } virtual void OnReadButton( wxCommandEvent& event ) { event.Skip(); } @@ -494,6 +491,8 @@ class HardwareSourcePanelGen : public wxPanel private: protected: + wxStaticText* m_staticText30; + wxStaticText* label; public: wxCheckBox* highDensityToggle; @@ -513,6 +512,7 @@ class FluxfileSourcePanelGen : public wxPanel private: protected: + wxStaticText* m_staticText28; public: wxFilePickerCtrl* fluxImagePicker; @@ -531,6 +531,7 @@ class ImagefileSourcePanelGen : public wxPanel private: protected: + wxStaticText* m_staticText29; public: wxFilePickerCtrl* diskImagePicker;