Skip to content

Commit

Permalink
Reduce space wastage in bottom half of Surface Inspector
Browse files Browse the repository at this point in the history
Replace "Texture Lock" text button with an icon button. Remove
"Normalise" button and align "Natural" button and default scale spinbox
on the same row. Remove left-hand column of labels which provides little
information.
  • Loading branch information
Matthew Mott committed Apr 21, 2024
1 parent 9995276 commit 81df388
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 73 deletions.
Binary file modified install/bitmaps/texture_lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 32 additions & 68 deletions radiant/ui/surfaceinspector/SurfaceInspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,17 @@ namespace
constexpr const char* const FOLDER_ICON = "treeView16.png";
constexpr const char* const LABEL_STEP = N_("Step:");

constexpr const char* LABEL_FIT_TEXTURE = N_("Fit:");
constexpr const char* LABEL_FIT = N_("Fit");

constexpr const char* LABEL_ALIGN_TEXTURE = N_("Align:");
constexpr const char* LABEL_ALIGN_TOP = N_("Top");
constexpr const char* LABEL_ALIGN_BOTTOM = N_("Bottom");
constexpr const char* LABEL_ALIGN_RIGHT = N_("Right");
constexpr const char* LABEL_ALIGN_LEFT = N_("Left");

constexpr const char* LABEL_FLIP_TEXTURE = N_("Flip:");
constexpr const char* LABEL_FLIPX = N_("Flip Horizontal");
constexpr const char* LABEL_FLIPY = N_("Flip Vertical");

constexpr const char* LABEL_MODIFY_TEXTURE = N_("Modify:");
constexpr const char* LABEL_NATURAL = N_("Natural");
constexpr const char* LABEL_NORMALISE = N_("Normalise");
constexpr const char* LABEL_DEFAULT_SCALE = N_("Scale:");

constexpr const char* LABEL_DEFAULT_SCALE = N_("Default Scale:");
constexpr const char* LABEL_TEXTURE_LOCK = N_("Texture Lock");
// Tooltips
constexpr const char* TT_NATURAL = N_(
"Reset the texture to its default alignment"
);
constexpr const char* TT_DEFAULT_SCALE = N_(
"Scale to set when resetting a texture to its natural alignment"
);

const std::string RKEY_DEFAULT_TEXTURE_SCALE = "user/ui/textures/defaultTextureScale";

Expand Down Expand Up @@ -104,7 +96,6 @@ void SurfaceInspector::ManipulatorRow::setValue(double v)

void SurfaceInspector::FitTextureWidgets::enable(bool enabled)
{
label->Enable(enabled);
x->Enable(enabled);
fitButton->Enable(enabled);
preserveAspectButton->Enable(enabled);
Expand Down Expand Up @@ -211,7 +202,6 @@ void SurfaceInspector::connectButtons()
_alignTexture.right->Connect(wxEVT_BUTTON, wxCommandEventHandler(SurfaceInspector::onUpdateAfterButtonClick), NULL, this);
_alignTexture.left->Connect(wxEVT_BUTTON, wxCommandEventHandler(SurfaceInspector::onUpdateAfterButtonClick), NULL, this);
_modifyTex.natural->Connect(wxEVT_BUTTON, wxCommandEventHandler(SurfaceInspector::onUpdateAfterButtonClick), NULL, this);
_modifyTex.normalise->Connect(wxEVT_BUTTON, wxCommandEventHandler(SurfaceInspector::onUpdateAfterButtonClick), NULL, this);

for (ManipulatorMap::iterator i = _manipulators.begin(); i != _manipulators.end(); ++i)
{
Expand All @@ -222,7 +212,6 @@ void SurfaceInspector::connectButtons()
wxutil::button::connectToCommand(_flipTexture.flipX, "FlipTextureX");
wxutil::button::connectToCommand(_flipTexture.flipY, "FlipTextureY");
wxutil::button::connectToCommand(_modifyTex.natural, "TextureNatural");
wxutil::button::connectToCommand(_modifyTex.normalise, "NormaliseTexture");

wxutil::button::connectToCommand(_alignTexture.top, "TexAlignTop");
wxutil::button::connectToCommand(_alignTexture.bottom, "TexAlignBottom");
Expand Down Expand Up @@ -304,7 +293,6 @@ wxBoxSizer* SurfaceInspector::createFitTextureRow()
auto* fitTextureHBox = new wxBoxSizer(wxHORIZONTAL);

// Create widgets from left to right
_fitTexture.label = new wxStaticText(this, wxID_ANY, _(LABEL_FIT_TEXTURE));
_fitTexture.width = makeFitSpinBox(Axis::X);
_fitTexture.width->SetToolTip(
_("Number of whole texture images to fit horizontally. Use the spin "
Expand Down Expand Up @@ -340,8 +328,8 @@ wxBoxSizer* SurfaceInspector::createFitTextureRow()
widthTimesHeight->Add(_fitTexture.height, 1, wxALIGN_CENTER_VERTICAL);

fitTextureHBox->Add(widthTimesHeight, 1, wxALIGN_CENTER_VERTICAL);
fitTextureHBox->Add(_fitTexture.preserveAspectButton, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);
fitTextureHBox->Add(_fitTexture.fitButton, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);
fitTextureHBox->Add(_fitTexture.preserveAspectButton, 0, wxEXPAND | wxLEFT, 6);
fitTextureHBox->Add(_fitTexture.fitButton, 0, wxEXPAND | wxLEFT, 6);

return fitTextureHBox;
}
Expand Down Expand Up @@ -428,8 +416,7 @@ void SurfaceInspector::populateWindow()

// Setup the table with default spacings
// 5x2 table with 12 pixel hspacing and 6 pixels vspacing
wxFlexGridSizer* operTable = new wxFlexGridSizer(5, 2, 6, 12);
operTable->AddGrowableCol(1);
wxBoxSizer* operTable = new wxBoxSizer(wxVERTICAL);

// Pack label & table into the dialog
dialogVBox->AddSpacer(6);
Expand All @@ -438,26 +425,17 @@ void SurfaceInspector::populateWindow()
// ------------------------ Fit Texture -----------------------------------

wxBoxSizer* fitTextureHBox = createFitTextureRow();
operTable->Add(_fitTexture.label, 0, wxALIGN_CENTER_VERTICAL);
operTable->Add(fitTextureHBox, 1, wxEXPAND);
operTable->Add(fitTextureHBox, 0, wxEXPAND);

// ------------------------ Align Texture -----------------------------------

_alignTexture.label = new wxStaticText(this, wxID_ANY, _(LABEL_ALIGN_TEXTURE));

_alignTexture.top = wxutil::IconButton(this, "align_top.png");
_alignTexture.bottom = wxutil::IconButton(this, "align_bottom.png");
_alignTexture.left = wxutil::IconButton(this, "align_left.png");
_alignTexture.right = wxutil::IconButton(this, "align_right.png");

_flipTexture.flipX = wxutil::IconButton(this, "flip_horiz.png");
_flipTexture.flipY = wxutil::IconButton(this, "flip_vert.png");

_alignTexture.top->SetMinSize(PixelSize(20, -1));
_alignTexture.bottom->SetMinSize(PixelSize(20, -1));
_alignTexture.left->SetMinSize(PixelSize(20, -1));
_alignTexture.right->SetMinSize(PixelSize(20, -1));

auto* alignTextureBox = new wxGridSizer(1, 6, 0, 6);
alignTextureBox->Add(_alignTexture.top, 1, wxEXPAND);
alignTextureBox->Add(_alignTexture.bottom, 1, wxEXPAND);
Expand All @@ -466,48 +444,37 @@ void SurfaceInspector::populateWindow()
alignTextureBox->Add(_flipTexture.flipX, 1, wxEXPAND);
alignTextureBox->Add(_flipTexture.flipY, 1, wxEXPAND);

operTable->Add(_alignTexture.label, 0, wxALIGN_CENTER_VERTICAL);
operTable->Add(alignTextureBox, 1, wxEXPAND);

// ------------------------ Modify Texture -----------------------------------
operTable->Add(alignTextureBox, 0, wxEXPAND | wxTOP, 6);

_modifyTex.label = new wxStaticText(this, wxID_ANY, _(LABEL_MODIFY_TEXTURE));
// Natural / Scale / Texture lock row
wxBoxSizer* modTextureBox = new wxBoxSizer(wxHORIZONTAL);

_modifyTex.natural = new wxButton(this, wxID_ANY, _(LABEL_NATURAL));
_modifyTex.normalise = new wxButton(this, wxID_ANY, _(LABEL_NORMALISE));

wxGridSizer* modTextureBox = new wxGridSizer(1, 2, 0, 6);

modTextureBox->Add(_modifyTex.natural, 1, wxEXPAND);
modTextureBox->Add(_modifyTex.normalise, 1, wxEXPAND);

operTable->Add(_modifyTex.label, 0, wxALIGN_CENTER_VERTICAL);
operTable->Add(modTextureBox, 1, wxEXPAND);

// ------------------------ Default Scale -----------------------------------

_modifyTex.natural->SetToolTip(_(TT_NATURAL));
modTextureBox->Add(_modifyTex.natural, 0, wxEXPAND);
wxStaticText* defaultScaleLabel = new wxStaticText(this, wxID_ANY, _(LABEL_DEFAULT_SCALE));
modTextureBox->Add(defaultScaleLabel, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 6);

_defaultTexScale = new wxSpinCtrlDouble(this, wxID_ANY);
_defaultTexScale->SetMinSize(wxSize(50, -1));
_defaultTexScale->SetToolTip(_(TT_DEFAULT_SCALE));
_defaultTexScale->SetMinSize(
wxSize(_defaultTexScale->GetCharWidth() * SPINBOX_WIDTH_CHARS, -1)
);
_defaultTexScale->SetRange(0.0, 1000.0);
_defaultTexScale->SetIncrement(0.1);
_defaultTexScale->SetDigits(3);
modTextureBox->Add(_defaultTexScale, 1, wxLEFT, 6);

// Texture Lock Toggle
_texLockButton = new wxToggleButton(this, wxID_ANY, _(LABEL_TEXTURE_LOCK));

wxGridSizer* defaultScaleBox = new wxGridSizer(1, 2, 0, 6);

wxBoxSizer* texScaleSizer = new wxBoxSizer(wxHORIZONTAL);
texScaleSizer->Add(_defaultTexScale, 1, wxALIGN_CENTER_VERTICAL);

defaultScaleBox->Add(texScaleSizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
defaultScaleBox->Add(_texLockButton, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);

operTable->Add(defaultScaleLabel, 0, wxALIGN_CENTER_VERTICAL);
operTable->Add(defaultScaleBox, 1, wxEXPAND);
_texLockButton = new wxBitmapToggleButton(
this, wxID_ANY, wxutil::GetLocalBitmap("texture_lock.png")
);
_texLockButton->SetToolTip(
_("Lock texture to face(s) when moving brush or patch (global setting)")
);
modTextureBox->Add(_texLockButton, 0, wxLEFT | wxEXPAND, 6);
operTable->Add(modTextureBox, 0, wxEXPAND | wxTOP, 6);

// Top-level sizer to provide margin
wxBoxSizer* border = new wxBoxSizer(wxVERTICAL);
border->Add(dialogVBox, 1, wxEXPAND | wxALL, 12);
SetSizerAndFit(border);
Expand Down Expand Up @@ -673,16 +640,13 @@ void SurfaceInspector::doUpdate()
_alignTexture.left->Enable(haveSelection);
_alignTexture.right->Enable(haveSelection);
_alignTexture.top->Enable(haveSelection);
_alignTexture.label->Enable(haveSelection);

// The flip texture widget sensitivity
_flipTexture.flipX->Enable(haveSelection);
_flipTexture.flipY->Enable(haveSelection);

// The natural/normalise widget sensitivity
_modifyTex.label->Enable(haveSelection);
_modifyTex.natural->Enable(haveSelection);
_modifyTex.normalise->Enable(haveSelection);

// Current shader name
_shaderEntry->SetValue(selection::getShaderFromSelection());
Expand Down
4 changes: 0 additions & 4 deletions radiant/ui/surfaceinspector/SurfaceInspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class SurfaceInspector :

struct FitTextureWidgets
{
wxStaticText* label;
wxStaticText* x;
wxButton* fitButton;
wxToggleButton* preserveAspectButton;
Expand All @@ -71,7 +70,6 @@ class SurfaceInspector :

struct AlignTextureWidgets
{
wxStaticText* label;
wxButton* top;
wxButton* bottom;
wxButton* left;
Expand All @@ -80,9 +78,7 @@ class SurfaceInspector :

struct ModifyTextureWidgets
{
wxStaticText* label;
wxButton* natural;
wxButton* normalise;
} _modifyTex;

wxSpinCtrlDouble* _defaultTexScale;
Expand Down
2 changes: 1 addition & 1 deletion resources/icons/flip_vert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions resources/icons/texture_lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 81df388

Please sign in to comment.