Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5774: Add buttons to harmonise Horizontal and Vertical scale values
  • Loading branch information
codereader committed Oct 9, 2021
1 parent c4a89cf commit 601794b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
Binary file added install/bitmaps/arrow_down_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/bitmaps/arrow_up_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 43 additions & 2 deletions radiant/ui/surfaceinspector/SurfaceInspector.cpp
Expand Up @@ -293,8 +293,8 @@ void SurfaceInspector::populateWindow()
wxStaticText* topLabel = new wxStaticText(this, wxID_ANY, _(LABEL_PROPERTIES));
topLabel->SetFont(topLabel->GetFont().Bold());

// 6x2 table with 12 pixel hspacing and 6 pixels vspacing
wxFlexGridSizer* table = new wxFlexGridSizer(6, 2, 6, 12);
// 7x2 table with 12 pixel hspacing and 6 pixels vspacing
auto table = new wxFlexGridSizer(7, 2, 6, 12);
table->AddGrowableCol(1);

// Create the entry field and pack it into the first table row
Expand Down Expand Up @@ -331,6 +331,25 @@ void SurfaceInspector::populateWindow()
_manipulators[HSHIFT] = createManipulatorRow(this, _(LABEL_HSHIFT), table);
_manipulators[VSHIFT] = createManipulatorRow(this, _(LABEL_VSHIFT), table);
_manipulators[HSCALE] = createManipulatorRow(this, _(LABEL_HSCALE), table);

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

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); });

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

_manipulators[VSCALE] = createManipulatorRow(this, _(LABEL_VSCALE), table);
_manipulators[ROTATION] = createManipulatorRow(this, _(LABEL_ROTATION), table);

Expand Down Expand Up @@ -501,6 +520,25 @@ SurfaceInspector& SurfaceInspector::Instance()
return *instancePtr;
}

void SurfaceInspector::onHarmoniseScale(bool useHorizontal)
{
auto horizValue = _manipulators[HSCALE].value->GetValue();
auto vertValue = _manipulators[VSCALE].value->GetValue();

if (horizValue == vertValue) return; // nothing to do

if (useHorizontal)
{
_manipulators[VSCALE].value->SetValue(horizValue);
}
else
{
_manipulators[HSCALE].value->SetValue(vertValue);
}

emitTexDef();
}

void SurfaceInspector::emitShader()
{
// Apply it to the selection
Expand Down Expand Up @@ -590,6 +628,9 @@ void SurfaceInspector::doUpdate()
_manipulators[VSCALE].value->Enable(valueSensitivity);
_manipulators[ROTATION].value->Enable(valueSensitivity);

_useHorizScale->Enable(valueSensitivity);
_useVertScale->Enable(valueSensitivity);

// The fit widget sensitivity
_fitTexture.enable(haveSelection);

Expand Down
4 changes: 4 additions & 0 deletions radiant/ui/surfaceinspector/SurfaceInspector.h
Expand Up @@ -92,6 +92,8 @@ class SurfaceInspector :

wxSpinCtrlDouble* _defaultTexScale;
wxToggleButton* _texLockButton;
wxButton* _useHorizScale;
wxButton* _useVertScale;

// To avoid key changed loopbacks when the registry is updated
bool _callbackActive;
Expand Down Expand Up @@ -183,6 +185,8 @@ class SurfaceInspector :

void handleTextureChangedMessage(radiant::TextureChangedMessage& msg);

void onHarmoniseScale(bool useHorizontal);

}; // class SurfaceInspector

} // namespace

0 comments on commit 601794b

Please sign in to comment.