diff options
-rw-r--r-- | src/Editor.cxx | 2 | ||||
-rw-r--r-- | src/Geometry.h | 4 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 16 | ||||
-rw-r--r-- | test/simpleTests.py | 33 |
4 files changed, 54 insertions, 1 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index e6a31f11a..17749d799 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7200,7 +7200,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETELEMENTCOLOUR: - return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourAlpha()).OpaqueRGB(); + return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourAlpha()).AsInteger(); case SCI_RESETELEMENTCOLOUR: vs.ResetElement(static_cast<int>(wParam)); diff --git a/src/Geometry.h b/src/Geometry.h index e9cb5a6c8..01af92969 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -187,6 +187,10 @@ public: return ColourAlpha(co | (0xffu << 24)); } + constexpr int AsInteger() const noexcept { + return co; + } + constexpr int OpaqueRGB() const noexcept { return co & 0xffffff; } diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index ed08ad6ce..4d555b1c2 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -206,6 +206,17 @@ void ViewStyle::Init(size_t stylesSize_) { elementBaseColours[SC_ELEMENT_SELECTION_ADDITIONAL_BACK] = ColourAlpha(0xd7, 0xd7, 0xd7, 0xff); elementBaseColours[SC_ELEMENT_SELECTION_SECONDARY_BACK] = ColourAlpha(0xb0, 0xb0, 0xb0, 0xff); elementBaseColours[SC_ELEMENT_SELECTION_NO_FOCUS_BACK] = ColourAlpha(0x80, 0x80, 0x80, 0x3f); + elementAllowsTranslucent.insert({ + SC_ELEMENT_SELECTION_TEXT, + SC_ELEMENT_SELECTION_BACK, + SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, + SC_ELEMENT_SELECTION_ADDITIONAL_BACK, + SC_ELEMENT_SELECTION_SECONDARY_TEXT, + SC_ELEMENT_SELECTION_SECONDARY_BACK, + SC_ELEMENT_SELECTION_NO_FOCUS_TEXT, + SC_ELEMENT_SELECTION_BACK, + SC_ELEMENT_SELECTION_NO_FOCUS_BACK, + }); selection.layer = Layer::base; selection.eolFilled = false; @@ -224,6 +235,11 @@ void ViewStyle::Init(size_t stylesSize_) { elementBaseColours[SC_ELEMENT_CARET] = ColourAlpha(0, 0, 0); elementBaseColours[SC_ELEMENT_CARET_ADDITIONAL] = ColourAlpha(0x7f, 0x7f, 0x7f); elementBaseColours[SC_ELEMENT_CARET_SECONDARY] = ColourAlpha(0, 0, 0, 0x40); + elementAllowsTranslucent.insert({ + SC_ELEMENT_CARET, + SC_ELEMENT_CARET_ADDITIONAL, + SC_ELEMENT_CARET_SECONDARY, + }); caret.style = CARETSTYLE_LINE; caret.width = 1; diff --git a/test/simpleTests.py b/test/simpleTests.py index 63efc8019..d6c00170c 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -1923,6 +1923,39 @@ class TestStyleAttributes(unittest.TestCase): self.ed.FontLocale = testLocale self.assertEquals(self.ed.GetFontLocale(), testLocale) +class TestElements(unittest.TestCase): + """ These tests are just to ensure that the calls set and retrieve values. + They do not check the visual appearance of the style attributes. + """ + def setUp(self): + self.xite = Xite.xiteFrame + self.ed = self.xite.ed + self.ed.ClearAll() + self.ed.EmptyUndoBuffer() + self.testColourAlpha = 0x18171615 + + def tearDown(self): + pass + + def testIsSet(self): + self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST), 0) + + def testAllowsTranslucent(self): + self.assertEquals(self.ed.GetElementAllowsTranslucent(self.ed.SC_ELEMENT_LIST), 0) + self.assertEquals(self.ed.GetElementAllowsTranslucent(self.ed.SC_ELEMENT_SELECTION_TEXT), 1) + + def testChanging(self): + self.ed.SetElementColour(self.ed.SC_ELEMENT_LIST_BACK, self.testColourAlpha) + self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_LIST_BACK), self.testColourAlpha) + self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST_BACK), 1) + + def testReset(self): + self.ed.SetElementColour(self.ed.SC_ELEMENT_LIST_BACK, self.testColourAlpha) + self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_LIST_BACK), self.testColourAlpha) + self.ed.ResetElementColour(self.ed.SC_ELEMENT_LIST_BACK) + self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_LIST_BACK), 0) + self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST_BACK), 0) + class TestIndices(unittest.TestCase): def setUp(self): self.xite = Xite.xiteFrame |