Make modem properties collapsable and add theme colors

This commit is contained in:
Charles J. Cliffe 2016-07-27 19:56:43 -04:00
parent 0a80feece9
commit 91547475e5
3 changed files with 84 additions and 6 deletions

View File

@ -1003,6 +1003,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
waterfallSpeedMeter->Refresh();
spectrumAvgMeter->Refresh();
gainCanvas->setThemeColors();
modemProps->updateTheme();
}
switch (event.GetId()) {
@ -1498,6 +1499,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
modemProps->initProperties(demod->getModemArgs());
modemPropertiesUpdated.store(false);
demodTray->Layout();
modemProps->fitColumns();
#if ENABLE_DIGITAL_LAB
if (demod->getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)demod->getOutput();
@ -1510,6 +1512,18 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
#endif
}
if (modemProps->isCollapsed() && modemProps->GetMinWidth() > 22) {
modemProps->SetMinSize(wxSize(22,-1));
modemProps->SetMaxSize(wxSize(22,-1));
demodTray->Layout();
modemProps->fitColumns();
} else if (!modemProps->isCollapsed() && modemProps->GetMinWidth() < 200) {
modemProps->SetMinSize(wxSize(200,-1));
modemProps->SetMaxSize(wxSize(200,-1));
demodTray->Layout();
modemProps->fitColumns();
}
int peakHoldMode = peakHoldButton->getSelection();
if (peakHoldButton->modeChanged()) {
wxGetApp().getSpectrumProcessor()->setPeakHold(peakHoldMode == 1);

View File

@ -4,24 +4,62 @@
ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid,
const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, winid, pos, size, style, name) {
m_propertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE);
m_propertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE | wxPG_NO_INTERNAL_BORDER);
bSizer = new wxBoxSizer( wxVERTICAL );
bSizer->Add(m_propertyGrid, 1, wxEXPAND, 5);
bSizer->Add(m_propertyGrid, 1, wxEXPAND, 0);
this->SetSizer(bSizer);
m_propertyGrid->Connect( wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEventHandler( ModemProperties::OnCollapse ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEventHandler( ModemProperties::OnExpand ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( ModemProperties::OnChange ), NULL, this );
this->Connect( wxEVT_SHOW, wxShowEventHandler( ModemProperties::OnShow ), NULL, this );
this->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseEnter ), NULL, this);
this->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseLeave ), NULL, this);
updateTheme();
mouseInView = false;
collapsed = false;
}
void ModemProperties::OnShow(wxShowEvent & /* event */) {
updateTheme();
}
void ModemProperties::updateTheme() {
wxColour bgColor(
(unsigned char) (ThemeMgr::mgr.currentTheme->generalBackground.r * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->generalBackground.g * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->generalBackground.b * 255.0));
wxColour textColor(
(unsigned char) (ThemeMgr::mgr.currentTheme->text.r * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->text.g * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->text.b * 255.0));
wxColour btn(
(unsigned char) (ThemeMgr::mgr.currentTheme->button.r * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->button.g * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->button.b * 255.0));
wxColour btnHl(
(unsigned char) (ThemeMgr::mgr.currentTheme->buttonHighlight.r * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->buttonHighlight.g * 255.0),
(unsigned char) (ThemeMgr::mgr.currentTheme->buttonHighlight.b * 255.0));
m_propertyGrid->SetEmptySpaceColour(bgColor);
m_propertyGrid->SetCellBackgroundColour(bgColor);
m_propertyGrid->SetCellTextColour(textColor);
m_propertyGrid->SetSelectionTextColour(bgColor);
m_propertyGrid->SetSelectionBackgroundColour(btnHl);
m_propertyGrid->SetCaptionTextColour(bgColor);
m_propertyGrid->SetCaptionBackgroundColour(btn);
m_propertyGrid->SetLineColour(btn);
}
ModemProperties::~ModemProperties() {
@ -51,6 +89,10 @@ void ModemProperties::initProperties(ModemArgInfoList newArgs) {
}
m_propertyGrid->FitColumns();
if (collapsed) {
m_propertyGrid->CollapseAll();
}
}
wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg) {
@ -166,6 +208,14 @@ void ModemProperties::OnChange(wxPropertyGridEvent &event) {
}
}
void ModemProperties::OnCollapse(wxPropertyGridEvent &event) {
collapsed = true;
}
void ModemProperties::OnExpand(wxPropertyGridEvent &event) {
collapsed = false;
}
void ModemProperties::OnMouseEnter(wxMouseEvent & /* event */) {
mouseInView = true;
}
@ -177,3 +227,11 @@ void ModemProperties::OnMouseLeave(wxMouseEvent & /* event */) {
bool ModemProperties::isMouseInView() {
return mouseInView || (m_propertyGrid && m_propertyGrid->IsEditorFocused());
}
bool ModemProperties::isCollapsed() {
return collapsed;
}
void ModemProperties::fitColumns() {
m_propertyGrid->FitColumns();
}

View File

@ -21,12 +21,18 @@ public:
void initProperties(ModemArgInfoList newArgs);
bool isMouseInView();
bool isCollapsed();
void fitColumns();
void updateTheme();
private:
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg);
std::string readProperty(std::string);
void OnChange(wxPropertyGridEvent &event);
void OnShow(wxShowEvent &event);
void OnCollapse(wxPropertyGridEvent &event);
void OnExpand(wxPropertyGridEvent &event);
void OnMouseEnter(wxMouseEvent &event);
void OnMouseLeave(wxMouseEvent &event);
@ -35,5 +41,5 @@ private:
wxPropertyGrid* m_propertyGrid;
ModemArgInfoList args;
std::map<std::string, wxPGProperty *> props;
bool mouseInView;
bool mouseInView, collapsed;
};