diff --git a/radiant/ui/materials/MaterialEditor.cpp b/radiant/ui/materials/MaterialEditor.cpp index 142dacf601..e4540fd234 100644 --- a/radiant/ui/materials/MaterialEditor.cpp +++ b/radiant/ui/materials/MaterialEditor.cpp @@ -828,6 +828,33 @@ void MaterialEditor::_onTreeViewSelectionChanged(wxDataViewEvent& ev) void MaterialEditor::_onStageListSelectionChanged(wxDataViewEvent& ev) { updateStageControls(); + updateStageButtonSensitivity(); +} + +void MaterialEditor::updateStageButtonSensitivity() +{ + auto item = _stageView->GetSelection(); + + if (_material && item.IsOk()) + { + auto row = wxutil::TreeModel::Row(item, *_stageList); + auto index = row[STAGE_COLS().index].getInteger(); + auto layersCount = _material->getAllLayers().size(); + + getControl("MaterialEditorRemoveStageButton")->Enable(); + getControl("MaterialEditorToggleStageButton")->Enable(); + getControl("MaterialEditorMoveUpStageButton")->Enable(index > 0); + getControl("MaterialEditorMoveDownStageButton")->Enable(index + 1 < layersCount); + getControl("MaterialEditorDuplicateStageButton")->Enable(); + } + else + { + getControl("MaterialEditorRemoveStageButton")->Disable(); + getControl("MaterialEditorToggleStageButton")->Disable(); + getControl("MaterialEditorMoveUpStageButton")->Disable(); + getControl("MaterialEditorMoveDownStageButton")->Disable(); + getControl("MaterialEditorDuplicateStageButton")->Disable(); + } } void MaterialEditor::_onStageListValueChanged(wxDataViewEvent& ev) @@ -1122,6 +1149,7 @@ void MaterialEditor::selectStageByIndex(std::size_t index) } updateStageControls(); + updateStageButtonSensitivity(); } IShaderLayer::Ptr MaterialEditor::getSelectedStage() diff --git a/radiant/ui/materials/MaterialEditor.h b/radiant/ui/materials/MaterialEditor.h index 0b1ee9169c..57d47aeb0c 100644 --- a/radiant/ui/materials/MaterialEditor.h +++ b/radiant/ui/materials/MaterialEditor.h @@ -131,6 +131,7 @@ class MaterialEditor : void updateStageColoredStatus(); void updateNameOfSelectedStage(); void moveStagePosition(int direction); + void updateStageButtonSensitivity(); void _onTreeViewSelectionChanged(wxDataViewEvent& ev); void _onStageListSelectionChanged(wxDataViewEvent& ev);