Skip to content

Commit

Permalink
#6021: Move row assignment code from ThreadedMaterialLoader to Thread…
Browse files Browse the repository at this point in the history
…edDeclarationTreePopulator
  • Loading branch information
codereader committed Jul 29, 2022
1 parent 8f58dc8 commit 267a716
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions radiant/ui/common/ShaderSelector.cpp
Expand Up @@ -11,7 +11,6 @@

#include <wx/dataview.h>
#include <wx/sizer.h>
#include "wxutil/Bitmap.h"

#include <GL/glew.h>

Expand All @@ -22,9 +21,7 @@
#include "string/predicate.h"
#include <functional>

#include "ifavourites.h"
#include "wxutil/dataview/ThreadedDeclarationTreePopulator.h"
#include "wxutil/dataview/TreeViewItemStyle.h"

namespace ui
{
Expand All @@ -33,8 +30,7 @@ namespace ui

namespace
{
const char* const FOLDER_ICON = "folder16.png";
const char* const TEXTURE_ICON = "icon_texture.png";
constexpr const char* const TEXTURE_ICON = "icon_texture.png";
}

/**
Expand All @@ -47,18 +43,12 @@ class ThreadedMaterialLoader final :
const wxutil::DeclarationTreeView::Columns& _columns;
const ShaderSelector::PrefixList& _prefixes;

wxIcon _folderIcon;
wxIcon _textureIcon;

public:
ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, const ShaderSelector::PrefixList& prefixes) :
ThreadedDeclarationTreePopulator(decl::Type::Material, columns),
ThreadedDeclarationTreePopulator(decl::Type::Material, columns, TEXTURE_ICON),
_columns(columns),
_prefixes(prefixes)
{
_textureIcon.CopyFromBitmap(wxutil::GetLocalBitmap(TEXTURE_ICON));
_folderIcon.CopyFromBitmap(wxutil::GetLocalBitmap(FOLDER_ICON));
}
{}

~ThreadedMaterialLoader()
{
Expand All @@ -79,7 +69,7 @@ class ThreadedMaterialLoader final :
populator.addPath(materialName, [&](wxutil::TreeModel::Row& row,
const std::string& path, const std::string& leafName, bool isFolder)
{
StoreMaterialValues(row, path, leafName, isFolder);
AssignValuesToRow(row, path, path, leafName, isFolder);
});
break; // don't consider any further prefixes
}
Expand All @@ -91,22 +81,6 @@ class ThreadedMaterialLoader final :
{
model->SortModelFoldersFirst(_columns.leafName, _columns.isFolder);
}

private:
void StoreMaterialValues(wxutil::TreeModel::Row& row, const std::string& materialName, const std::string& leafName, bool isFolder)
{
bool isFavourite = IsFavourite(materialName);

row[_columns.iconAndName] = wxVariant(wxDataViewIconText(leafName, !isFolder ? _textureIcon : _folderIcon));
row[_columns.iconAndName] = wxutil::TreeViewItemStyle::Declaration(isFavourite);
row[_columns.fullName] = materialName;
row[_columns.leafName] = leafName;
row[_columns.declName] = materialName;
row[_columns.isFolder] = isFolder;
row[_columns.isFavourite] = isFavourite;

row.SendItemAdded();
}
};

// Constructor creates elements
Expand Down

0 comments on commit 267a716

Please sign in to comment.