Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

pebble-slide-layer

1.1.3 • Public • Published

Slide Layer is a custom layer for Pebble smartwatch with sliding effect - ideal for immitation of old mechanical digital watches

To use the library add #include <pebble-slide-layer/pebble-slide-layer.h> to your source.

Rustics Slider

General use flow:

  1. Create SlideLayer add add it to parent layer
  2. If desired - set properties (animation direction and duration)
  3. Create and assign next bitmap (e.g. next digit image on the wacthface) to slide in
  4. Call slide animation function

New image will slide in and remain in place until slide animation function is called again

Functions

Functions

SlideLayer* slide_layer_create(GRect frame) - creates slide layer and returns pointer to it. Parameter is GRect with coordinates and layer size, for example SlideLayer* slide_layer = slide_layer_create(GRect(50, 50, 20, 40));.

void slide_layer_destroy(SlideLayer *slide_layer) - destroys slde layer and frees memory.

<codeLayer* slide_layer_get_layer(SlideLayer *slide_layer); - gets underlying Layer of the slide layer for basic manipulations such as adding to Window root layer or layer changing frame or bounds

void slide_layer_set_animation_duration(int duration, SlideLayer *slide_layer); - sets duration of the slide-in in milliseconds.

void slide_layer_set_animation_direction(int direction, SlideLayer *slide_layer); - set direction of the slide-in animation. Possible values:

  • SLIDE_TO_RIGHT
  • SLIDE_TO_TOP_RIGHT
  • SLIDE_TO_TOP
  • SLIDE_TO_TOP_LEFT
  • SLIDE_TO_LEFT
  • SLIDE_TO_BOTTOM_LEFT
  • SLIDE_TO_BOTTOM
  • SLIDE_TO_BOTTOM_RIGHT
//Example usage 
 
//creating slide layer 
slide_layer = slide_layer_create(GRect(10305975));
layer_add_child(window_get_root_layer(my_window), slide_layer_get_layer(slide_layer));
 
window_stack_push(my_window, true);
  
//setting slide layer params 
slide_layer_set_animation_direction(SLIDE_TO_RIGHT, slide_layer);
slide_layer_set_animation_duration(1000, slide_layer);
 
//assigning next bitmap to slide in 
slide_layer->gbitmap = gbitmap_create_with_resource(RESOURCE_ID_MY_IMG);
 
// animating layer 
slide_layer_animate(slide_layer);
  
  

Install

npm i pebble-slide-layer

DownloadsWeekly Downloads

0

Version

1.1.3

License

MIT

Last publish

Collaborators

  • avatar