mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update docs for #78 text update
This commit is contained in:
parent
4ef8316949
commit
94197391a5
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
# Druid components
|
||||
|
||||
|
||||
@ -42,7 +40,7 @@ _fill example usecases_
|
||||
Basic Druid text component. Text components by default have the text size adjusting.
|
||||
|
||||
### Setup
|
||||
Create text node with druid: `text = druid:new_text(node_name, [initial_value], [is_disable_size_adjust])`
|
||||
Create text node with druid: `text = druid:new_text(node_name, [initial_value], [text_adjust_type])`
|
||||
|
||||
### Notes
|
||||
- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. It can be disabled on component creating by settings argument `is_no_adjust` to _true_
|
||||
@ -53,6 +51,14 @@ Create text node with druid: `text = druid:new_text(node_name, [initial_value],
|
||||
|
||||

|
||||
|
||||
- There is several text adjust types. Default Downscale. You can change the default adjust type in the text style table.
|
||||
- **const.TEXT_ADJUST.DOWNSCALE** - Change text's scale to fit in the text node size
|
||||
- **const.TEXT_ADJUST.TRIM** - Trim the text with postfix (default - "...", override in styles) to fit in the text node size
|
||||
- **const.TEXT_ADJUST.NO_ADJUST** - No any adjust, like default Defold text node
|
||||
- **const.TEXT_ADJUST.DOWNSCALE_LIMITED** - Change text's scale list downscale, but there is limit for text's scale
|
||||
- **const.TEXT_ADJUST.SCROLL** - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect.
|
||||
- **const.TEXT_ADJUST.SCALE_THEN_SCROLL** - Combine two modes: first limited downscale, then scroll
|
||||
|
||||
|
||||
## Blocker
|
||||
[Blocker API here](https://insality.github.io/druid/modules/Blocker.html)
|
||||
|
@ -215,3 +215,11 @@ Have a good day.
|
||||
- **#112** Allow remap default Druid input bindings.
|
||||
- **#66** Add `druid:set_whitelist()` and `druid.set_blacklist()` functions. It's affects only on input process step, you can allow/forbid interact with list of specific components
|
||||
- **#125** Now `component:set_input_priority()` affects on all component's children too
|
||||
- **#78** Update Text component:
|
||||
- Add text adjust type instead of _no_adjust_ param.
|
||||
- const.TEXT_ADJUST.DOWNSCALE - Change text's scale to fit in the text node size
|
||||
- const.TEXT_ADJUST.TRIM - Trim the text with postfix (default - "...", override in styles) to fit in the text node size
|
||||
- const.TEXT_ADJUST.NO_ADJUST - No any adjust, like default Defold text node
|
||||
- const.TEXT_ADJUST.DOWNSCALE_LIMITED - Change text's scale list downscale, but there is limit for text's scale
|
||||
- const.TEXT_ADJUST.SCROLL - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect.
|
||||
- const.TEXT_ADJUST.SCALE_THEN_SCROLL - Combine two modes: first limited downscale, then scroll
|
@ -168,9 +168,11 @@ end
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=...] string TRIM_POSTFIX The postfix for TRIM adjust type
|
||||
-- @tfield[opt=DOWNSCALE] string DEFAULT_ADJUST The default adjust type for any text component
|
||||
function Text.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.TRIM_POSTFIX = style.TRIM_POSTFIX or "..."
|
||||
self.style.DEFAULT_ADJUST = style.DEFAULT_ADJUST or const.TEXT_ADJUST.DOWNSCALE
|
||||
end
|
||||
|
||||
|
||||
@ -192,7 +194,7 @@ function Text.init(self, node, value, adjust_type)
|
||||
self.text_area.x = self.text_area.x * self.start_scale.x
|
||||
self.text_area.y = self.text_area.y * self.start_scale.y
|
||||
|
||||
self.adjust_type = adjust_type or const.TEXT_ADJUST.DOWNSCALE
|
||||
self.adjust_type = adjust_type or self.style.DEFAULT_ADJUST
|
||||
self.color = gui.get_color(self.node)
|
||||
|
||||
self.on_set_text = Event()
|
||||
|
@ -1,3 +1,4 @@
|
||||
local const = require("druid.const")
|
||||
local settings = require("druid.system.settings")
|
||||
local anims = require("druid.styles.default.anims")
|
||||
|
||||
@ -131,7 +132,8 @@ M["input"] = {
|
||||
|
||||
|
||||
M["text"] = {
|
||||
TRIM_POSTFIX = "..."
|
||||
TRIM_POSTFIX = "...",
|
||||
DEFAULT_ADJUST = const.TEXT_ADJUST.DOWNSCALE
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user