diff --git a/docs/overview/style.md b/docs/overview/style.md index 4ab6f3773..18d2f92e0 100644 --- a/docs/overview/style.md +++ b/docs/overview/style.md @@ -184,11 +184,11 @@ To remove specific styles use `lv_obj_remoev_style(obj, style, selector)`. This ### Report style changes -If a style - which is already assigned to object - changes (i.e. one of it's property is set to a new value) the objects using that style should be notified. There are 3 options to do this: -1. If you know that the changed properties can be applied by a simple (e.g. color or opacity changes) redraw just call `lv_obj_invalidate(obj)`, `lv_obj_invalideate(lv_scr_act())`. -2. If something more complex change happened on a style and you know which object(s) are affected by that style call `lv_obj_refresh_style(obj, part, property)`. +If a style which is already assigned to object changes (i.e. a property is added or changed) the objects using that style should be notified. There are 3 options to do this: +1. If you know that the changed properties can be applied by a simple redraw (e.g. color or opacity changes) just call `lv_obj_invalidate(obj)` or `lv_obj_invalideate(lv_scr_act())`. +2. If more complex style properties were changed or added, and you know which object(s) are affected by that style call `lv_obj_refresh_style(obj, part, property)`. To refresh all parts and properties use `lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY)`. -3. No make LVGL check all object whether thy use the style and refresh them use `lv_obj_report_style_change(&style)`. If `style` is `NULL` all object's will be notified. +3. No make LVGL check all object whether they use the style and refresh them call `lv_obj_report_style_change(&style)`. If `style` is `NULL` all object's will be notified about the style change. ### Get a property's value on an object To get a final value of property - considering cascading, inheritance, local styles and transitions (see below) - get functions like this can be used: diff --git a/docs/widgets/obj.md b/docs/widgets/obj.md index 1b0254f55..0626429a2 100644 --- a/docs/widgets/obj.md +++ b/docs/widgets/obj.md @@ -85,45 +85,46 @@ To manually send an event to an object, use `lv_event_send(obj, LV_EVENT_..., pa Read the [Event overview](/overview/event) to learn more about the events. -### Style +### Styles Be sure to read the [Style overview](/overview/style). Here or only the most essential functions are described. -A new style can be added to an object with `lv_obj_add_style(obj, part, &new_style)` function. The Base object use all the rectangle-like style properties. +A new style can be added to an object with `lv_obj_add_style(obj, &new_style, selector)` function. +`selector` is a combination of part and state(s). E.g. `LV_PART_SCROLLBAR | LV_STATE_PRESSED`. + +The Base object use `LV_PART_MAIN` style properties and `LV_PART_SCROLLBAR` with the typical backgroud style proeprties. -If you modify a style, which is already used by objects, in order to refresh the affected objects you can use either `lv_obj_refresh_style(obj)` on each object using it or - notify all objects with a given style use `lv_obj_report_style_change(&style)`. If the parameter of `lv_obj_report_style_change` is `NULL`, all objects will be notified. ### Flags There are some attributes which can be enabled/disabled by `lv_obj_add/clear_flag(obj, LV_OBJ_FLAG_...)`: --`LV_OBJ_FLAG_HIDDEN` Make the object hidden. (Like it wasn't there at all) --`LV_OBJ_FLAG_CLICKABLE` Make the object clickable by the input devices --`LV_OBJ_FLAG_CLICK_FOCUSABLE` Add focused state to the object when clicked --`LV_OBJ_FLAG_CHECKABLE` Toggle checked state when the object is clicked --`LV_OBJ_FLAG_SCROLLABLE` Make the object scrollable --`LV_OBJ_FLAG_SCROLL_ELASTIC` Allow scrolling inside but with slower speed --`LV_OBJ_FLAG_SCROLL_MOMENTUM` Make the object scroll further when "thrown" --`LV_OBJ_FLAG_SCROLL_ONE`Allow scrolling only one snapable children --`LV_OBJ_FLAG_SCROLL_CHAIN` Allow propagating the scroll to a parent --`LV_OBJ_FLAG_SCROLL_ON_FOCUS` Automatically scroll object to make it visible when focused --`LV_OBJ_FLAG_SNAPABLE` If scroll snap is enabled on the parent it can snap to this object --`LV_OBJ_FLAG_PRESS_LOCK` Keep the object pressed even if the press slid from the object --`LV_OBJ_FLAG_EVENT_BUBBLE` Propagate the events to the parent too --`LV_OBJ_FLAG_GESTURE_BUBBLE` Propagate the gestures to the parent --`LV_OBJ_FLAG_ADV_HITTEST` Allow performing more accurate hit (click) test. E.g. consider rounded corners. --`LV_OBJ_FLAG_IGNORE_LAYOUT` Make the object position-able by the layouts --`LV_OBJ_FLAG_FLOATING` Do not scroll the object when the parent scrolls and ignore layout +- `LV_OBJ_FLAG_HIDDEN` Make the object hidden. (Like it wasn't there at all) +- `LV_OBJ_FLAG_CLICKABLE` Make the object clickable by the input devices +- `LV_OBJ_FLAG_CLICK_FOCUSABLE` Add focused state to the object when clicked +- `LV_OBJ_FLAG_CHECKABLE` Toggle checked state when the object is clicked +- `LV_OBJ_FLAG_SCROLLABLE` Make the object scrollable +- `LV_OBJ_FLAG_SCROLL_ELASTIC` Allow scrolling inside but with slower speed +- `LV_OBJ_FLAG_SCROLL_MOMENTUM` Make the object scroll further when "thrown" +- `LV_OBJ_FLAG_SCROLL_ONE`Allow scrolling only one snapable children +- `LV_OBJ_FLAG_SCROLL_CHAIN` Allow propagating the scroll to a parent +- `LV_OBJ_FLAG_SCROLL_ON_FOCUS` Automatically scroll object to make it visible when focused +- `LV_OBJ_FLAG_SNAPABLE` If scroll snap is enabled on the parent it can snap to this object +- `LV_OBJ_FLAG_PRESS_LOCK` Keep the object pressed even if the press slid from the object +- `LV_OBJ_FLAG_EVENT_BUBBLE` Propagate the events to the parent too +- `LV_OBJ_FLAG_GESTURE_BUBBLE` Propagate the gestures to the parent +- `LV_OBJ_FLAG_ADV_HITTEST` Allow performing more accurate hit (click) test. E.g. consider rounded corners. +- `LV_OBJ_FLAG_IGNORE_LAYOUT` Make the object position-able by the layouts +- `LV_OBJ_FLAG_FLOATING` Do not scroll the object when the parent scrolls and ignore layout --`LV_OBJ_FLAG_LAYOUT_1` Custom flag, free to use by layouts --`LV_OBJ_FLAG_LAYOUT_2` Custom flag, free to use by layouts +- `LV_OBJ_FLAG_LAYOUT_1` Custom flag, free to use by layouts +- `LV_OBJ_FLAG_LAYOUT_2` Custom flag, free to use by layouts --`LV_OBJ_FLAG_WIDGET_1` Custom flag, free to use by widget --`LV_OBJ_FLAG_WIDGET_2` Custom flag, free to use by widget +- `LV_OBJ_FLAG_WIDGET_1` Custom flag, free to use by widget +- `LV_OBJ_FLAG_WIDGET_2` Custom flag, free to use by widget --`LV_OBJ_FLAG_USER_1` Custom flag, free to use by user --`LV_OBJ_FLAG_USER_2` Custom flag, free to use by user --`LV_OBJ_FLAG_USER_3` Custom flag, free to use by user --`LV_OBJ_FLAG_USER_4` Custom flag, free to use by usersection. +- `LV_OBJ_FLAG_USER_1` Custom flag, free to use by user +- `LV_OBJ_FLAG_USER_2` Custom flag, free to use by user +- `LV_OBJ_FLAG_USER_3` Custom flag, free to use by user +- `LV_OBJ_FLAG_USER_4` Custom flag, free to use by usersection. Some examples: ```c