From 50f70a8bb42fc982350731da104b042ae75b1df2 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 10 May 2021 14:33:37 +1000 Subject: Add elementBaseColours to hold default or system derived colours. Editor::UpdateBaseElements can be overridden by platform layers to set base colours although they should also do this when they detect changes in system settings. --- src/ViewStyle.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/ViewStyle.cxx') diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 58af810b8..16701983e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -523,6 +523,12 @@ std::optional ViewStyle::ElementColour(int element) const { return search->second; } } + ElementMap::const_iterator searchBase = elementBaseColours.find(element); + if (searchBase != elementBaseColours.end()) { + if (searchBase->second.has_value()) { + return searchBase->second; + } + } return {}; } @@ -530,6 +536,32 @@ bool ViewStyle::ElementAllowsTranslucent(int element) const { return elementAllowsTranslucent.count(element) > 0; } +void ViewStyle::ResetElement(int element) { + elementColours.erase(element); +} + +bool ViewStyle::ElementIsSet(int element) const { + ElementMap::const_iterator search = elementColours.find(element); + if (search != elementColours.end()) { + return search->second.has_value(); + } + return false; +} + +bool ViewStyle::SetElementBase(int element, ColourAlpha colour) { + bool different = false; + ElementMap::const_iterator search = elementBaseColours.find(element); + if (search == elementBaseColours.end()) { + different = true; + } else { + if (search->second.has_value() && !(*search->second == colour)) { + different = true; + } + } + elementBaseColours[element] = colour; + return different; +} + bool ViewStyle::SetWrapState(int wrapState_) noexcept { WrapMode wrapStateWanted; switch (wrapState_) { -- cgit v1.2.3