Skip to content

Commit

Permalink
#5537: Rename ShaderSelector to MaterialSelector and move its file pa…
Browse files Browse the repository at this point in the history
…ir to ui/materials/ folder
  • Loading branch information
codereader committed Sep 16, 2022
1 parent 072f99f commit 72c3302
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion radiant/CMakeLists.txt
Expand Up @@ -37,7 +37,6 @@ add_executable(darkradiant
ui/common/ImageFileSelector.cpp
ui/common/MapPreview.cpp
ui/common/ShaderChooser.cpp
ui/common/ShaderSelector.cpp
ui/common/TexturePreviewCombo.cpp
ui/common/SkinChooser.cpp
ui/common/SoundChooser.cpp
Expand Down Expand Up @@ -96,6 +95,7 @@ add_executable(darkradiant
ui/materials/editor/MaterialEditorModule.cpp
ui/materials/editor/MaterialPreview.cpp
ui/materials/MaterialPopulator.cpp
ui/materials/MaterialSelector.cpp
ui/materials/MaterialTreeView.cpp
ui/merge/MergeControlDialog.cpp
ui/animationpreview/AnimationPreview.cpp
Expand Down
2 changes: 2 additions & 0 deletions radiant/ui/common/DeclarationSelector.h
Expand Up @@ -10,6 +10,8 @@ namespace ui

/**
* Common implementation of a declaration selector widget that can be added to a dialog.
* It features a Declaration Tree View with an associated toolbar for favourite management.
* Preview widgets can optionally be appended to the right or the bottom of the tree view.
*/
class DeclarationSelector :
public wxPanel
Expand Down
8 changes: 4 additions & 4 deletions radiant/ui/common/ShaderChooser.cpp
Expand Up @@ -7,7 +7,7 @@
#include <wx/button.h>
#include <wx/textctrl.h>

#include "ShaderSelector.h"
#include "../materials/MaterialSelector.h"

namespace ui
{
Expand All @@ -18,7 +18,7 @@ namespace ui
}

// Construct the dialog
ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter filter, wxTextCtrl* targetEntry) :
ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry) :
wxutil::DialogBase(_(LABEL_TITLE), parent),
_targetEntry(targetEntry),
_selector(nullptr)
Expand All @@ -30,7 +30,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter fil
wxBoxSizer* dialogVBox = new wxBoxSizer(wxVERTICAL);
mainPanel->GetSizer()->Add(dialogVBox, 1, wxEXPAND | wxALL, 12);

_selector = new ShaderSelector(mainPanel,
_selector = new MaterialSelector(mainPanel,
std::bind(&ShaderChooser::shaderSelectionChanged, this), filter);

if (_targetEntry != nullptr)
Expand All @@ -43,7 +43,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter fil

_selector->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &ShaderChooser::_onItemActivated, this);

// Pack in the ShaderSelector and buttons panel
// Pack in the MaterialSelector and buttons panel
dialogVBox->Add(_selector, 1, wxEXPAND);

createButtons(mainPanel, dialogVBox);
Expand Down
12 changes: 6 additions & 6 deletions radiant/ui/common/ShaderChooser.h
@@ -1,6 +1,6 @@
#pragma once

#include "ui/common/ShaderSelector.h"
#include "ui/materials/MaterialSelector.h"
#include "wxutil/WindowPosition.h"
#include "wxutil/dialog/DialogBase.h"
#include <string>
Expand All @@ -12,8 +12,8 @@ class Material;
namespace ui
{

/* A dialog containing a ShaderSelector widget combo and OK/Cancel
* buttons. The ShaderSelector subclass is automatically populated with
/* A dialog containing a MaterialSelector widget combo and OK/Cancel
* buttons. The MaterialSelector subclass is automatically populated with
* all shaders matching the "texture/" prefix.
*/
class ShaderChooser :
Expand All @@ -22,9 +22,9 @@ class ShaderChooser :
// The text entry the chosen texture is written into (can be NULL)
wxTextCtrl* _targetEntry;

// The ShaderSelector widget, that contains the actual selection
// The MaterialSelector widget, that contains the actual selection
// tools (treeview etc.)
ShaderSelector* _selector;
MaterialSelector* _selector;

// The shader name at dialog startup (to allow proper behaviour on cancelling)
std::string _initialShader;
Expand All @@ -43,7 +43,7 @@ class ShaderChooser :
* Also, the initially selected shader will be read from
* this field at startup.
*/
ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr);
ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr);

std::string getSelectedTexture();

Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/einspector/TexturePropertyEditor.cpp
Expand Up @@ -24,7 +24,7 @@ TexturePropertyEditor::TexturePropertyEditor(wxWindow* parent, IEntitySelection&
// Browse button callback
void TexturePropertyEditor::onBrowseButtonClick()
{
auto dialog = new ShaderChooser(getWidget(), ShaderSelector::TextureFilter::Lights);
auto dialog = new ShaderChooser(getWidget(), MaterialSelector::TextureFilter::Lights);

dialog->setSelectedTexture(getKeyValue(_key->getFullKey()));

Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/findshader/FindShader.cpp
Expand Up @@ -106,7 +106,7 @@ void FindAndReplaceShader::performReplace()
void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev)
{
// Construct the modal dialog
ShaderChooser* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular,
ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular,
findNamedObject<wxTextCtrl>(this, "FindReplaceDialogFindEntry"));

chooser->ShowModal();
Expand All @@ -116,7 +116,7 @@ void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev)
void FindAndReplaceShader::onChooseReplace(wxCommandEvent& ev)
{
// Construct the modal dialog
ShaderChooser* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular,
ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular,
findNamedObject<wxTextCtrl>(this, "FindReplaceDialogReplaceEntry"));

chooser->ShowModal();
Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/lightinspector/LightInspector.cpp
Expand Up @@ -175,8 +175,8 @@ void LightInspector::setupTextureWidgets()
{
wxPanel* parent = findNamedObject<wxPanel>(this, "LightInspectorChooserPanel");

_texSelector = new ShaderSelector(parent, std::bind(&LightInspector::shaderSelectionChanged, this),
ShaderSelector::TextureFilter::Lights);
_texSelector = new MaterialSelector(parent, std::bind(&LightInspector::shaderSelectionChanged, this),
MaterialSelector::TextureFilter::Lights);
parent->GetSizer()->Add(_texSelector, 1, wxEXPAND);
}

Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/lightinspector/LightInspector.h
Expand Up @@ -2,7 +2,7 @@

#include "icommandsystem.h"
#include "iradiant.h"
#include "ui/common/ShaderSelector.h"
#include "ui/materials/MaterialSelector.h"
#include "wxutil/window/TransientWindow.h"
#include "wxutil/XmlResourceBasedWidget.h"

Expand Down Expand Up @@ -35,7 +35,7 @@ class LightInspector :
bool _isProjected;

// Internal widgets
ShaderSelector* _texSelector;
MaterialSelector* _texSelector;
wxSlider* _brightnessSlider;

// The light entities to edit
Expand Down
@@ -1,4 +1,4 @@
#include "ShaderSelector.h"
#include "MaterialSelector.h"

#include <vector>
#include <string>
Expand Down Expand Up @@ -34,10 +34,10 @@ class ThreadedMaterialLoader final :
std::vector<std::string> _prefixes;

public:
ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, ShaderSelector::TextureFilter filter) :
ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, MaterialSelector::TextureFilter filter) :
ThreadedDeclarationTreePopulator(decl::Type::Material, columns, TEXTURE_ICON)
{
if (filter == ShaderSelector::TextureFilter::Lights)
if (filter == MaterialSelector::TextureFilter::Lights)
{
_prefixes = game::current::getLightTexturePrefixes();
}
Expand Down Expand Up @@ -75,7 +75,7 @@ class ThreadedMaterialLoader final :
}
};

ShaderSelector::ShaderSelector(wxWindow* parent, const std::function<void()>& selectionChanged,
MaterialSelector::MaterialSelector(wxWindow* parent, const std::function<void()>& selectionChanged,
TextureFilter textureFilter) :
DeclarationSelector(parent, decl::Type::Material),
_textureFilter(textureFilter),
Expand All @@ -87,12 +87,12 @@ ShaderSelector::ShaderSelector(wxWindow* parent, const std::function<void()>& se
PopulateTreeView(std::make_shared<ThreadedMaterialLoader>(GetColumns(), _textureFilter));
}

MaterialPtr ShaderSelector::getSelectedShader()
MaterialPtr MaterialSelector::getSelectedShader()
{
return GlobalMaterialManager().getMaterial(GetSelectedDeclName());
}

void ShaderSelector::onTreeViewSelectionChanged()
void MaterialSelector::onTreeViewSelectionChanged()
{
_previewCombo->SetTexture(GetSelectedDeclName());

Expand Down
@@ -1,9 +1,8 @@
#pragma once

#include <memory>
#include "DeclarationSelector.h"

#include "TexturePreviewCombo.h"
#include "../common/DeclarationSelector.h"
#include "../common/TexturePreviewCombo.h"

// FORWARD DECLS
class Material;
Expand All @@ -15,18 +14,18 @@ namespace ui
{

/**
* A widget that allows the selection of a shader. The widget contains
* three elements - a tree view displaying available shaders as
* identified by the specified prefixes, a TexturePreviewComob displaying a
* preview of the currently-selected shader and a table containing certain
* information about the shader.
* A widget that allows the selection of a material. The widget contains
* three elements - a tree view displaying available materials as
* identified by the specified prefixes, a TexturePreviewCombo displaying a
* preview of the currently-selected material and a table containing certain
* information about it.
*
* This widget populates its list of shaders automatically, and offers a method
* This widget populates its list of materials automatically, and offers a method
* that allows calling code to retrieve the user's selection. The set of
* displayed textures can be defined by passing the corresponding TextureFilter
* displayed materials can be defined by passing the corresponding TextureFilter
* value to the constructor.
*/
class ShaderSelector :
class MaterialSelector :
public DeclarationSelector
{
public:
Expand All @@ -49,7 +48,7 @@ class ShaderSelector :
* @selectionChanged: Functor invoked when the tree view selection changes.
* @filter: which texture set to show in the selector
*/
ShaderSelector(wxWindow* parent, const std::function<void()>& selectionChanged, TextureFilter filter);
MaterialSelector(wxWindow* parent, const std::function<void()>& selectionChanged, TextureFilter filter);

// Get the selected Material
MaterialPtr getSelectedShader();
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/materials/editor/MaterialEditor.cpp
Expand Up @@ -411,7 +411,7 @@ void MaterialEditor::setupPreviewLightProperties(wxWindow* previewPanel)
getControl<wxButton>("MaterialPreviewRoomMaterialButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent& ev)
{
auto textCtrl = getControl<wxTextCtrl>("MaterialPreviewRoomMaterial");
auto selector = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, textCtrl);
auto selector = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, textCtrl);
selector->ShowModal();
selector->Destroy();
});
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/surfaceinspector/SurfaceInspector.cpp
Expand Up @@ -788,7 +788,7 @@ void SurfaceInspector::onShaderSelect(wxCommandEvent& ev)
std::string previousShader = _shaderEntry->GetValue().ToStdString();

// Instantiate the modal dialog, will block execution
auto* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, _shaderEntry);
auto* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, _shaderEntry);

chooser->signal_shaderChanged().connect(
sigc::mem_fun(this, &SurfaceInspector::emitShader)
Expand Down
4 changes: 2 additions & 2 deletions tools/msvc/DarkRadiant.vcxproj
Expand Up @@ -268,6 +268,7 @@
<ClCompile Include="..\..\radiant\ui\materials\editor\MaterialEditorModule.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\editor\MaterialPreview.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialPopulator.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialSelector.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialTreeView.cpp" />
<ClCompile Include="..\..\radiant\ui\mediabrowser\MediaBrowserTreeView.cpp" />
<ClCompile Include="..\..\radiant\ui\menu\MenuBar.cpp" />
Expand All @@ -291,7 +292,6 @@
<ClCompile Include="..\..\radiant\ui\common\EntityChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\common\MapPreview.cpp" />
<ClCompile Include="..\..\radiant\ui\common\ShaderChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\common\ShaderSelector.cpp" />
<ClCompile Include="..\..\radiant\ui\common\TexturePreviewCombo.cpp" />
<ClCompile Include="..\..\radiant\ui\einspector\AddPropertyDialog.cpp" />
<ClCompile Include="..\..\radiant\ui\einspector\AnglePropertyEditor.cpp" />
Expand Down Expand Up @@ -474,6 +474,7 @@
<ClInclude Include="..\..\radiant\ui\materials\editor\TestModelSkin.h" />
<ClInclude Include="..\..\radiant\ui\materials\editor\TexturePreview.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialPopulator.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialSelector.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialTreeView.h" />
<ClInclude Include="..\..\radiant\ui\mediabrowser\MediaBrowserTreeView.h" />
<ClInclude Include="..\..\radiant\ui\menu\MenuBar.h" />
Expand All @@ -499,7 +500,6 @@
<ClInclude Include="..\..\radiant\ui\common\EntityChooser.h" />
<ClInclude Include="..\..\radiant\ui\common\MapPreview.h" />
<ClInclude Include="..\..\radiant\ui\common\ShaderChooser.h" />
<ClInclude Include="..\..\radiant\ui\common\ShaderSelector.h" />
<ClInclude Include="..\..\radiant\ui\common\TexturePreviewCombo.h" />
<ClInclude Include="..\..\radiant\ui\einspector\AddPropertyDialog.h" />
<ClInclude Include="..\..\radiant\ui\einspector\AnglePropertyEditor.h" />
Expand Down
12 changes: 6 additions & 6 deletions tools/msvc/DarkRadiant.vcxproj.filters
Expand Up @@ -226,9 +226,6 @@
<ClCompile Include="..\..\radiant\ui\common\ShaderChooser.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\common\ShaderSelector.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\common\TexturePreviewCombo.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
Expand Down Expand Up @@ -709,6 +706,9 @@
<ClCompile Include="..\..\radiant\ui\common\DeclarationSelector.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\materials\MaterialSelector.cpp">
<Filter>src\ui\materials</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiant\camera\CameraSettings.h">
Expand Down Expand Up @@ -744,9 +744,6 @@
<ClInclude Include="..\..\radiant\ui\common\ShaderChooser.h">
<Filter>src\ui\common</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\common\ShaderSelector.h">
<Filter>src\ui\common</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\common\TexturePreviewCombo.h">
<Filter>src\ui\common</Filter>
</ClInclude>
Expand Down Expand Up @@ -1380,6 +1377,9 @@
<ClInclude Include="..\..\radiant\ui\common\DeclarationSelector.h">
<Filter>src\ui\common</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\materials\MaterialSelector.h">
<Filter>src\ui\materials</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\radiant\darkradiant.rc" />
Expand Down

0 comments on commit 72c3302

Please sign in to comment.