Scrolls through a sequence of layouts, swapping to the previous or next at the ends.
More...
|
| typedef LayoutLayer *(* | SwapLayerGetLayoutHandler) (struct SwapLayer *swap_layer, int8_t rel_position, void *context) |
| | Get a layout relative to the current one.
|
| |
| typedef void(* | SwapLayerLayoutRemovedHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, void *context) |
| | Called when the swap layer no longer uses a layout; the client may destroy it.
|
| |
| typedef void(* | SwapLayerLayoutDidAppearHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, int8_t rel_change, void *context) |
| | Called when a layout has become the current one.
|
| |
| typedef void(* | SwapLayerLayoutWillAppearHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, void *context) |
| | Called when a layout is about to become the current one.
|
| |
| typedef void(* | SwapLayerUpdateColorsHandler) (struct SwapLayer *swap_layer, GColor bg_color, bool status_bar_filled, void *context) |
| | Called when the window colors should change to match the visible layout.
|
| |
| typedef void(* | SwapLayerInteractionHandler) (struct SwapLayer *swap_layer, void *context) |
| | Called on every user interaction, e.g.
|
| |
Scrolls through a sequence of layouts, swapping to the previous or next at the ends.
Used by the notification window. The SwapLayer holds the previous, current and next layouts, which the client supplies on demand through SwapLayerCallbacks::get_layout_handler and destroys in SwapLayerCallbacks::layout_removed_handler. Up and down scroll the current layout and swap to the neighbor once its end is reached.
◆ SwapLayerCallbacks
| struct SwapLayerCallbacks |
◆ ArrowLayer
Layer drawing the arrow hinting at more content.
| Data Fields |
|
GBitmap |
arrow_bitmap |
Arrow image. |
|
Layer |
layer |
Layer. |
◆ SwapLayer
Data structure of a SwapLayer.
- Note
- A SwapLayer can be cast to a Layer and used with all functions that take one, e.g.
...
layer_set_hidden((Layer *)&swap_layer, true);
Data structure of a SwapLayer.
Definition swap_layer.h:127
| Data Fields |
|
Animation * |
animation |
Scroll or swap animation in progress. |
|
ArrowLayer |
arrow_layer |
Arrow hinting at more content. |
|
SwapLayerCallbacks |
callbacks |
Callbacks. |
|
void * |
context |
Callback context. |
|
LayoutLayer * |
current |
Current layout. |
|
bool |
is_deiniting |
The swap layer is being deinitialized. |
|
Layer |
layer |
Root layer. |
|
LayoutLayer * |
next |
Next layout. |
|
LayoutLayer * |
previous |
Previous layout. |
|
uint16_t |
swap_delay_remaining |
Repeated clicks left before a held button swaps to the next layout. |
|
bool |
swap_in_progress |
A swap is in progress. |
◆ SwapLayerGetLayoutHandler
| typedef LayoutLayer *(* SwapLayerGetLayoutHandler) (struct SwapLayer *swap_layer, int8_t rel_position, void *context) |
Get a layout relative to the current one.
- Parameters
-
| swap_layer | Swap layer. |
| rel_position | Offset from the current layout, which the client keeps track of: -1 for the previous, 0 for the current, 1 for the next. |
| context | Callback context. |
- Returns
- Layout, or NULL if there is none at that position.
◆ SwapLayerInteractionHandler
| typedef void(* SwapLayerInteractionHandler) (struct SwapLayer *swap_layer, void *context) |
Called on every user interaction, e.g.
to restart an inactivity timer.
- Parameters
-
| swap_layer | Swap layer. |
| context | Callback context. |
◆ SwapLayerLayoutDidAppearHandler
| typedef void(* SwapLayerLayoutDidAppearHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, int8_t rel_change, void *context) |
Called when a layout has become the current one.
- Parameters
-
| swap_layer | Swap layer. |
| layer | New current layout. |
| rel_change | Offset from the previous current layout. |
| context | Callback context. |
◆ SwapLayerLayoutRemovedHandler
| typedef void(* SwapLayerLayoutRemovedHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, void *context) |
Called when the swap layer no longer uses a layout; the client may destroy it.
- Parameters
-
| swap_layer | Swap layer. |
| layer | Removed layout. |
| context | Callback context. |
◆ SwapLayerLayoutWillAppearHandler
| typedef void(* SwapLayerLayoutWillAppearHandler) (struct SwapLayer *swap_layer, LayoutLayer *layer, void *context) |
Called when a layout is about to become the current one.
- Parameters
-
| swap_layer | Swap layer. |
| layer | Upcoming layout. |
| context | Callback context. |
◆ SwapLayerUpdateColorsHandler
| typedef void(* SwapLayerUpdateColorsHandler) (struct SwapLayer *swap_layer, GColor bg_color, bool status_bar_filled, void *context) |
Called when the window colors should change to match the visible layout.
- Parameters
-
| swap_layer | Swap layer. |
| bg_color | Background color. |
| status_bar_filled | Whether the status bar should be filled with bg_color. |
| context | Callback context. |
◆ swap_layer_attempt_layer_swap()
| bool swap_layer_attempt_layer_swap |
( |
SwapLayer * |
swap_layer, |
|
|
ScrollDirection |
direction |
|
) |
| |
Try to swap to the layout in a direction.
Fails if there is no layout to swap to; on success the will appear and did appear handlers are called.
- Parameters
-
| swap_layer | Swap layer. |
| direction | Direction to swap in. |
- Returns
- true if the swap started.
◆ swap_layer_deinit()
| void swap_layer_deinit |
( |
SwapLayer * |
swap_layer | ) |
|
Deinitialize a swap layer.
Calls the layout removed handler for every layout it tracks.
- Parameters
-
◆ swap_layer_get_current_layout()
Get the current layout.
- Parameters
-
- Returns
- Current layout, or NULL.
◆ swap_layer_get_layer()
| Layer * swap_layer_get_layer |
( |
const SwapLayer * |
swap_layer | ) |
|
Get the root layer.
- Parameters
-
- Returns
- Root layer.
◆ swap_layer_init()
| void swap_layer_init |
( |
SwapLayer * |
swap_layer, |
|
|
const GRect * |
frame |
|
) |
| |
Initialize a swap layer, without layouts.
- Parameters
-
| [out] | swap_layer | Swap layer. |
| frame | Frame of the layer. |
◆ swap_layer_reload_data()
| void swap_layer_reload_data |
( |
SwapLayer * |
swap_layer | ) |
|
Reload the layouts.
Calls the layout removed handler for every layout it tracks, then fetches the current and next layouts. The will appear and did appear handlers are both called.
- Parameters
-
◆ swap_layer_set_callbacks()
Set the callbacks.
- Parameters
-
| swap_layer | Swap layer. |
| callback_context | Context passed to the callbacks. |
| callbacks | Callbacks. |
◆ swap_layer_set_click_config_onto_window()
| void swap_layer_set_click_config_onto_window |
( |
SwapLayer * |
swap_layer, |
|
|
struct Window * |
window |
|
) |
| |
Install the swap layer's click handling on a window.
- Parameters
-
| swap_layer | Swap layer. |
| window | Window receiving the clicks. |
◆ swap_layer_touch_release()
| void swap_layer_touch_release |
( |
SwapLayer * |
swap_layer | ) |
|
Release touch input while the swap layer is covered by a higher modal.
Removes it from the touch-navigation registry so touch cannot reach the hidden notification body. Idempotent and safe when touch is disabled; the click config provider registers it again when it is shown.
- Parameters
-
◆ swap_layer_touch_scroll_by()
| void swap_layer_touch_scroll_by |
( |
SwapLayer * |
swap_layer, |
|
|
int16_t |
dy |
|
) |
| |
Scroll the current layout by a pixel delta without animation.
Used by touch panning for live 1:1 scrolling. The scroll offset is clamped to the scrollable range. The next layout is pulled right under the current one so its peek tracks the finger, and the auto-close inactivity timer is refreshed so a long notification cannot close mid-read.
- Parameters
-
| swap_layer | Swap layer. |
| dy | Delta in pixels; positive scrolls back towards the top, negative further into the content. |