Skip to content

Commit

Permalink
#5364: connect 'Override light colour' to registry key
Browse files Browse the repository at this point in the history
Checkbox initialised based on a new registry key and saves its value when
toggled.
  • Loading branch information
Matthew Mott committed Dec 18, 2020
1 parent 597347e commit 7894a81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
35 changes: 28 additions & 7 deletions radiant/uimanager/colourscheme/ColourSchemeEditor.cpp
Expand Up @@ -9,6 +9,7 @@
#include "wxutil/dialog/Dialog.h"
#include "wxutil/dialog/MessageBox.h"
#include "wxutil/TreeView.h"
#include "registry/registry.h"

#include <wx/panel.h>
#include <wx/sizer.h>
Expand All @@ -22,7 +23,9 @@ namespace ui

namespace
{
const char* const EDITOR_WINDOW_TITLE = N_("Edit Colour Schemes");
const char* const EDITOR_WINDOW_TITLE = N_("Edit Colour Schemes");

constexpr const char* RKEY_OVERRIDE_LIGHTCOL = "user/ui/colour/overrideLightColour";
}

ColourSchemeEditor::ColourSchemeEditor() :
Expand Down Expand Up @@ -72,6 +75,29 @@ wxBoxSizer* ColourSchemeEditor::constructListButtons()
return buttonBox;
}

void ColourSchemeEditor::addOptionsPanel(wxBoxSizer& vbox)
{
wxStaticLine* sep = new wxStaticLine(this);
vbox.Add(sep, 0, wxEXPAND | wxTOP, 6);

// Override light colour checkbox
wxCheckBox* overrideLightsCB = new wxCheckBox(
this, wxID_ANY, _("Override light volume colour")
);
overrideLightsCB->SetValue(
registry::getValue(RKEY_OVERRIDE_LIGHTCOL, false)
);
overrideLightsCB->Bind(
wxEVT_CHECKBOX,
[this](wxCommandEvent& ev)
{
registry::setValue(RKEY_OVERRIDE_LIGHTCOL, ev.IsChecked());
}
);

vbox.Add(overrideLightsCB, 0, wxEXPAND | wxTOP, 6);
}

void ColourSchemeEditor::constructWindow()
{
wxBoxSizer* mainHBox = new wxBoxSizer(wxHORIZONTAL);
Expand Down Expand Up @@ -103,12 +129,7 @@ void ColourSchemeEditor::constructWindow()
leftVBox->Add(constructListButtons(), 0, wxEXPAND, 6);

// Options panel below the copy/delete buttons
wxStaticLine* sep = new wxStaticLine(this);
leftVBox->Add(sep, 0, wxEXPAND | wxTOP, 6);
wxCheckBox* overrideLightsCB = new wxCheckBox(
this, wxID_ANY, _("Override light volume colour")
);
leftVBox->Add(overrideLightsCB, 0, wxEXPAND | wxTOP, 6);
addOptionsPanel(*leftVBox);

// The Box containing the Colour, pack it into the right half of the hbox
_colourFrame = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxDOUBLE_BORDER);
Expand Down
1 change: 1 addition & 0 deletions radiant/uimanager/colourscheme/ColourSchemeEditor.h
Expand Up @@ -48,6 +48,7 @@ class ColourSchemeEditor :
void populateTree();
void constructWindow();
wxBoxSizer* constructListButtons();
void addOptionsPanel(wxBoxSizer& vbox);
wxSizer* constructColourSelector(colours::IColourItem& colour, const std::string& name);
void updateColourSelectors();

Expand Down

0 comments on commit 7894a81

Please sign in to comment.