Skip to content

Commit

Permalink
#5532: Toggle stage visibility button
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 20, 2021
1 parent 4f4f22d commit 0c70138
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -398,6 +398,7 @@ void MaterialEditor::setupMaterialStageView()

getControl<wxButton>("MaterialEditorAddStageButton")->Bind(wxEVT_BUTTON, &MaterialEditor::_onAddStage, this);
getControl<wxButton>("MaterialEditorRemoveStageButton")->Bind(wxEVT_BUTTON, &MaterialEditor::_onRemoveStage, this);
getControl<wxButton>("MaterialEditorToggleStageButton")->Bind(wxEVT_BUTTON, &MaterialEditor::_onToggleStage, this);
}

void MaterialEditor::setupStageFlag(const std::string& controlName, int flags)
Expand Down Expand Up @@ -836,7 +837,6 @@ void MaterialEditor::_onStageListValueChanged(wxDataViewEvent& ev)

wxutil::TreeModel::Row row(ev.GetItem(), *_stageList);
stage->setEnabled(row[STAGE_COLS().enabled].getBool());
int index = row[STAGE_COLS().index].getInteger();
}

void MaterialEditor::updateControlsFromMaterial()
Expand Down Expand Up @@ -1625,6 +1625,23 @@ void MaterialEditor::_onRemoveStage(wxCommandEvent& ev)
updateStageListFromMaterial();
}

void MaterialEditor::_onToggleStage(wxCommandEvent& ev)
{
auto item = _stageView->GetSelection();
if (!_material || !item.IsOk()) return;

auto row = wxutil::TreeModel::Row(item, *_stageList);
row[STAGE_COLS().enabled] = !row[STAGE_COLS().enabled].getBool();

row.SendItemChanged();

auto stage = getEditableStageForSelection();
if (!stage) return;

stage->setEnabled(row[STAGE_COLS().enabled].getBool());
onMaterialChanged();
}

void MaterialEditor::updateNameOfSelectedStage()
{
auto item = _stageView->GetSelection();
Expand All @@ -1633,7 +1650,6 @@ void MaterialEditor::updateNameOfSelectedStage()
auto row = wxutil::TreeModel::Row(item, *_stageList);

row[STAGE_COLS().name] = getNameForLayer(*getSelectedStage());

row.SendItemChanged();
}

Expand Down
1 change: 1 addition & 0 deletions radiant/ui/materials/MaterialEditor.h
Expand Up @@ -143,6 +143,7 @@ class MaterialEditor :
void _onStageBlendTypeChanged(wxCommandEvent& ev);
void _onAddStage(wxCommandEvent& ev);
void _onRemoveStage(wxCommandEvent& ev);
void _onToggleStage(wxCommandEvent& ev);

void onMaterialChanged();

Expand Down

0 comments on commit 0c70138

Please sign in to comment.