Skip to content

Commit

Permalink
#5567: Make the unlock button more prominent
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 2, 2021
1 parent 71a4e64 commit adf85c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion install/ui/materialeditor.fbp
Expand Up @@ -2948,7 +2948,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxFlexGridSizer" expanded="1">
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
Expand Down
17 changes: 16 additions & 1 deletion radiant/ui/materials/editor/MaterialEditor.cpp
Expand Up @@ -292,6 +292,16 @@ void MaterialEditor::setupMaterialTreeView()
auto unlockButton = getControl<wxButton>("MaterialEditorUnlockButton");
unlockButton->Disable();
unlockButton->Bind(wxEVT_BUTTON, &MaterialEditor::_onUnlockMaterial, this);
unlockButton->Bind(wxEVT_ENTER_WINDOW, [unlockButton](wxMouseEvent&)
{
if (!unlockButton->IsEnabled()) { return; }
unlockButton->SetForegroundColour(wxNullColour);
});
unlockButton->Bind(wxEVT_LEAVE_WINDOW, [unlockButton](wxMouseEvent&)
{
if (!unlockButton->IsEnabled()) { return; }
unlockButton->SetForegroundColour(*wxWHITE);
});
}

void MaterialEditor::_onBasicMapEntryChanged(const std::string& entryName, IShaderLayer::Type type)
Expand Down Expand Up @@ -1552,7 +1562,12 @@ void MaterialEditor::updateMaterialControlSensitivity()
getControl<wxButton>("MaterialEditorCopyDefButton")->Enable(_material != nullptr);
getControl<wxButton>("MaterialEditorRevertButton")->Enable(_material && _material->isModified());

getControl<wxButton>("MaterialEditorUnlockButton")->Enable(_material && !canBeModified);
auto unlockButton = getControl<wxButton>("MaterialEditorUnlockButton");
unlockButton->Show(_material != nullptr);
unlockButton->Enable(_material && !canBeModified);
unlockButton->SetBackgroundColour(unlockButton->IsEnabled() ? wxColour(255, 70, 70) : wxNullColour);
unlockButton->SetLabelText(unlockButton->IsEnabled() ? _("Unlock Editing") : _("Is editable"));
unlockButton->SetForegroundColour(unlockButton->IsEnabled() ? *wxWHITE : wxNullColour);
}

std::pair<IShaderLayer::Ptr, std::size_t> MaterialEditor::findMaterialStageByType(IShaderLayer::Type type)
Expand Down

0 comments on commit adf85c8

Please sign in to comment.