PebbleOS
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
Swap layer

Scrolls through a sequence of layouts, swapping to the previous or next at the ends. More...

Data Structures

struct  SwapLayerCallbacks
 Callbacks of a SwapLayer. More...
 
struct  ArrowLayer
 Layer drawing the arrow hinting at more content. More...
 
struct  SwapLayer
 Data structure of a SwapLayer. More...
 

Typedefs

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.
 

Functions

void swap_layer_init (SwapLayer *swap_layer, const GRect *frame)
 Initialize a swap layer, without layouts.
 
void swap_layer_deinit (SwapLayer *swap_layer)
 Deinitialize a swap layer.
 
void swap_layer_reload_data (SwapLayer *swap_layer)
 Reload the layouts.
 
LayoutLayer * swap_layer_get_current_layout (const SwapLayer *swap_layer)
 Get the current layout.
 
Layer * swap_layer_get_layer (const SwapLayer *swap_layer)
 Get the root layer.
 
void swap_layer_set_callbacks (SwapLayer *swap_layer, void *callback_context, SwapLayerCallbacks callbacks)
 Set the callbacks.
 
void swap_layer_set_click_config_onto_window (SwapLayer *swap_layer, struct Window *window)
 Install the swap layer's click handling on a window.
 
bool swap_layer_attempt_layer_swap (SwapLayer *swap_layer, ScrollDirection direction)
 Try to swap to the layout in a direction.
 
void swap_layer_touch_scroll_by (SwapLayer *swap_layer, int16_t dy)
 Scroll the current layout by a pixel delta without animation.
 
void swap_layer_touch_release (SwapLayer *swap_layer)
 Release touch input while the swap layer is covered by a higher modal.
 

Detailed Description

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.


Data Structure Documentation

◆ SwapLayerCallbacks

struct SwapLayerCallbacks

Callbacks of a SwapLayer.

Note
The context set with swap_layer_set_callbacks() is passed to all of them.
Data Fields
ClickConfigProvider click_config_provider Adds click handlers on top of the swap layer's own, may be NULL.
SwapLayerGetLayoutHandler get_layout_handler Supplies layouts.
SwapLayerInteractionHandler interaction_handler Reports user interaction.
SwapLayerLayoutDidAppearHandler layout_did_appear_handler Called after a swap.
SwapLayerLayoutRemovedHandler layout_removed_handler Releases layouts.
SwapLayerLayoutWillAppearHandler layout_will_appear_handler Called before a swap.
SwapLayerUpdateColorsHandler update_colors_handler Updates the window colors.

◆ ArrowLayer

struct ArrowLayer

Layer drawing the arrow hinting at more content.

Data Fields
GBitmap arrow_bitmap Arrow image.
Layer layer Layer.

◆ SwapLayer

struct 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.
SwapLayer swap_layer;
...
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.

Typedef Documentation

◆ SwapLayerGetLayoutHandler

typedef LayoutLayer *(* SwapLayerGetLayoutHandler) (struct SwapLayer *swap_layer, int8_t rel_position, void *context)

Get a layout relative to the current one.

Parameters
swap_layerSwap layer.
rel_positionOffset from the current layout, which the client keeps track of: -1 for the previous, 0 for the current, 1 for the next.
contextCallback 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_layerSwap layer.
contextCallback 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_layerSwap layer.
layerNew current layout.
rel_changeOffset from the previous current layout.
contextCallback 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_layerSwap layer.
layerRemoved layout.
contextCallback 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_layerSwap layer.
layerUpcoming layout.
contextCallback 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_layerSwap layer.
bg_colorBackground color.
status_bar_filledWhether the status bar should be filled with bg_color.
contextCallback context.

Function Documentation

◆ 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_layerSwap layer.
directionDirection 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_layerSwap layer.

◆ swap_layer_get_current_layout()

LayoutLayer * swap_layer_get_current_layout ( const SwapLayer *  swap_layer)

Get the current layout.

Parameters
swap_layerSwap layer.
Returns
Current layout, or NULL.

◆ swap_layer_get_layer()

Layer * swap_layer_get_layer ( const SwapLayer *  swap_layer)

Get the root layer.

Parameters
swap_layerSwap layer.
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_layerSwap layer.
frameFrame 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_layerSwap layer.

◆ swap_layer_set_callbacks()

void swap_layer_set_callbacks ( SwapLayer *  swap_layer,
void *  callback_context,
SwapLayerCallbacks  callbacks 
)

Set the callbacks.

Parameters
swap_layerSwap layer.
callback_contextContext passed to the callbacks.
callbacksCallbacks.

◆ 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_layerSwap layer.
windowWindow 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_layerSwap layer.

◆ 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_layerSwap layer.
dyDelta in pixels; positive scrolls back towards the top, negative further into the content.