Skip to content

Commit

Permalink
Merge branch 'circle-arc' of https://github.com/bkbilly/pebblejs into…
Browse files Browse the repository at this point in the history
… circle-arc
  • Loading branch information
bkbilly committed Feb 5, 2016
2 parents 52af619 + 796212b commit 1c4a6a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ Note that this means you may have to move portions of your startup logic into th

## Wakeup

The Wakeup module allows you to schedule your app to wakeup at a specified time using Pebble's wakeup functionality. Whether the user is in a different watchface or app, your app while launch by the specified time. This allows you to write a custom alarm app, for example. If your app is already running, you may also subscribe to receive the wakeup event, which can be useful for more longer lived timers. With the Wakeup module, you can save data to be read on launch and configure your app to behave differently based on launch data. The Wakeup module, like the Settings module, is backed by localStorage.
The Wakeup module allows you to schedule your app to wakeup at a specified time using Pebble's wakeup functionality. Whether the user is in a different watchface or app, your app will launch at the specified time. This allows you to write a custom alarm app, for example. If your app is already running, you may also subscribe to receive the wakeup event, which can be useful for more longer lived timers. With the Wakeup module, you can save data to be read on launch and configure your app to behave differently based on launch data. The Wakeup module, like the Settings module, is backed by localStorage.

### Wakeup

Expand Down
4 changes: 4 additions & 0 deletions src/js/ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ Menu.prototype._resolveMenu = function(clear, pushing) {
Menu.prototype._resolveSection = function(e, clear) {
var section = this._getSection(e);
if (!section) { return; }
section = myutil.shadow({
textColor: this.state.textColor,
backgroundColor: this.state.backgroundColor
}, section);
section.items = this._getItems(e);
if (this === WindowStack.top()) {
simply.impl.menuSection.call(this, e.sectionIndex, section, clear);
Expand Down
4 changes: 4 additions & 0 deletions src/js/ui/simply-pebble.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ var MenuSectionPacket = new struct([
[Packet, 'packet'],
['uint16', 'section'],
['uint16', 'items', EnumerableType],
['uint8', 'backgroundColor', Color],
['uint8', 'textColor', Color],
['uint16', 'titleLength', EnumerableType],
['cstring', 'title', StringType],
]);
Expand Down Expand Up @@ -1227,6 +1229,8 @@ SimplyPebble.menuSection = function(section, def, clear) {
MenuSectionPacket
.section(section)
.items(def.items)
.backgroundColor(def.backgroundColor)
.textColor(def.textColor)
.titleLength(def.title)
.title(def.title);
SimplyPebble.sendPacket(MenuSectionPacket);
Expand Down
10 changes: 9 additions & 1 deletion src/simply/simply_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct __attribute__((__packed__)) MenuSectionPacket {
Packet packet;
uint16_t section;
uint16_t num_items;
GColor8 background_color;
GColor8 text_color;
uint16_t title_length;
char title[];
};
Expand Down Expand Up @@ -340,10 +342,14 @@ static void menu_draw_header_callback(GContext *ctx, const Layer *cell_layer, ui
list1_prepend(&self->menu_layer.sections, &section->node);

GRect bounds = layer_get_bounds(cell_layer);

graphics_context_set_fill_color(ctx, gcolor8_get_or(section->title_background, GColorWhite));
graphics_fill_rect(ctx, bounds, 0, GCornerNone);

bounds.origin.x += 2;
bounds.origin.y -= 1;

graphics_context_set_text_color(ctx, gcolor8_get_or(self->menu_layer.normal_foreground, GColorBlack));
graphics_context_set_text_color(ctx, gcolor8_get_or(section->title_foreground, GColorBlack));
graphics_draw_text(ctx, section->title, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD),
bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
}
Expand Down Expand Up @@ -551,6 +557,8 @@ static void handle_menu_section_packet(Simply *simply, Packet *data) {
*section = (SimplyMenuSection) {
.section = packet->section,
.num_items = packet->num_items,
.title_foreground = packet->text_color,
.title_background = packet->background_color,
.title = packet->title_length ? strdup2(packet->title) : NULL,
};
simply_menu_add_section(simply->menu, section);
Expand Down
2 changes: 2 additions & 0 deletions src/simply/simply_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef struct SimplyMenuSection SimplyMenuSection;
struct SimplyMenuSection {
SimplyMenuCommonMember;
uint16_t num_items;
GColor8 title_foreground;
GColor8 title_background;
};

typedef struct SimplyMenuItem SimplyMenuItem;
Expand Down

0 comments on commit 1c4a6a6

Please sign in to comment.