mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Remove colors from rich text
This commit is contained in:
parent
0cf5ba30db
commit
97942965cd
@ -51,7 +51,6 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
|||||||
---@field height number
|
---@field height number
|
||||||
|
|
||||||
---@class druid.rich_text.style
|
---@class druid.rich_text.style
|
||||||
---@field COLORS table<string, vector4>
|
|
||||||
---@field ADJUST_STEPS number
|
---@field ADJUST_STEPS number
|
||||||
---@field ADJUST_SCALE_DELTA number
|
---@field ADJUST_SCALE_DELTA number
|
||||||
|
|
||||||
@ -105,7 +104,6 @@ end
|
|||||||
---@param style druid.rich_text.style
|
---@param style druid.rich_text.style
|
||||||
function M:on_style_change(style)
|
function M:on_style_change(style)
|
||||||
self.style = {
|
self.style = {
|
||||||
COLORS = style.COLORS or {},
|
|
||||||
ADJUST_STEPS = style.ADJUST_STEPS or 20,
|
ADJUST_STEPS = style.ADJUST_STEPS or 20,
|
||||||
ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02,
|
ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02,
|
||||||
}
|
}
|
||||||
|
@ -148,12 +148,4 @@ M["hotkey"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
M["rich_text"] = {
|
|
||||||
COLORS = {
|
|
||||||
white = "#FFFFFF",
|
|
||||||
black = "#000000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -205,7 +205,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function M:update(dt)
|
function M:update(dt)
|
||||||
if self.is_dirty then
|
if not self.is_dirty then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
self.is_dirty = false
|
self.is_dirty = false
|
||||||
|
|
||||||
self:clear_created_properties()
|
self:clear_created_properties()
|
||||||
@ -226,7 +229,6 @@ function M:update(dt)
|
|||||||
self.properties_constructors[index]()
|
self.properties_constructors[index]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
---@param on_create fun(checkbox: druid.widget.property_checkbox)|nil
|
---@param on_create fun(checkbox: druid.widget.property_checkbox)|nil
|
||||||
|
@ -81,7 +81,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test color tag with named color
|
-- Test color tag with named color
|
||||||
local words = rich_text:set_text("<color=red>Colored Text</color>")
|
local words = rich_text:set_text("<color=#FF0000>Colored Text</color>")
|
||||||
|
|
||||||
assert(#words > 0)
|
assert(#words > 0)
|
||||||
-- Word should have a tags field with color tag
|
-- Word should have a tags field with color tag
|
||||||
@ -104,7 +104,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test shadow tag with named color
|
-- Test shadow tag with named color
|
||||||
local words = rich_text:set_text("<shadow=black>Shadowed Text</shadow>")
|
local words = rich_text:set_text("<shadow=#000000>Shadowed Text</shadow>")
|
||||||
|
|
||||||
assert(#words > 0)
|
assert(#words > 0)
|
||||||
assert(words[1].shadow ~= nil)
|
assert(words[1].shadow ~= nil)
|
||||||
@ -129,7 +129,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test outline tag with named color
|
-- Test outline tag with named color
|
||||||
local words = rich_text:set_text("<outline=black>Outlined Text</outline>")
|
local words = rich_text:set_text("<outline=#000000>Outlined Text</outline>")
|
||||||
|
|
||||||
assert(#words > 0)
|
assert(#words > 0)
|
||||||
assert(words[1].outline ~= nil)
|
assert(words[1].outline ~= nil)
|
||||||
@ -228,7 +228,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test combined tags
|
-- Test combined tags
|
||||||
local words = rich_text:set_text("<color=red><size=2>Big Red Text</size></color>")
|
local words = rich_text:set_text("<color=#FF0000><size=2>Big Red Text</size></color>")
|
||||||
|
|
||||||
assert(#words > 0)
|
assert(#words > 0)
|
||||||
assert(words[1].tags.color)
|
assert(words[1].tags.color)
|
||||||
@ -236,7 +236,7 @@ return function()
|
|||||||
assert(words[1].relative_scale == 2)
|
assert(words[1].relative_scale == 2)
|
||||||
|
|
||||||
-- Test nested tags
|
-- Test nested tags
|
||||||
words = rich_text:set_text("<color=red>Red <size=2>Big Red</size> Red</color>")
|
words = rich_text:set_text("<color=#FF0000>Red <size=2>Big Red</size> Red</color>")
|
||||||
|
|
||||||
assert(#words >= 3)
|
assert(#words >= 3)
|
||||||
-- All words should have color tag
|
-- All words should have color tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user