Exemplo n.º 1
0
Arquivo: dock.c Projeto: dkogan/notion
static void dock_deinit(WDock *dock)
{
    while(dock->dockapps!=NULL)
        destroy_obj((Obj*)dock->dockapps->reg);

    UNLINK_ITEM(docks, dock, dock_next, dock_prev);

    dock_brush_release(dock);

    window_deinit((WWindow*) dock);
}
Exemplo n.º 2
0
void panehandle_deinit(WPaneHandle *pwin)
{
    assert(pwin->splitfloat==NULL);
    
    if(pwin->brush!=NULL){
        grbrush_release(pwin->brush);
        pwin->brush=NULL;
    }
    
    window_deinit(&(pwin->wwin));
}
Exemplo n.º 3
0
bool infowin_init(WInfoWin *p, WWindow *parent, const WFitParams *fp,
                  const char *style)
{
    XSetWindowAttributes attr;
    
    if(!window_init(&(p->wwin), parent, fp))
        return FALSE;
    
    p->buffer=ALLOC_N(char, INFOWIN_BUFFER_LEN);
    if(p->buffer==NULL)
        goto fail;
    p->buffer[0]='\0';
    
    if(style==NULL)
        p->style=scopy("*");
    else
        p->style=scopy(style);
    if(p->style==NULL)
        goto fail2;
    
    p->brush=NULL;
    
    gr_stylespec_init(&p->attr);
    
    infowin_updategr(p);
    
    if(p->brush==NULL)
        goto fail3;
    
    /* Enable save unders */
    attr.save_under=True;
    XChangeWindowAttributes(ioncore_g.dpy, p->wwin.win, CWSaveUnder, &attr);
    
    window_select_input(&(p->wwin), IONCORE_EVENTMASK_NORMAL);

    return TRUE;

fail3:
    gr_stylespec_unalloc(&p->attr);
    free(p->style);
fail2:
    free(p->buffer);
fail:    
    window_deinit(&(p->wwin));
    return FALSE;
}
Exemplo n.º 4
0
void rootwin_deinit(WRootWin *rw)
{
    WScreen *scr, *next;

    FOR_ALL_SCREENS_W_NEXT(scr, next){
        if(REGION_MANAGER(scr)==(WRegion*)rw)
            destroy_obj((Obj*)scr);
    }
    
    UNLINK_ITEM(*(WRegion**)&ioncore_g.rootwins, (WRegion*)rw, p_next, p_prev);
    
    XSelectInput(ioncore_g.dpy, WROOTWIN_ROOT(rw), 0);
    
    XFreeGC(ioncore_g.dpy, rw->xor_gc);
    
    window_deinit((WWindow*)rw);
}
Exemplo n.º 5
0
void handle_deinit(AppContextRef ctx)
// Pebble has little to no memory management, so we have to clear up. I'm
// not convinced this is all of it, mind you. It'd be nice if we could
// work out where all the leaks are somehow.
{
    (void)ctx;

    bmp_deinit_container(&watchface_container);
    rotbmp_deinit_container(&hourhand_container);
    rotbmp_deinit_container(&minutehand_container);
    bmp_deinit_container(&centerdot_container);
    if(!big) {
        if(digital_time)
            fonts_unload_custom_font(&large_font);
        fonts_unload_custom_font(&small_font);
    }
    window_deinit(&window);
}
Exemplo n.º 6
0
void menu_deinit(WMenu *menu)
{
    menu_typeahead_clear(menu);
    
    if(menu->submenu!=NULL)
        destroy_obj((Obj*)menu->submenu);
    
    /*if(menu->cycle_bindmap!=NULL)
        bindmap_destroy(menu->cycle_bindmap);*/

    extl_unref_table(menu->tab);
    extl_unref_fn(menu->handler);
    
    deinit_entries(menu);
    
    menu_release_gr(menu);
    
    window_deinit((WWindow*)menu);
}
Exemplo n.º 7
0
void infowin_deinit(WInfoWin *p)
{
    if(p->buffer!=NULL){
        free(p->buffer);
        p->buffer=NULL;
    }

    if(p->style!=NULL){
        free(p->style);
        p->style=NULL;
    }
    
    if(p->brush!=NULL){
        grbrush_release(p->brush);
        p->brush=NULL;
    }
    
    gr_stylespec_unalloc(&p->attr);
    
    window_deinit(&(p->wwin));
}
Exemplo n.º 8
0
bool menu_init(WMenu *menu, WWindow *par, const WFitParams *fp,
               const WMenuCreateParams *params)
{
    Window win;
    int i;
    
    menu->entries=preprocess_menu(params->tab, &(menu->n_entries));
    
    if(menu->entries==NULL){
        warn(TR("Empty menu."));
        return FALSE;
    }

    menu->tab=extl_ref_table(params->tab);
    menu->handler=extl_ref_fn(params->handler);
    menu->pmenu_mode=params->pmenu_mode;
    menu->big_mode=params->big_mode;
    /*menu->cycle_bindmap=NULL;*/
    
    menu->last_fp=*fp;
    
    if(params->pmenu_mode){
        menu->selected_entry=-1;
    }else{
        menu->selected_entry=params->initial-1;
        if(menu->selected_entry<0)
           menu->selected_entry=0;
        if(params->initial > menu->n_entries)
           menu->selected_entry=0;
    }
    
    menu->max_entry_w=0;
    menu->entry_h=0;
    menu->brush=NULL;
    menu->entry_brush=NULL;
    menu->entry_spacing=0;
    menu->vis_entries=menu->n_entries;
    menu->first_entry=0;
    menu->submenu=NULL;
    menu->typeahead=NULL;
    
    menu->gm_kcb=0;
    menu->gm_state=0;
    
    if(!window_init((WWindow*)menu, par, fp))
        goto fail;

    win=menu->win.win;
    
    if(!menu_init_gr(menu, region_rootwin_of((WRegion*)par), win))
        goto fail2;
        
    init_attr();
    
    menu_firstfit(menu, params->submenu_mode, &(params->refg));
    
    window_select_input(&(menu->win), IONCORE_EVENTMASK_NORMAL);
    
    region_add_bindmap((WRegion*)menu, mod_menu_menu_bindmap);
    
    region_register((WRegion*)menu);
    
    return TRUE;

fail2:
    window_deinit((WWindow*)menu);
fail:
    extl_unref_table(menu->tab);
    extl_unref_fn(menu->handler);
    deinit_entries(menu);
    return FALSE;
}
Exemplo n.º 9
0
void InboxDestroy()
{
	window_deinit(&s_window);
}
Exemplo n.º 10
0
static void window_init(Window *window){
  bitcoin_img = gbitmap_create_with_resource(RESOURCE_ID_LG_BIT);
  dogecoin_img = gbitmap_create_with_resource(RESOURCE_ID_LG_DOGE);
  litecoin_img = gbitmap_create_with_resource(RESOURCE_ID_LG_LITE);
  
  first_it[0] = (SimpleMenuItem){
    .title = "BitCoin",
    .callback = coin_select_cb,
    .icon = bitcoin_img,
  };
  first_it[1] = (SimpleMenuItem){
    .title = "DogeCoin",
    .callback = coin_select_cb,
    .icon = dogecoin_img,
  };
  first_it[2] = (SimpleMenuItem){
    .title = "LiteCoin",
    .callback = coin_select_cb,
    .icon = litecoin_img,
  };
  menu_sec[0] = (SimpleMenuSection){
    .num_items = 3,
    .items = first_it,
  };
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  
  sml = simple_menu_layer_create(bounds, window, menu_sec, 2, NULL);
  
  layer_add_child(window_layer, simple_menu_layer_get_layer(sml));
  
  handle_wins_init();
  
  // Clicker
  // window_set_click_config_provider(window, click_config_provider);
}

static void window_deinit(void) {
  handle_wins_deinit();
  simple_menu_layer_destroy(sml);
}

static void handle_init(void) {
  window = window_create();
  window_init(window);
  
  //Register AppMessage events
  app_message_register_inbox_received(in_received_handler);           
  app_message_open(512, 512);    //Large input and output buffer sizes
  
  //Register to receive minutely updates
  tick_timer_service_subscribe(MINUTE_UNIT, tick_callback);
  
  window_stack_push(window, true /* Animated */);
}

static void handle_deinit(void) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Hi im handeling deinit");
  gbitmap_destroy(bitcoin_img);
  gbitmap_destroy(dogecoin_img);
  gbitmap_destroy(litecoin_img);
  
  window_deinit();
  window_destroy(window);
  
  tick_timer_service_unsubscribe();
}

int main(void) {
  handle_init();
  app_event_loop();
  handle_deinit();
}
Exemplo n.º 11
0
int game_loop(){


    unsigned redraw = 0;

    game_rect t;
    rect_Zero(&t);
    sprite_sheet = gamespr_create("ski1.bmp");

    animation_init();
    init_player();
    start_new_game(0);


    while(!mainloop){

        ALLEGRO_EVENT e;
        ALLEGRO_TIMEOUT timeout;
        int i;

        al_init_timeout(&timeout, 0.06);

        bool  late = al_wait_for_event_until(g_queue, &e, &timeout);





        if(late){
            switch(e.type){
                case ALLEGRO_EVENT_DISPLAY_CLOSE:
                    mainloop = 1;
                    break;

                 case ALLEGRO_EVENT_KEY_UP:
                        player_poll_kbd_up(&e);
                 break;

                 case ALLEGRO_EVENT_KEY_DOWN:
                        player_poll_kbd_dn(&e);
                 break;

                case ALLEGRO_EVENT_TIMER:

                /* main clock updates 1/60ms (60FPS LOCK) */
                    if(e.timer.source == g_timer){
                        particle_list = particles_clean(particle_list, 0);
                        particles_update(particle_list);
                        player_update_screen();
                        player_update(&ski_player, &playfield);



                        for(i = 1; i < MAX_SPRITES; i++){
                           update_enemy(i);
                        }

                        update_enemy_behavior(gobj_list, &playfield);

                        redraw =  1;
                    }

                     /* update for the chronomenter run every 100ms only) */
                    if( e.timer.source == timer_chrono){
                        HUD_UpdateChrono();
                        DMSG("%d", al_get_timer_count(timer_chrono));




                    }

                    break;
            }


            if( redraw == 1 && al_event_queue_is_empty(g_queue)){
                    redraw = 0;
                    al_clear_to_color(WHITE_COLOR);


                    particles_draw(NULL, particle_list);
                    player_draw(ski_player.object->position.x, ski_player.object->position.y );

                    for(i = 1; i < MAX_OBJECTS; i++){
                         int enemy_type = gobj_list[i].type;
                         draw_enemy(enemy_type, i, 0,0, gobj_list[i].position.x, gobj_list[i].position.y, 32,32);

                    }

                    HUD_create_stats_box();
                    al_flip_display();
            }
        }

    }

    HUD_destroy();
    unload_spritesheets();
    window_deinit();
    particle_list = particles_clean(particle_list, PARTICLES_ALL_CLEAN);
    return EXIT_SUCCESS;
}