Skip to content

Commit

Permalink
#4764: Thumbnail browser is now displaying folders in the "Other Mate…
Browse files Browse the repository at this point in the history
…rials" branch
  • Loading branch information
codereader committed Nov 6, 2022
1 parent 403b8e8 commit fd000f8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions radiant/ui/materials/MaterialPopulator.cpp
Expand Up @@ -31,6 +31,11 @@ MaterialPopulator::~MaterialPopulator()
EnsureStopped();
}

std::string MaterialPopulator::GetOtherMaterialsName()
{
return _(OTHER_MATERIALS_FOLDER);
}

void MaterialPopulator::AddSingleMaterial(const wxutil::TreeModel::Ptr& model, const std::string& materialName)
{
std::vector<std::string> parts;
Expand Down
2 changes: 2 additions & 0 deletions radiant/ui/materials/MaterialPopulator.h
Expand Up @@ -27,6 +27,8 @@ class MaterialPopulator :
// Remove the given named material from the tree (assuming it is present)
void RemoveSingleMaterial(const wxutil::TreeModel::Ptr& model, const std::string& materialName);

static std::string GetOtherMaterialsName();

protected:
void PopulateModel(const wxutil::TreeModel::Ptr& model) override;

Expand Down
13 changes: 13 additions & 0 deletions radiant/ui/materials/MaterialTreeView.cpp
Expand Up @@ -58,6 +58,19 @@ void MaterialTreeView::SetTreeMode(MaterialTreeView::TreeMode mode)
SetSelectedFullname(previouslySelectedItem);
}

std::string MaterialTreeView::GetSelectedTextureFolderName()
{
if (!IsDirectorySelected()) return {};

// The folder name is stored in the decl name column
auto fullName = GetSelectedFullname();

auto otherMaterialsPrefix = MaterialPopulator::GetOtherMaterialsName() + "/";

return string::starts_with(fullName, otherMaterialsPrefix) ?
fullName.substr(otherMaterialsPrefix.length()) : fullName;
}

void MaterialTreeView::onMaterialCreated(const std::string& name)
{
auto populator = MaterialPopulator(Columns());
Expand Down
4 changes: 4 additions & 0 deletions radiant/ui/materials/MaterialTreeView.h
Expand Up @@ -37,6 +37,10 @@ class MaterialTreeView :

virtual void SetTreeMode(MaterialTreeView::TreeMode mode) override;

// Returns the name of the texture folder without any "Other Materials" prefix
// Returns an empty string if no folder is selected
std::string GetSelectedTextureFolderName();

// Loads all the materials
virtual void Populate();

Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/mediabrowser/MediaBrowser.cpp
Expand Up @@ -119,7 +119,7 @@ void MediaBrowser::onIdle()
{
// When a directory is selected, open the popup
auto popup = new wxutil::TransientPopupWindow(this);
auto browser = new TextureDirectoryBrowser(popup, _treeView->GetSelectedFullname());
auto browser = new TextureDirectoryBrowser(popup, _treeView->GetSelectedTextureFolderName());
popup->GetSizer()->Add(browser, 1, wxEXPAND | wxALL, 3);

// Size reaching from the upper edge of the mediabrowser to the bottom of the screen (minus a few pixels)
Expand Down

0 comments on commit fd000f8

Please sign in to comment.