Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambdas for widgets states/flags #65

Open
nagyrobi opened this issue Feb 9, 2024 · 1 comment
Open

Lambdas for widgets states/flags #65

nagyrobi opened this issue Feb 9, 2024 · 1 comment

Comments

@nagyrobi
Copy link

nagyrobi commented Feb 9, 2024

To make complex automations, we need some easily usable lambdas to get the states and flags of the widgets. These are all booleans so their usage in conditions as lambdas would be very easy.

Use case:

      - if:
          condition:
            lambda: |-
              return id(my_widget).state.checked; #or id(my_widget).flag.hidden;
          then:
            -  do.something

States:

  • default (Optional, boolean): Normal, released state
  • disabled (Optional, boolean): Disabled state
  • pressed (Optional, boolean): Being pressed
  • checked (Optional, boolean): Toggled or checked state
  • scrolled (Optional, boolean): Being scrolled
  • focused (Optional, boolean): Focused via keypad or encoder or clicked via touchpad/mouse
  • focus_key (Optional, boolean): Focused via keypad or encoder but not via touchpad/mouse
  • edited (Optional, boolean): Edit by an encoder
  • user_1, user_2, user_3, user_4 (Optional, boolean): Custom states

Flags:

  • hidden (Optional, boolean): make the widget hidden (like it wasn't there at all),
  • checkable (Optional, boolean): toggle checked state when the widget is clicked
  • clickable (Optional, boolean): make the widget clickable by input devices.
  • click_focusable (Optional, boolean): add focused state to the widget when clicked
  • scrollable (Optional, boolean): make the widget scrollable
  • scroll_elastic (Optional, boolean): allow scrolling inside but with slower speed
  • scroll_momentum (Optional, boolean): make the widget scroll further when "thrown"
  • scroll_one (Optional, boolean): allow scrolling only one snappable children
  • scroll_chain_hor (Optional, boolean): allow propagating the horizontal scroll to a parent
  • scroll_chain_ver (Optional, boolean): allow propagating the vertical scroll to a parent
  • scroll_chain simple (Optional, boolean): packaging for (scroll_chain_hor | scroll_chain_ver)
  • scroll_on_focus (Optional, boolean): automatically scroll widget to make it visible when focused
  • scroll_with_arrow (Optional, boolean): allow scrolling the focused widget with arrow keys
  • snappable (Optional, boolean): if scroll snap is enabled on the parent it can snap to this widget
  • press_lock (Optional, boolean): keep the widget pressed even if the press slid from the widget
  • event_bubble (Optional, boolean): propagate the events to the parent too
  • gesture_bubble (Optional, boolean): propagate the gestures to the parent
  • adv_hittest (Optional, boolean): allow performing more accurate hit (click) test. E.g. Accounting for rounded corners
  • ignore_layout (Optional, boolean): make the widget positionable by the layouts
  • floating (Optional, boolean): do not scroll the widget when the parent scrolls and ignore layout
  • overflow_visible (Optional, boolean): do not clip the children's content to the parent's boundary
  • layout_1, layout_2 (Optional, boolean): custom flags, free to use by layouts
  • widget_1, widget_2 (Optional, boolean): custom flags, free to use by widget
  • user_1, user_2, user_3, user_4 (Optional, boolean): custom flags, free to use by user
@nagyrobi nagyrobi changed the title Lambdas for widgets states Lambdas for widgets states/flags Feb 9, 2024
@clydebarrow
Copy link
Owner

This is already possible by using lvgl functions, e.g.

            !lambda return lv_obj_get_state(id(pendant_lights)) & LV_STATE_CHECKED;

Some nicer syntax might be possible in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants