pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
    • Rocky
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

SimpleMenuLayer

Wrapper around MenuLayer, that uses static data to display a list menu.

Function Documentation

SimpleMenuLayer * simple_menu_layer_create(GRect frame, Window * window, const SimpleMenuSection * sections, int32_t num_sections, void * callback_context)

Creates a new SimpleMenuLayer on the heap and initializes it. It also sets the internal click configuration provider onto given window.

Note

The sections array is not deep-copied and can therefore not be stack allocated, but needs to be backed by long-lived storage.

This function does not add the menu's layer to the window.

Parameters

frame

The frame at which to initialize the menu

window

The window onto which to set the click configuration provider

sections

Array with sections that need to be displayed in the menu

num_sections

The number of sections in the sections array.

callback_context

Pointer to application specific data, that is passed into the callbacks.

Returns

A pointer to the SimpleMenuLayer. NULL if the SimpleMenuLayer could not be created

void simple_menu_layer_destroy(SimpleMenuLayer * menu_layer)

Destroys a SimpleMenuLayer previously created by simple_menu_layer_create.

Layer * simple_menu_layer_get_layer(const SimpleMenuLayer * simple_menu)

Gets the "root" Layer of the simple menu layer, which is the parent for the sub-layers used for its implementation.

Parameters

simple_menu

Pointer to the SimpleMenuLayer for which to get the "root" Layer

Returns

The "root" Layer of the menu layer.

int simple_menu_layer_get_selected_index(const SimpleMenuLayer * simple_menu)

Gets the row index of the currently selection menu item.

Parameters

simple_menu

The SimpleMenuLayer for which to get the current selected row index.

void simple_menu_layer_set_selected_index(SimpleMenuLayer * simple_menu, int32_t index, bool animated)

Selects the item in the first section at given row index.

Parameters

simple_menu

The SimpleMenuLayer for which to change the selection

index

The row index of the item to select

animated

Supply true to animate changing the selection, or false to change the selection instantly.

MenuLayer * simple_menu_layer_get_menu_layer(SimpleMenuLayer * simple_menu)

Parameters

simple_menu

The SimpleMenuLayer to get the MenuLayer from.

Returns

The MenuLayer.

Data Structure Documentation

struct SimpleMenuItem

Data structure containing the information of a menu item.

Data Fields

const char * title

The title of the menu item. Required.

const char * subtitle

The subtitle of the menu item. Optional, leave NULL if unused.

GBitmap * icon

The icon of the menu item. Optional, leave NULL if unused.

SimpleMenuLayerSelectCallback callback

The callback that needs to be called upon a click on the SELECT button. Optional, leave NULL if unused.

struct SimpleMenuSection

Data structure containing the information of a menu section.

Data Fields

const char * title

Title of the section. Optional, leave NULL if unused.

const SimpleMenuItem * items

Array of items in the section.

uint32_t num_items

Number of items in the .items array.

Typedef Documentation

typedef struct SimpleMenuLayer SimpleMenuLayer
typedef void(* SimpleMenuLayerSelectCallback)(int index, void *context)

Function signature for the callback to handle the event that a user hits the SELECT button.

Parameters

index

The row index of the item

context

The callback context

Need some help?

Functions

  • simple_menu_layer_create
  • simple_menu_layer_destroy
  • simple_menu_layer_get_layer
  • simple_menu_layer_get_selected_index
  • simple_menu_layer_set_selected_index
  • simple_menu_layer_get_menu_layer

Data Structures

  • SimpleMenuItem
  • SimpleMenuSection

Typedefs

  • SimpleMenuLayer
  • SimpleMenuLayerSelectCallback

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!