Skip to content

Commit

Permalink
#5613: Display the ambiguous values in italics (if supported)
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 17, 2021
1 parent f349ecc commit b9d5317
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
13 changes: 13 additions & 0 deletions libs/wxutil/dataview/TreeViewItemStyle.h
Expand Up @@ -88,6 +88,12 @@ class TreeViewItemStyle
SetStrikethrough(attr, true);
}

static void ApplyKeyValueAmbiguousStyle(wxDataViewItemAttr& attr)
{
attr.SetColour(wxColour(80, 80, 80));
SetItalic(attr, true);
}

static void ApplyKeyValueConflictStyle(wxDataViewItemAttr& attr)
{
if (SupportsBackgroundColour())
Expand All @@ -108,6 +114,13 @@ class TreeViewItemStyle
#endif
}

static void SetItalic(wxDataViewItemAttr& attr, bool enabled)
{
#if wxCHECK_VERSION(3, 1, 2)
attr.SetItalic(enabled);
#endif
}

private:

// Returns true if wxWidgets supports setting the background colour of items
Expand Down
15 changes: 11 additions & 4 deletions radiant/ui/einspector/EntityInspector.cpp
Expand Up @@ -205,7 +205,7 @@ void EntityInspector::onKeyInsert(const std::string& key,
//onKeyChange(key, value.get());
}

void EntityInspector::onKeyChange(const std::string& key, const std::string& value)
void EntityInspector::onKeyChange(const std::string& key, const std::string& value, bool isMultiValue)
{
wxDataViewItem keyValueIter;
bool added = false;
Expand Down Expand Up @@ -336,9 +336,16 @@ void EntityInspector::onKeyChange(const std::string& key, const std::string& val

// Apply background style to all other columns
row[_columns.name] = style;
row[_columns.value] = style;
row[_columns.booleanValue] = style;

// Before applying the style to the value, check if the value is ambiguous
if (isMultiValue)
{
wxutil::TreeViewItemStyle::ApplyKeyValueAmbiguousStyle(style);
}

row[_columns.value] = style;

row[_columns.isInherited] = false;
row[_columns.hasHelpText] = key == "classname" || hasDescription; // classname always has a description

Expand Down Expand Up @@ -514,12 +521,12 @@ void EntityInspector::onKeyRemoved(const std::string& key)

void EntityInspector::onKeyValueSetChanged(const std::string& key, const std::string& uniqueValue)
{
onKeyChange(key, uniqueValue.empty() ? _("[differing values]") : uniqueValue);
onKeyChange(key, uniqueValue.empty() ? _("[differing values]") : uniqueValue, uniqueValue.empty());
}

void EntityInspector::onUndoRedoOperation()
{
refresh();
//refresh();
}

void EntityInspector::onDefsReloaded()
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/einspector/EntityInspector.h
Expand Up @@ -287,7 +287,7 @@ class EntityInspector final :
void onMainFrameShuttingDown();

void onKeyInsert(const std::string& key, EntityKeyValue& value);
void onKeyChange(const std::string& key, const std::string& value);
void onKeyChange(const std::string& key, const std::string& value, bool isMultiValue = false);
void onKeyErase(const std::string& key, EntityKeyValue& value);

// greebo: Tells the inspector to reload the window settings from the registry.
Expand Down

0 comments on commit b9d5317

Please sign in to comment.