6.6 KiB
Druid components
Button
Overview
Basic Druid input component. Handle input on node and provide different callbacks on touch events.
Setup
Create button with druid: button = druid:new_button(node_name, callback, [params], [animation_node])
Where node name is name of node from GUI scene. You can use node_name
as input trigger zone and point another node for animation via animation_node
Notes
- Button callback have next params: (self, params, button_instance)
- self - Druid self context
- params - Additional params, specified on button creating
- button_instance - button itself
- You can set params on button callback on button creating:
druid:new_button("node_name", callback, params)
. This params will pass in callback as second argument - Button have next events:
- on_click - basic button callback
- on_repeated_click - repeated click callback, while holding the button, don't trigger if callback is empty
- on_long_click - callback on long button tap, don't trigger if callback is empty
- on_hold_click - hold callback, before long_click trigger, don't trigger if callback is empty
- on_double_click - different callback, if tap button 2+ in row, don't trigger if callback is empty
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use
button:set_click_zone
to restrict button click zone - Button can have key trigger to use then by key:
button:set_key_trigger
- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be
big panel
and animation node will besmall icon
Text
Overview
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])
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
- Text pivot can be changed with
text:set_pivot
, and text will save their position inside their text size box:
Blocker
Overview
Druid component for block input. Use it to block input in special zone.
Setup
Create blocker component with druid: druid:new_blocker(node_name)
Notes
Blue zone is button with close_window callback
Yellow zone is blocker with window content
So you can do the safe zones, when you have the big buttons
Back Handler
Overview
Component to handle back button. It handle Android back button and Backspace key. Key triggers in input.binding
should be setup for correct working.
Setup
Setup callback on back button with druid:new_back_handler(callback)
Notes
Lang text
Overview
Wrap on Text component to handle localization. It uses druid get_text_function to set text by it's id
Setup
Create lang text component with druid text = druid:new_lang_text(node_name, locale_id)
Notes
Scroll
Overview
Basic Druid scroll component. Handle all scrolling stuff in druid GUI
Setup
Create scroll component with druid: scroll = druid:new_scroll(scroll_parent, scroll_input)
.
Scroll parent - is dynamic part. This node will change position by scroll system
Scroll input - is static part. It capturing user input and recognize scrolling touches
Initial scroll size will be equal to scroll parent node size. The initial view box will be equal to scroll input node size
Notes
Progress
Overview
Basic Druid progress bar component
Setup
Create progress bar component with druid: progress = druid:new_progress(node_name, key, init_value)
Node name should have maximum node size, so in GUI scene, node_name should be fully filled. Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or just "y")
Notes
- Progress correct working with 9slice nodes, it trying to set size by set_size first, if it is not possible, it set up sizing via set_scale
- Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene
Slider
Overview
Basic Druid slider component
Setup
Create slider component with druid: slider = druid:new_slider(node_name, end_pos, callback)
Pin node (node_name in params) should be placed in zero position (initial). It will be available to mode Pin node between start pos and end pos.
Notes
- You can setup points of interests on slider via
slider:set_steps
. If steps are exist, slider values will be only from this steps (notched slider) - For now, start pos and end pos should be on vertical or horizontal line (their x or y value should be equal)
Input
Overview
Basic Druid text input component (unimplemented)
Setup
Notes
Checkbox
Overview
Basic Druid checkbox component
Setup
Notes
Checkbox group
Overview
Several checkboxes in one group
Setup
Notes
Radio group
Overview
Several checkboxes in one group with single choice
Setup
Notes
Timer
Overview
Handle timer work on gui text node
Setup
Notes
Grid
Overview
Component for manage node positions
Setup
Notes
Hover
Overview
System Druid component, handle hover node state