Skip to content

Commit

Permalink
#6107: Active layer is using bold style
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 25, 2022
1 parent 104080e commit eecf59f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
8 changes: 8 additions & 0 deletions libs/wxutil/dataview/TreeViewItemStyle.h
Expand Up @@ -53,6 +53,14 @@ class TreeViewItemStyle
return italic;
}

static wxDataViewItemAttr ActiveItemStyle()
{
wxDataViewItemAttr bold;
bold.SetBold(true);

return bold;
}

// Styles used by the merge action visualisation in data views

static void ApplyKeyValueAddedStyle(wxDataViewItemAttr& attr)
Expand Down
29 changes: 20 additions & 9 deletions radiant/ui/layers/LayerControlDialog.cpp
Expand Up @@ -12,11 +12,11 @@
#include <wx/panel.h>
#include <wx/artprov.h>

#include "wxutil/ScrollWindow.h"
#include "wxutil/Button.h"

#include "scene/LayerUsageBreakdown.h"
#include "wxutil/dataview/TreeView.h"
#include "wxutil/dataview/TreeViewItemStyle.h"

namespace ui
{
Expand Down Expand Up @@ -104,19 +104,26 @@ void LayerControlDialog::refresh()

// Traverse the layers
auto& layerManager = GlobalMapModule().getRoot()->getLayerManager();
auto activeLayerId = layerManager.getActiveLayer();

layerManager.foreachLayer([&](int layerID, const std::string& layerName)
layerManager.foreachLayer([&](int layerId, const std::string& layerName)
{
// Store the object in a sorted container
auto row = _layerStore->AddItem();

row[_columns.id] = layerID;
row[_columns.id] = layerId;
row[_columns.name] = layerName;
row[_columns.visible] = layerManager.layerIsVisible(layerID);

if (activeLayerId == layerId)
{
row[_columns.name] = wxutil::TreeViewItemStyle::ActiveItemStyle();
}

row[_columns.visible] = layerManager.layerIsVisible(layerId);

row.SendItemAdded();

_layerItemMap.emplace(layerID, row.getItem());
_layerItemMap.emplace(layerId, row.getItem());
});

#if 0
Expand Down Expand Up @@ -146,7 +153,8 @@ void LayerControlDialog::update()
return;
}

auto& layerSystem = GlobalMapModule().getRoot()->getLayerManager();
auto& layerManager = GlobalMapModule().getRoot()->getLayerManager();
auto activeLayerId = layerManager.getActiveLayer();

// Update usage next time round
_rescanSelectionOnIdle = true;
Expand All @@ -155,17 +163,20 @@ void LayerControlDialog::update()
std::size_t numVisible = 0;
std::size_t numHidden = 0;

layerSystem.foreachLayer([&](int layerID, const std::string& layerName)
layerManager.foreachLayer([&](int layerId, const std::string& layerName)
{
auto existingItem = _layerItemMap.find(layerID);
auto existingItem = _layerItemMap.find(layerId);

if (existingItem == _layerItemMap.end()) return; // tracking error?

wxutil::TreeModel::Row row(existingItem->second, *_layerStore);

row[_columns.name] = layerName;

if (layerSystem.layerIsVisible(layerID))
row[_columns.name] = activeLayerId == layerId ?
wxutil::TreeViewItemStyle::ActiveItemStyle() : wxDataViewItemAttr(); // no style

if (layerManager.layerIsVisible(layerId))
{
row[_columns.visible] = true;
numVisible++;
Expand Down

0 comments on commit eecf59f

Please sign in to comment.