Skip to content

Commit

Permalink
#5537: Add protected virtual method to override by DeclarationSelecto…
Browse files Browse the repository at this point in the history
…r subclasses
  • Loading branch information
codereader committed Sep 16, 2022
1 parent 038a1d9 commit 5e6b7ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions radiant/ui/common/DeclarationSelector.cpp
Expand Up @@ -54,6 +54,8 @@ void DeclarationSelector::PopulateTreeView(const wxutil::IResourceTreePopulator:

void DeclarationSelector::onTreeViewSelectionChanged(wxDataViewEvent& ev)
{
// Invoke the virtual method
onTreeViewSelectionChanged();
ev.Skip();
}

Expand Down
4 changes: 4 additions & 0 deletions radiant/ui/common/DeclarationSelector.h
Expand Up @@ -43,6 +43,10 @@ class DeclarationSelector :
wxutil::DeclarationTreeView* GetTreeView();
void PopulateTreeView(const wxutil::IResourceTreePopulator::Ptr& populator);

// Event method invoked when the tree view selection has been changed
virtual void onTreeViewSelectionChanged()
{}

private:
void createTreeView();
void onTreeViewSelectionChanged(wxDataViewEvent& ev);
Expand Down
3 changes: 1 addition & 2 deletions radiant/ui/common/ShaderSelector.cpp
Expand Up @@ -85,7 +85,6 @@ ShaderSelector::ShaderSelector(wxWindow* parent, const std::function<void()>& se
createPreview();

PopulateTreeView(std::make_shared<ThreadedMaterialLoader>(Columns(), _textureFilter));
GetTreeView()->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ShaderSelector::_onSelChange, this);
}

const wxutil::DeclarationTreeView::Columns& ShaderSelector::Columns()
Expand All @@ -105,7 +104,7 @@ MaterialPtr ShaderSelector::getSelectedShader()
return GlobalMaterialManager().getMaterial(GetSelectedDeclName());
}

void ShaderSelector::_onSelChange(wxDataViewEvent& ev)
void ShaderSelector::onTreeViewSelectionChanged()
{
_previewCombo->SetTexture(GetSelectedDeclName());

Expand Down
9 changes: 3 additions & 6 deletions radiant/ui/common/ShaderSelector.h
@@ -1,12 +1,9 @@
#pragma once

#include <string>
#include <memory>
#include "DeclarationSelector.h"
#include "wxutil/dataview/DeclarationTreeView.h"

#include <wx/panel.h>

#include "TexturePreviewCombo.h"

// FORWARD DECLS
Expand Down Expand Up @@ -58,12 +55,12 @@ class ShaderSelector :
// Get the selected Material
MaterialPtr getSelectedShader();

protected:
void onTreeViewSelectionChanged() override;

private:
// Create GUI elements
void createPreview();

void _onSelChange(wxDataViewEvent& ev);

const wxutil::DeclarationTreeView::Columns& Columns();
};

Expand Down

0 comments on commit 5e6b7ae

Please sign in to comment.