PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
Notification layout

Layout of notifications and reminders (LayoutIdNotification, LayoutIdReminder). More...

Data Structures

struct  NotificationStyle
 Fonts and spacing of a notification card, per content size. More...
 
struct  NotificationLayoutInfo
 LayoutLayerConfig context of a notification layout. More...
 
struct  NotificationLayout
 Notification and reminder layout; can be cast to a LayoutLayer. More...
 

Macros

#define LAYOUT_BANNER_HEIGHT_RECT
 Banner height of notification and reminder layouts on rectangular displays, excluding the status bar; the top and bottom banners have the same size.
 
#define LAYOUT_TOP_BANNER_HEIGHT_ROUND   60
 Height of the top banner on round displays, including the status bar.
 
#define LAYOUT_BOTTOM_BANNER_HEIGHT_ROUND   40
 Height of the bottom banner on round displays.
 
#define LAYOUT_TOP_BANNER_HEIGHT
 Height of the top banner, excluding the status bar.
 
#define LAYOUT_ARROW_HEIGHT   PBL_IF_RECT_ELSE(19, 16)
 Height of the white arrow layer.
 
#define LAYOUT_HEIGHT   (DISP_ROWS - STATUS_BAR_LAYER_HEIGHT - LAYOUT_ARROW_HEIGHT)
 Height of the layout text region: the display minus the status bar and arrow.
 
#define LAYOUT_BEFORE_TEXT_SPACING_Y   40
 Vertical offset before the text begins.
 
#define BANNER_CIRCLE_RADIUS   140
 Radius of the round banner.
 
#define LAYOUT_TOP_BANNER_ORIGIN_Y    (LAYOUT_TOP_BANNER_HEIGHT_ROUND - (BANNER_CIRCLE_RADIUS + STATUS_BAR_LAYER_HEIGHT) - 1)
 Vertical origin of the round top banner circle.
 
#define TEXT_VISIBLE_UPPER_THRESHOLD   (STATUS_BAR_LAYER_HEIGHT - INTERPOLATE_MOOOK_BOUNCE_BACK - 1)
 Largest layout origin y at which its text is considered visible.
 
#define TEXT_VISIBLE_LOWER_THRESHOLD(h)    (-(h) + DISP_ROWS - STATUS_BAR_LAYER_HEIGHT - INTERPOLATE_MOOOK_BOUNCE_BACK - 1)
 Smallest layout origin y at which its text is considered visible.
 
#define DEFAULT_NOTIFICATION_COLOR   (GColorFolly)
 Default notification background color.
 
#define DEFAULT_REMINDER_COLOR   (GColorRed)
 Default reminder background color.
 
#define NOTIFICATION_TINY_RESOURCE_HEIGHT   (ATTRIBUTE_ICON_TINY_SIZE_PX)
 Height of the tiny icon in the notification banner.
 
#define NOTIFICATION_TINY_RESOURCE_SIZE   (GSize(30, NOTIFICATION_TINY_RESOURCE_HEIGHT))
 Size of the tiny icon in the notification banner; some icons are 30 px wide.
 
#define NOTIFICATION_TINY_RESOURCE_VERTICAL_OFFSET
 Vertical adjustment of the banner icon.
 
#define CARD_ICON_UPPER_PADDING
 Vertical position of the banner icon within the layout.
 
#define NOTIFICATION_IMAGE_MIN_ASPECT   (4)
 Widest image band a notification can reserve, 4:1 landscape, as a height/width ratio in sixteenths.
 
#define NOTIFICATION_IMAGE_MAX_ASPECT   (24)
 Tallest image band a notification can reserve, 2:3 portrait, in sixteenths.
 

Functions

LayoutLayer * notification_layout_create (const LayoutLayerConfig *config)
 Create a notification layout.
 
bool notification_layout_verify (bool existing_attributes[])
 Check the attributes of a notification or reminder.
 
bool notification_layout_get_image_size (const LayoutLayer *layout, GSize *size_out)
 Get the size of the image band a notification layout reserves.
 
TimelineResourceId notification_layout_get_fallback_icon_id (TimelineItemType item_type)
 Get the icon used when an item has none.
 

Variables

static const TimelineResourceId NOTIF_FALLBACK_ICON = TIMELINE_RESOURCE_NOTIFICATION_GENERIC
 Icon of notifications without one.
 
static const TimelineResourceId REMINDER_FALLBACK_ICON = TIMELINE_RESOURCE_NOTIFICATION_REMINDER
 Icon of reminders without one.
 

Detailed Description

Layout of notifications and reminders (LayoutIdNotification, LayoutIdReminder).

Only the card mode is rendered. The card shows a banner with the tiny icon and app name, then the title, subtitle, location, body (or a large emoji when the body is a single Jumboji, see Jumboji table), an optional phone-supplied image and the timestamp. The LayoutLayerConfig context must be a NotificationLayoutInfo.


Data Structure Documentation

◆ NotificationStyle

struct NotificationStyle

Fonts and spacing of a notification card, per content size.

Offset and margin follow GTextNode: an offset moves an element without affecting its neighbors, a margin changes its size without affecting its internal positioning. Padding is extra space between an element and the next one below; upper padding is the same towards the element above. New fields should be offsets or margins rather than paddings. All values are in pixels.

Data Fields
const char * body_font_key Font key of the body.
int8_t body_icon_margin Margin of the large body icon.
int8_t body_icon_offset Offset of the large body icon, currently used by Jumboji.
int8_t body_line_delta Line spacing delta of the body.
int8_t body_padding Padding of the body.
const char * footer_font_key Font key of the footer.
const char * header_font_key Font key of the header.
int8_t header_padding Padding of the header (app name).
int8_t location_margin Margin of the location.
int8_t location_offset Offset of the location.
const char * subtitle_font_key Font key of the subtitle.
int8_t subtitle_line_delta Line spacing delta of the subtitle.
int8_t subtitle_lower_padding Lower padding of the subtitle.
int8_t subtitle_upper_padding Upper padding of the subtitle.
int8_t timestamp_lower_padding Lower padding of the timestamp.
int8_t timestamp_upper_padding Upper padding of the timestamp.
const char * title_font_key Font key of the title.
int8_t title_line_delta Line spacing delta of the title.
int8_t title_offset_if_body_icon Additional title offset when there is a body icon.
int8_t title_padding Padding of the title.

◆ NotificationLayoutInfo

struct NotificationLayoutInfo

LayoutLayerConfig context of a notification layout.

Data Fields
TimelineItem * item Notification or reminder shown; must outlive the layout.
bool show_notification_timestamp Whether to show how long ago the notification arrived.

◆ NotificationLayout

struct NotificationLayout

Notification and reminder layout; can be cast to a LayoutLayer.

Data Fields
LayoutColors colors Colors.
KinoLayer * detail_icon_layer Large body icon; allocated separately since it is rarely used.
KinoLayer icon_layer Banner icon.
AppResourceInfo icon_res_info Resource of the banner icon.
NotificationLayoutInfo info Item shown, copied from the config context.
LayoutLayer layout Base layout.
const NotificationStyle * style Style of the current content size.
GTextNode * view_node Root of the card view.
GSize view_size Size of the card view.

Macro Definition Documentation

◆ BANNER_CIRCLE_RADIUS

#define BANNER_CIRCLE_RADIUS   140

Radius of the round banner.

◆ CARD_ICON_UPPER_PADDING

#define CARD_ICON_UPPER_PADDING
Value:
#define LAYOUT_TOP_BANNER_HEIGHT
Height of the top banner, excluding the status bar.
Definition notification_layout.h:40
#define NOTIFICATION_TINY_RESOURCE_VERTICAL_OFFSET
Vertical adjustment of the banner icon.
Definition notification_layout.h:165
#define NOTIFICATION_TINY_RESOURCE_HEIGHT
Height of the tiny icon in the notification banner.
Definition notification_layout.h:156

Vertical position of the banner icon within the layout.

◆ DEFAULT_NOTIFICATION_COLOR

#define DEFAULT_NOTIFICATION_COLOR   (GColorFolly)

Default notification background color.

◆ DEFAULT_REMINDER_COLOR

#define DEFAULT_REMINDER_COLOR   (GColorRed)

Default reminder background color.

◆ LAYOUT_ARROW_HEIGHT

#define LAYOUT_ARROW_HEIGHT   PBL_IF_RECT_ELSE(19, 16)

Height of the white arrow layer.

◆ LAYOUT_BANNER_HEIGHT_RECT

#define LAYOUT_BANNER_HEIGHT_RECT
Value:
PREFERRED_CONTENT_SIZE_SWITCH( \
PreferredContentSizeDefault, /* This is the same as Medium until Small is designed */ \
/* small */ 36, /* medium */ 36, /* large */ \
29, /* This is the same as Large until ExtraLarge is designed */ /* extralarge */ 29)

Banner height of notification and reminder layouts on rectangular displays, excluding the status bar; the top and bottom banners have the same size.

◆ LAYOUT_BEFORE_TEXT_SPACING_Y

#define LAYOUT_BEFORE_TEXT_SPACING_Y   40

Vertical offset before the text begins.

◆ LAYOUT_BOTTOM_BANNER_HEIGHT_ROUND

#define LAYOUT_BOTTOM_BANNER_HEIGHT_ROUND   40

Height of the bottom banner on round displays.

◆ LAYOUT_HEIGHT

#define LAYOUT_HEIGHT   (DISP_ROWS - STATUS_BAR_LAYER_HEIGHT - LAYOUT_ARROW_HEIGHT)

Height of the layout text region: the display minus the status bar and arrow.

◆ LAYOUT_TOP_BANNER_HEIGHT

#define LAYOUT_TOP_BANNER_HEIGHT
Value:
PBL_IF_RECT_ELSE(LAYOUT_BANNER_HEIGHT_RECT, \
LAYOUT_TOP_BANNER_HEIGHT_ROUND - STATUS_BAR_LAYER_HEIGHT)
#define LAYOUT_TOP_BANNER_HEIGHT_ROUND
Height of the top banner on round displays, including the status bar.
Definition notification_layout.h:36
#define LAYOUT_BANNER_HEIGHT_RECT
Banner height of notification and reminder layouts on rectangular displays, excluding the status bar;...
Definition notification_layout.h:30

Height of the top banner, excluding the status bar.

◆ LAYOUT_TOP_BANNER_HEIGHT_ROUND

#define LAYOUT_TOP_BANNER_HEIGHT_ROUND   60

Height of the top banner on round displays, including the status bar.

◆ LAYOUT_TOP_BANNER_ORIGIN_Y

#define LAYOUT_TOP_BANNER_ORIGIN_Y    (LAYOUT_TOP_BANNER_HEIGHT_ROUND - (BANNER_CIRCLE_RADIUS + STATUS_BAR_LAYER_HEIGHT) - 1)

Vertical origin of the round top banner circle.

◆ NOTIFICATION_IMAGE_MAX_ASPECT

#define NOTIFICATION_IMAGE_MAX_ASPECT   (24)

Tallest image band a notification can reserve, 2:3 portrait, in sixteenths.

◆ NOTIFICATION_IMAGE_MIN_ASPECT

#define NOTIFICATION_IMAGE_MIN_ASPECT   (4)

Widest image band a notification can reserve, 4:1 landscape, as a height/width ratio in sixteenths.

The phone clamps to the same range.

◆ NOTIFICATION_TINY_RESOURCE_HEIGHT

#define NOTIFICATION_TINY_RESOURCE_HEIGHT   (ATTRIBUTE_ICON_TINY_SIZE_PX)

Height of the tiny icon in the notification banner.

◆ NOTIFICATION_TINY_RESOURCE_SIZE

#define NOTIFICATION_TINY_RESOURCE_SIZE   (GSize(30, NOTIFICATION_TINY_RESOURCE_HEIGHT))

Size of the tiny icon in the notification banner; some icons are 30 px wide.

◆ NOTIFICATION_TINY_RESOURCE_VERTICAL_OFFSET

#define NOTIFICATION_TINY_RESOURCE_VERTICAL_OFFSET
Value:
PREFERRED_CONTENT_SIZE_SWITCH( \
PreferredContentSizeDefault, /* This is the same as Medium until Small is designed */ \
/* small */ -1, /* medium */ -1, /* large */ \
-2, /* This is the same as Large until ExtraLarge is designed */ /* extralarge */ -2)

Vertical adjustment of the banner icon.

Accounts for the whitespace inside the status bar below its text, so it depends on the status bar font.

◆ TEXT_VISIBLE_LOWER_THRESHOLD

#define TEXT_VISIBLE_LOWER_THRESHOLD (   h)     (-(h) + DISP_ROWS - STATUS_BAR_LAYER_HEIGHT - INTERPOLATE_MOOOK_BOUNCE_BACK - 1)

Smallest layout origin y at which its text is considered visible.

Parameters
hHeight of the layout.

◆ TEXT_VISIBLE_UPPER_THRESHOLD

#define TEXT_VISIBLE_UPPER_THRESHOLD   (STATUS_BAR_LAYER_HEIGHT - INTERPOLATE_MOOOK_BOUNCE_BACK - 1)

Largest layout origin y at which its text is considered visible.

Function Documentation

◆ notification_layout_create()

LayoutLayer * notification_layout_create ( const LayoutLayerConfig *  config)

Create a notification layout.

Parameters
configConfiguration; its context must be a NotificationLayoutInfo.
Returns
New layout, allocated on the calling task's heap.

◆ notification_layout_get_fallback_icon_id()

TimelineResourceId notification_layout_get_fallback_icon_id ( TimelineItemType  item_type)

Get the icon used when an item has none.

Parameters
item_typeItem type.
Returns
NOTIF_FALLBACK_ICON for notifications, REMINDER_FALLBACK_ICON otherwise.

◆ notification_layout_get_image_size()

bool notification_layout_get_image_size ( const LayoutLayer *  layout,
GSize *  size_out 
)

Get the size of the image band a notification layout reserves.

The image requester and the renderer must agree on it, so it is computed here only.

Parameters
layoutNotification layout.
[out]size_outSize of the band.
Returns
false if the item has no image.

◆ notification_layout_verify()

bool notification_layout_verify ( bool  existing_attributes[])

Check the attributes of a notification or reminder.

Parameters
existing_attributesArray of NumAttributeIds flags, indexed by AttributeId.
Returns
true if a title is present.

Variable Documentation

◆ NOTIF_FALLBACK_ICON

const TimelineResourceId NOTIF_FALLBACK_ICON = TIMELINE_RESOURCE_NOTIFICATION_GENERIC
static

Icon of notifications without one.

◆ REMINDER_FALLBACK_ICON

const TimelineResourceId REMINDER_FALLBACK_ICON = TIMELINE_RESOURCE_NOTIFICATION_REMINDER
static

Icon of reminders without one.