Skip to content

Commit

Permalink
#5532: Stage manipulation button sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 20, 2021
1 parent 6db0dd5 commit 808c324
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -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<wxButton>("MaterialEditorRemoveStageButton")->Enable();
getControl<wxButton>("MaterialEditorToggleStageButton")->Enable();
getControl<wxButton>("MaterialEditorMoveUpStageButton")->Enable(index > 0);
getControl<wxButton>("MaterialEditorMoveDownStageButton")->Enable(index + 1 < layersCount);
getControl<wxButton>("MaterialEditorDuplicateStageButton")->Enable();
}
else
{
getControl<wxButton>("MaterialEditorRemoveStageButton")->Disable();
getControl<wxButton>("MaterialEditorToggleStageButton")->Disable();
getControl<wxButton>("MaterialEditorMoveUpStageButton")->Disable();
getControl<wxButton>("MaterialEditorMoveDownStageButton")->Disable();
getControl<wxButton>("MaterialEditorDuplicateStageButton")->Disable();
}
}

void MaterialEditor::_onStageListValueChanged(wxDataViewEvent& ev)
Expand Down Expand Up @@ -1122,6 +1149,7 @@ void MaterialEditor::selectStageByIndex(std::size_t index)
}

updateStageControls();
updateStageButtonSensitivity();
}

IShaderLayer::Ptr MaterialEditor::getSelectedStage()
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/materials/MaterialEditor.h
Expand Up @@ -131,6 +131,7 @@ class MaterialEditor :
void updateStageColoredStatus();
void updateNameOfSelectedStage();
void moveStagePosition(int direction);
void updateStageButtonSensitivity();

void _onTreeViewSelectionChanged(wxDataViewEvent& ev);
void _onStageListSelectionChanged(wxDataViewEvent& ev);
Expand Down

0 comments on commit 808c324

Please sign in to comment.