From 97942965cde5eaff162dbccbfec3ae382f428d9a Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 28 May 2025 22:13:44 +0300 Subject: [PATCH] Remove colors from rich text --- druid/custom/rich_text/rich_text.lua | 2 -- druid/styles/default/style.lua | 8 ----- .../properties_panel/properties_panel.lua | 32 ++++++++++--------- test/tests/test_rich_text.lua | 10 +++--- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 1044d62..5ae422f 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -51,7 +51,6 @@ local rich_text = require("druid.custom.rich_text.module.rt") ---@field height number ---@class druid.rich_text.style ----@field COLORS table ---@field ADJUST_STEPS number ---@field ADJUST_SCALE_DELTA number @@ -105,7 +104,6 @@ end ---@param style druid.rich_text.style function M:on_style_change(style) self.style = { - COLORS = style.COLORS or {}, ADJUST_STEPS = style.ADJUST_STEPS or 20, ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02, } diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 08c3195..363fbac 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -148,12 +148,4 @@ M["hotkey"] = { } -M["rich_text"] = { - COLORS = { - white = "#FFFFFF", - black = "#000000" - } -} - - return M diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index b56bdd8..2176f6d 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -205,26 +205,28 @@ end function M:update(dt) - if self.is_dirty then - self.is_dirty = false + if not self.is_dirty then + return + end - self:clear_created_properties() + self.is_dirty = false - local properties_count = #self.properties_constructors + self:clear_created_properties() - -- Render all current properties - local start_index = (self.current_page - 1) * self.properties_per_page + 1 - local end_index = start_index + self.properties_per_page - 1 - end_index = math.min(end_index, properties_count) + local properties_count = #self.properties_constructors - local is_paginator_visible = properties_count > self.properties_per_page - gui.set_enabled(self.paginator.root, is_paginator_visible) - self.paginator:set_number_type(1, math.ceil(properties_count / self.properties_per_page), true) - self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(properties_count / self.properties_per_page)) + -- Render all current properties + local start_index = (self.current_page - 1) * self.properties_per_page + 1 + local end_index = start_index + self.properties_per_page - 1 + end_index = math.min(end_index, properties_count) - for index = start_index, end_index do - self.properties_constructors[index]() - end + local is_paginator_visible = properties_count > self.properties_per_page + gui.set_enabled(self.paginator.root, is_paginator_visible) + self.paginator:set_number_type(1, math.ceil(properties_count / self.properties_per_page), true) + self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(properties_count / self.properties_per_page)) + + for index = start_index, end_index do + self.properties_constructors[index]() end end diff --git a/test/tests/test_rich_text.lua b/test/tests/test_rich_text.lua index 0e4ad0d..d37d819 100644 --- a/test/tests/test_rich_text.lua +++ b/test/tests/test_rich_text.lua @@ -81,7 +81,7 @@ return function() local rich_text = druid:new_rich_text(text_node) -- Test color tag with named color - local words = rich_text:set_text("Colored Text") + local words = rich_text:set_text("Colored Text") assert(#words > 0) -- Word should have a tags field with color tag @@ -104,7 +104,7 @@ return function() local rich_text = druid:new_rich_text(text_node) -- Test shadow tag with named color - local words = rich_text:set_text("Shadowed Text") + local words = rich_text:set_text("Shadowed Text") assert(#words > 0) assert(words[1].shadow ~= nil) @@ -129,7 +129,7 @@ return function() local rich_text = druid:new_rich_text(text_node) -- Test outline tag with named color - local words = rich_text:set_text("Outlined Text") + local words = rich_text:set_text("Outlined Text") assert(#words > 0) assert(words[1].outline ~= nil) @@ -228,7 +228,7 @@ return function() local rich_text = druid:new_rich_text(text_node) -- Test combined tags - local words = rich_text:set_text("Big Red Text") + local words = rich_text:set_text("Big Red Text") assert(#words > 0) assert(words[1].tags.color) @@ -236,7 +236,7 @@ return function() assert(words[1].relative_scale == 2) -- Test nested tags - words = rich_text:set_text("Red Big Red Red") + words = rich_text:set_text("Red Big Red Red") assert(#words >= 3) -- All words should have color tag