Skip to content

Commit

Permalink
SurfaceInspector scale link buttons constructed in separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mott committed Nov 3, 2021
1 parent 1641dc3 commit 3433719
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
51 changes: 28 additions & 23 deletions radiant/ui/surfaceinspector/SurfaceInspector.cpp
Expand Up @@ -333,6 +333,31 @@ wxBoxSizer* SurfaceInspector::createFitTextureRow()
return fitTextureHBox;
}

void SurfaceInspector::createScaleLinkButtons(wxFlexGridSizer& table)
{
auto scaleLinkSizer = new wxBoxSizer(wxHORIZONTAL);

_useHorizScale = new wxBitmapButton(this, wxID_ANY, wxutil::GetLocalBitmap("arrow_down_blue.png"));
_useHorizScale->SetToolTip(_("Assign horizontal scale to vertical scale"));
scaleLinkSizer->Add(_useHorizScale, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 24);

_useVertScale = new wxBitmapButton(this, wxID_ANY, wxutil::GetLocalBitmap("arrow_up_blue.png"));
_useVertScale->SetToolTip(_("Assign vertical scale to horizontal scale"));
scaleLinkSizer->Add(_useVertScale, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);

_useHorizScale->Bind(wxEVT_BUTTON, [&](wxCommandEvent& ev) { onHarmoniseScale(true); });
_useVertScale->Bind(wxEVT_BUTTON, [&](wxCommandEvent& ev) { onHarmoniseScale(false); });

auto linkToggle = new wxBitmapToggleButton(this, wxID_ANY, wxutil::GetLocalBitmap("link_inactive.png"));
linkToggle->SetBitmapSelected(wxutil::GetLocalBitmap("link_active.png"));
linkToggle->SetToolTip(_("Linked Scaling: when active, scale changes will affect horizontal and vertical values proportionally"));
linkToggle->SetMaxClientSize(wxSize(35, -1));
_scaleLinkToggle = linkToggle;
scaleLinkSizer->Add(_scaleLinkToggle, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 24);

table.Add(scaleLinkSizer, 1, wxEXPAND);
}

void SurfaceInspector::populateWindow()
{
wxBoxSizer* dialogVBox = new wxBoxSizer(wxVERTICAL);
Expand Down Expand Up @@ -375,36 +400,16 @@ void SurfaceInspector::populateWindow()
dialogVBox->Add(topLabel, 0, wxEXPAND | wxBOTTOM, 6);
dialogVBox->Add(table, 0, wxEXPAND | wxLEFT, 18); // 18 pixels left indentation

// Populate the table with the according widgets
// Initial parameter editing rows
_manipulators[HSHIFT] = createManipulatorRow(this, _(LABEL_HSHIFT), table, "arrow_left_blue.png", "arrow_right_blue.png");
_manipulators[VSHIFT] = createManipulatorRow(this, _(LABEL_VSHIFT), table, "arrow_down_blue.png", "arrow_up_blue.png");
_manipulators[HSCALE] = createManipulatorRow(this, _(LABEL_HSCALE), table, "hscale_down.png", "hscale_up.png");

// Scale link widgets
table->AddSpacer(1); // instead of a label
createScaleLinkButtons(*table);

auto scaleLinkSizer = new wxBoxSizer(wxHORIZONTAL);

_useHorizScale = new wxBitmapButton(this, wxID_ANY, wxutil::GetLocalBitmap("arrow_down_blue.png"));
_useHorizScale->SetToolTip(_("Assign horizontal scale to vertical scale"));
scaleLinkSizer->Add(_useHorizScale, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 24);

_useVertScale = new wxBitmapButton(this, wxID_ANY, wxutil::GetLocalBitmap("arrow_up_blue.png"));
_useVertScale->SetToolTip(_("Assign vertical scale to horizontal scale"));
scaleLinkSizer->Add(_useVertScale, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);

_useHorizScale->Bind(wxEVT_BUTTON, [&](wxCommandEvent& ev) { onHarmoniseScale(true); });
_useVertScale->Bind(wxEVT_BUTTON, [&](wxCommandEvent& ev) { onHarmoniseScale(false); });

auto linkToggle = new wxBitmapToggleButton(this, wxID_ANY, wxutil::GetLocalBitmap("link_inactive.png"));
linkToggle->SetBitmapSelected(wxutil::GetLocalBitmap("link_active.png"));
linkToggle->SetToolTip(_("Linked Scaling: when active, scale changes will affect horizontal and vertical values proportionally"));
linkToggle->SetMaxClientSize(wxSize(35, -1));
_scaleLinkToggle = linkToggle;
scaleLinkSizer->Add(_scaleLinkToggle, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 24);

table->Add(scaleLinkSizer, 1, wxEXPAND);

// Remaining parameter rows
_manipulators[VSCALE] = createManipulatorRow(this, _(LABEL_VSCALE), table, "vscale_down.png", "vscale_up.png");
_manipulators[ROTATION] = createManipulatorRow(this, _(LABEL_ROTATION), table, "rotate_cw.png", "rotate_ccw.png");

Expand Down
3 changes: 2 additions & 1 deletion radiant/ui/surfaceinspector/SurfaceInspector.h
Expand Up @@ -145,12 +145,13 @@ class SurfaceInspector :
* @returns: the structure containing the widget pointers.
*/
ManipulatorRow createManipulatorRow(wxWindow* parent,
const std::string& label, wxFlexGridSizer* table,
const std::string& label, wxFlexGridSizer* table,
const std::string& bitmapSmaller, const std::string& bitmapLarger);

// Widget construction
void populateWindow();
wxBoxSizer* createFitTextureRow();
void createScaleLinkButtons(wxFlexGridSizer& table);

// Connect IEvents to the widgets
void connectEvents();
Expand Down

0 comments on commit 3433719

Please sign in to comment.