From 9c7ff0598cd468c7ccd827eba0495fc1e3439983 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 14 Nov 2016 23:16:08 -0500 Subject: [PATCH] Layout tweaks, fixes --- src/forms/Bookmark/BookmarkPanel.cpp | 6 ++-- src/forms/Bookmark/BookmarkPanel.fbp | 10 +++--- src/forms/Bookmark/BookmarkView.cpp | 49 +++++++++++++--------------- src/forms/Bookmark/BookmarkView.h | 2 ++ 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/forms/Bookmark/BookmarkPanel.cpp b/src/forms/Bookmark/BookmarkPanel.cpp index 008ef47..6901fee 100644 --- a/src/forms/Bookmark/BookmarkPanel.cpp +++ b/src/forms/Bookmark/BookmarkPanel.cpp @@ -15,7 +15,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po bSizer1 = new wxBoxSizer( wxVERTICAL ); m_treeView = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_EDIT_LABELS|wxTR_HAS_VARIABLE_ROW_HEIGHT|wxTR_HIDE_ROOT|wxTR_SINGLE ); - bSizer1->Add( m_treeView, 5, wxEXPAND, 5 ); + bSizer1->Add( m_treeView, 1, wxEXPAND, 5 ); m_propPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxFlexGridSizer* fgPropSizer; @@ -59,7 +59,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po m_propPanel->SetSizer( fgPropSizer ); m_propPanel->Layout(); fgPropSizer->Fit( m_propPanel ); - bSizer1->Add( m_propPanel, 1, wxBOTTOM|wxEXPAND|wxTOP, 5 ); + bSizer1->Add( m_propPanel, 0, wxALL|wxBOTTOM|wxEXPAND|wxTOP, 5 ); m_buttonPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* m_buttonPanelSizer; @@ -69,7 +69,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po m_buttonPanel->SetSizer( m_buttonPanelSizer ); m_buttonPanel->Layout(); m_buttonPanelSizer->Fit( m_buttonPanel ); - bSizer1->Add( m_buttonPanel, 1, wxEXPAND, 5 ); + bSizer1->Add( m_buttonPanel, 0, wxALL|wxEXPAND, 5 ); this->SetSizer( bSizer1 ); diff --git a/src/forms/Bookmark/BookmarkPanel.fbp b/src/forms/Bookmark/BookmarkPanel.fbp index d0f3adc..93305d0 100644 --- a/src/forms/Bookmark/BookmarkPanel.fbp +++ b/src/forms/Bookmark/BookmarkPanel.fbp @@ -86,7 +86,7 @@ 5 wxEXPAND - 5 + 1 1 1 @@ -187,8 +187,8 @@ 5 - wxBOTTOM|wxEXPAND|wxTOP - 1 + wxALL|wxBOTTOM|wxEXPAND|wxTOP + 0 1 1 @@ -952,8 +952,8 @@ 5 - wxEXPAND - 1 + wxALL|wxEXPAND + 0 1 1 diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index 9bf1f4b..7a915ef 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -21,10 +21,8 @@ BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, dragItemId = nullptr; hideProps(); - m_propPanel->Hide(); m_updateTimer.Start(500); -// m_treeView->SetDropEffectAboveItem(); mouseInView.store(false); } @@ -52,7 +50,7 @@ void BookmarkView::updateTheme() { wxColour btn(ThemeMgr::mgr.currentTheme->button); wxColour btnHl(ThemeMgr::mgr.currentTheme->buttonHighlight); - this->SetBackgroundColour(ThemeMgr::mgr.currentTheme->generalBackground * 4.0); + SetBackgroundColour(bgColor); m_treeView->SetBackgroundColour(bgColor); m_treeView->SetForegroundColour(textColor); @@ -69,9 +67,6 @@ void BookmarkView::updateTheme() { m_modulationLabel->SetForegroundColour(textColor); m_buttonPanel->SetBackgroundColour(bgColor); - for (auto p : m_buttonPanel->GetChildren()) { - p->SetBackgroundColour(bgColor); - } } @@ -266,21 +261,32 @@ void BookmarkView::hideProps() { m_labelText->Hide(); m_labelLabel->Hide(); + m_propPanel->Hide(); m_buttonPanel->Hide(); } +void BookmarkView::showProps() { + m_propPanel->Show(); + m_propPanel->GetSizer()->Layout(); +} + + void BookmarkView::clearButtons() { - m_buttonPanel->DestroyChildren(); m_buttonPanel->Hide(); + m_buttonPanel->DestroyChildren(); } void BookmarkView::showButtons() { m_buttonPanel->Show(); -// m_buttonPanel->Layout(); m_buttonPanel->GetSizer()->Layout(); } +void BookmarkView::refreshLayout() { + GetSizer()->Layout(); + Update(); +} + wxButton *BookmarkView::makeButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler) { wxButton *nButton = new wxButton( m_buttonPanel, wxID_ANY, labelVal); @@ -325,9 +331,9 @@ void BookmarkView::activeSelection(DemodulatorInstance *dsel) { addButton(m_buttonPanel, "Bookmark Active", wxCommandEventHandler( BookmarkView::onBookmarkActive )); addButton(m_buttonPanel, "Remove Active", wxCommandEventHandler( BookmarkView::onRemoveActive )); + showProps(); showButtons(); - - this->Layout(); + refreshLayout(); } @@ -373,9 +379,9 @@ void BookmarkView::bookmarkSelection(BookmarkEntry *bmSel) { addButton(m_buttonPanel, "Activate Bookmark", wxCommandEventHandler( BookmarkView::onActivateBookmark )); addButton(m_buttonPanel, "Remove Bookmark", wxCommandEventHandler( BookmarkView::onRemoveBookmark )); + showProps(); showButtons(); - - this->Layout(); + refreshLayout(); } @@ -408,9 +414,9 @@ void BookmarkView::recentSelection(BookmarkEntry *bmSel) { addButton(m_buttonPanel, "Activate Recent", wxCommandEventHandler( BookmarkView::onActivateRecent )); addButton(m_buttonPanel, "Bookmark Recent", wxCommandEventHandler( BookmarkView::onBookmarkRecent )); + showProps(); showButtons(); - - this->Layout(); + refreshLayout(); } void BookmarkView::groupSelection(std::string groupName) { @@ -427,8 +433,7 @@ void BookmarkView::groupSelection(std::string groupName) { addButton(m_buttonPanel, "Rename Group", wxCommandEventHandler( BookmarkView::onRenameGroup )); showButtons(); - - this->Layout(); + refreshLayout(); } @@ -438,26 +443,22 @@ void BookmarkView::bookmarkBranchSelection() { bookmarkSel = nullptr; clearButtons(); - hideProps(); addButton(m_buttonPanel, "Add Group", wxCommandEventHandler( BookmarkView::onAddGroup )); showButtons(); - - this->Layout(); + refreshLayout(); } void BookmarkView::recentBranchSelection() { - m_propPanel->Hide(); hideProps(); this->Layout(); } void BookmarkView::activeBranchSelection() { - m_propPanel->Hide(); hideProps(); this->Layout(); } @@ -476,7 +477,6 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) { } else if (itm == recentBranch) { recentBranchSelection(); } else { - m_propPanel->Hide(); hideProps(); this->Layout(); } @@ -485,20 +485,15 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) { } if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { - m_propPanel->Show(); activeSelection(tvi->demod); wxGetApp().getDemodMgr().setActiveDemodulator(tvi->demod, false); } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { - m_propPanel->Show(); recentSelection(tvi->bookmarkEnt); } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { - m_propPanel->Show(); bookmarkSelection(tvi->bookmarkEnt); } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) { - m_propPanel->Show(); groupSelection(tvi->groupName); } else { - m_propPanel->Hide(); hideProps(); this->Layout(); } diff --git a/src/forms/Bookmark/BookmarkView.h b/src/forms/Bookmark/BookmarkView.h index 9d4013f..53c33ec 100644 --- a/src/forms/Bookmark/BookmarkView.h +++ b/src/forms/Bookmark/BookmarkView.h @@ -50,6 +50,7 @@ public: protected: void hideProps(); + void showProps(); void onUpdateTimer( wxTimerEvent& event ); void doUpdateActiveList(); @@ -75,6 +76,7 @@ protected: void clearButtons(); void showButtons(); + void refreshLayout(); wxButton *makeButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler); wxButton *addButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);