int GLUI_Spinner::mouse_down_handler( int local_x, int local_y ) { this->state = find_arrow( local_x, local_y ); /* printf( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y, find_arrow( local_x, local_y )); */ if ( state != GLUI_SPINNER_STATE_UP AND state != GLUI_SPINNER_STATE_DOWN ) return true; reset_growth(); if ( can_draw() ) draw_arrows(); /*** ints and floats behave a bit differently. When you click on an int spinner, you expect the value to immediately go up by 1, whereas for a float it'll go up only by a fractional amount. Therefore, we go ahead and increment by one for int spinners ***/ if ( data_type == GLUI_SPINNER_INT ) { if ( state == GLUI_SPINNER_STATE_UP ) edittext->set_float_val( edittext->float_val + 1.0 ); else if ( state == GLUI_SPINNER_STATE_DOWN ) edittext->set_float_val( edittext->float_val - .9 ); } do_click(); return false; }
// draw nodes which are fully attached to the list void List::draw_connected(const Cairo::RefPtr<Cairo::Context> & cr) { ListNode * n = head; while (n != NULL) { n->draw(cr); n->printed = true; draw_arrows(cr, n); n = n->next; } }
int GLUI_Spinner::mouse_held_down_handler( int local_x, int local_y, int new_inside) { int new_state; if ( state == GLUI_SPINNER_STATE_NONE ) return false; /* printf("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y, new_inside); */ if ( state == GLUI_SPINNER_STATE_BOTH ) { /* dragging? */ do_drag( local_x, local_y ); } else { /* not dragging */ new_state = find_arrow( local_x, local_y ); if ( new_state == state ) { /** Still in same arrow **/ do_click(); } else { if ( new_inside OR 1) { /** The state changed, but we're still inside - that means we moved off the arrow: begin dragging **/ state = GLUI_SPINNER_STATE_BOTH; } else { /*** Here check y of mouse position to determine whether to drag ***/ /* ... */ } } /*** We switched to up/down dragging ***/ if ( state == GLUI_SPINNER_STATE_BOTH ) { glutSetCursor( GLUT_CURSOR_UP_DOWN ); last_x = local_x; last_y = local_y; /** If the spinner has limits, we reset the growth value, since reset_growth() will compute a new growth value for dragging vs. clicking. If the spinner has no limits, then we just let the growth remain at whatever the user has incremented it up to **/ if ( edittext->has_limits != GLUI_LIMIT_NONE ) reset_growth(); } if ( can_draw() ) draw_arrows(); } return false; }
// draw nodes which may point to the list but are no fully attached to it void List::draw_disconnected(const Cairo::RefPtr<Cairo::Context> & cr) { int xTmp = out_x; int yTmp = out_y; for (int i = 0; i < currentNodes; i++) { if (!nodes[i]->printed) { nodes[i]->y = yTmp; nodes[i]->x = xTmp; nodes[i]->draw(cr); draw_arrows(cr, nodes[i]); xTmp += 2 * ListNode::padding; } } }
void menu::draw_menu() { if (!is_open) return; if (current_index[current_menu] + 2 > option_count && current_menu == Players) current_index[current_menu] = option_count - 1; float difference = ((option_count > MAX_PP ? MAX_PP : option_count) * (.035 * 10)) / 10; draw_rect(x_axis, y_axis + .018, .205, .074, shader_color); draw_rect(x_axis, y_axis + .055 + difference / 2, .205, difference, background_color); draw_rect(x_axis, y_axis + .074 + difference, .205, .038, shader_color); draw_text(title, 1, 1, x_axis, y_axis - .024, white, center); draw_text(sub_title, 1, .55, x_axis, y_axis + .022, white, center); draw_text(creator_text, 1, .455, x_axis - .097, y_axis + difference + .058, white); draw_text((string)(current_index[current_menu] + 1) + "/" + (string)option_count, 1, .455, x_axis + .095, y_axis + difference + .058, white, right); draw_sprite("commonmenu", "arrowright", x_axis - .095, y_axis + .074 + (.035 * c_drawing_index), .022, .022, pointer_color); draw_instructions(); draw_arrows(); }
int GLUI_Spinner::mouse_up_handler( int local_x, int local_y, int inside ) { state = GLUI_SPINNER_STATE_NONE; /* printf("spinner: mouse up : %d/%d inside: %d\n",local_x,local_y,inside); */ /*glutSetCursor( GLUT_CURSOR_INHERIT ); */ glutSetCursor( GLUT_CURSOR_LEFT_ARROW ); draw_arrows(); /* do_callbacks(); --- stub */ /* if ( callback ) */ /* callback( this->user_id ); */ return false; }
TypeScreen game_rank_screen() { const int num_of_buttons = 1; int i, pos; const int num_of_ops = 1; ArrowOp vet_arrow_type[num_of_ops]; JHI_Image but_up; JHI_Image but_down; JHI_Image but_up_red; JHI_Image but_down_red; JHI_Image *but_up_pointer[num_of_ops]; JHI_Image *but_down_pointer[num_of_ops]; JHI_Text * text_pointer[num_of_ops]; JHI_Text * text_pointer_name[num_of_ops]; JHI_Text level; JHI_Text level_name; JHI_Font f1,f2; TypeScreen te = IS_CLOSE; JHI_Image back; Button back_title[num_of_buttons]; JHI_MouseSt mouse; JHI_Effect ef1; JHI_Point2d init_arrow_pos; jhi_load_image_with_transparent_color(&but_up, BUTTON_SET_UP, BLUE); jhi_load_image_with_transparent_color(&but_down, BUTTON_SET_DOWN, BLUE); jhi_load_image_with_transparent_color(&but_up_red, BUTTON_SET_RED_UP, BLUE); jhi_load_image_with_transparent_color(&but_down_red, BUTTON_SET_RED_DOWN, BLUE); jhi_load_effect(&ef1, CLICK_BOTTON_SOUND); jhi_load_font(&f2, MONSTER_FONT, 40); jhi_load_font(&f1, MONSTER_FONT, 30); jhi_load_image(&back, BACK_FILE_PATH); jhi_set_fps_timer(32); jhi_init_text(&level); jhi_init_text(&level_name); jhi_set_text(&f1, &level, BLACK, "Dificuldade:"); jhi_set_text(&f1, &level_name, RED, levels[get_rank_game_level()]); text_pointer[0] = &level; text_pointer_name[0] = &level_name; vet_arrow_type[0] = RANK_LEVEL; for (i = 0; i < num_of_ops; i++) { but_up_pointer[i] = &but_up; but_down_pointer[i] = &but_down; } jhi_init_mouse(&mouse); init_button(&back_title[0], &f1, "Retornar", BUTTON_TYPE_1); back_title[0].pos.x = jhi_get_central_pos(jhi_get_width_window(), jhi_get_height_window(), jhi_get_image_width(&(back_title[0].img)), jhi_get_image_height(&(back_title[0].img))).x - 250; init_arrow_pos = jhi_get_point(jhi_get_central_pos(jhi_get_width_window(), jhi_get_height_window(), jhi_get_image_width(&but_up), 0).x - 120, 20); while(jhi_get_close_window() != JHI_CLOSE) { jhi_timer_start(); jhi_update(); jhi_clean(); jhi_draw_image(&back, jhi_get_point(0, 0)); draw_rank(&f2, get_rank_game_level()); draw_button(&back_title[0], jhi_get_point(back_title[0].pos.x, 500)); draw_arrows(but_up_pointer, but_down_pointer, num_of_ops, init_arrow_pos, text_pointer, text_pointer_name); jhi_init_mouse(&mouse); for (i = 0; i < jhi_get_number_of_events(); i++) { mouse = jhi_get_mouse_status(i); } if (mouse.mouse_event != MOUSE_NOT_EVENT) { HANDLE_ARROWS; pos = check_buttons(mouse, back_title, num_of_buttons); if (pos == 0) {te = IS_TITLE; jhi_play_effect(&ef1, 2000); break;} } jhi_wait_time(); } jhi_free_font(&f1); jhi_free_font(&f2); jhi_free_image(&back); free_button(&back_title[0]); jhi_free_effect(&ef1); jhi_free_image(&but_up); jhi_free_image (&but_down); jhi_free_image(&but_up_red); jhi_free_image(&but_down_red); jhi_free_text(&level); jhi_free_text(&level_name); return te; }
int main(){ int i,count=0; cairo_surface_t *cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, W,H); int s=(W+SPACING-1)/SPACING+1; float *data = calloc((W+SPACING-1)/SPACING,sizeof(*data)); for(i=0;i<s;i++) data[i] = -sin((i-.35)/s*2*M_PI)*.9; clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_samples(cs,data,0); write_frame(cs,"quant",count++); /* fade in lines */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,(float)i/FRAMES); draw_samples(cs,data,0); write_frame(cs,"quant",count++); } /* fade in arrows */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1); draw_samples(cs,data,0); draw_arrows(cs,data,0,(float)i/FRAMES); write_frame(cs,"quant",count++); } /* move */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1); draw_samples(cs,data,(float)i/FRAMES); draw_arrows(cs,data,(float)i/FRAMES,1); write_frame(cs,"quant",count++); } /* fade out all */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1.-(float)i/FRAMES); draw_samples(cs,data,1); draw_arrows(cs,data,1,1-(float)i/FRAMES); write_frame(cs,"quant",count++); } clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_samples(cs,data,1); write_frame(cs,"quant",count++); cairo_surface_destroy(cs); return 0; }