Пример #1
0
void ui_start_metronome()
{
    if(metro_status == 0){
        easter_egg = 0;
    }

    itoa(metronome_bpm, bpm_str, 10);
    
    metronome_beat_count = metronome_beat_count % BEATLIMIT;
    
    itoa(metronome_beat_count, beat_count_str, 10);
    
    ui_draw_note();

    ui_draw_button();

    LCD_SetColors(LCD_COLOR_MAGENTA , LCD_COLOR_WHITE);
        
    LCD_DisplayStringLine(LCD_LINE_2, bpm_text_str);
    LCD_DisplayStringLine(LCD_LINE_3, bpm_str);
        
    LCD_DisplayStringLine(LCD_LINE_5, beat_text_str);
    LCD_DisplayStringLine(LCD_LINE_6, beat_count_str);

    ui_touch_detect();

    ui_swap_layer();


}
Пример #2
0
static void draw_button_ui_object (ui_object *obj)
{

	float
//		px1,
//		py1,
		x,
		//y,
		//vp_x1,
		//vp_y1,
		//vp_x2,
		//vp_y2,
		x_size,
		y_size,
		x_origin,
		y_origin,
		x1,
		y1,
		x2,
		y2;
		//nx1,
		//ny1,
		//nx2,
		//ny2;

	int
		redraw_flag = FALSE;
//		width,
//		height,
//		pitch;

	struct SCREEN
		*old_active_screen;
//		*memory_graphic;

//	unsigned short
//		*graphic;

//	unsigned char
//		*data;

//	ui_object
//		*parent;

	button_ui_object
		*button;

	button = obj->button;

	if (get_ui_object_redraw (obj))
	{

		if (get_ui_object_autosize (obj))
		{

			ui_object_autosize (obj);
		}

		//debug_log ("BU_DRAW: drawing button %f, %f  %f, %f", button->area.x, button->area.y, button->area.x_size, button->area.y_size);

		//x1 = get_ui_object_x (obj);
		//y1 = get_ui_object_y (obj);

		x_size = get_ui_object_x_size (obj);
		y_size = get_ui_object_y_size (obj);
	
		x_origin = get_ui_object_x_origin (obj);
		y_origin = get_ui_object_y_origin (obj);
	
		ui_set_origin (x_origin, y_origin);


		//x2 = x1 + x_size;// - 1;
		//y2 = y1 + y_size;// - 1;

		x1 = get_ui_object_x (obj);
		y1 = get_ui_object_y (obj);

		x1 += x_origin;
		y1 += y_origin;

		x2 = x1 + get_ui_object_x_size (obj);
		y2 = y1 + get_ui_object_y_size (obj);

		old_active_screen = get_active_screen ();

		if (get_ui_object_active_screen (obj))
		{
	
			set_active_screen (get_ui_object_active_screen (obj));
		}
		else
		{

			set_active_screen (video_screen);
		}

		// debug
		set_active_screen (video_screen);
		// debug

//		if (lock_screen (active_screen))
		{

//			memory_graphic = get_ui_object_memory_graphic (obj);
	
			if (!get_ui_object_clear (obj))
			{
	
				switch (get_ui_object_graphic_type (obj))
				{

					case UI_OBJECT_TEXTURE_GRAPHIC:
					{
			
						texture_graphic
							*graphic;
					
						if ((get_ui_object_state (obj) == UI_OBJECT_STATE_ON) && (get_ui_object_selected_texture_graphic (obj)))
						{
					
							graphic = get_ui_object_selected_texture_graphic (obj);
						}
						else if ((get_ui_object_highlighted (obj)) && (get_ui_object_highlighted_texture_graphic (obj)))
						{
					
							graphic = get_ui_object_highlighted_texture_graphic (obj);
						}
						else
						{
					
							graphic = get_ui_object_texture_graphic (obj);
						}
			
						if (graphic)
						{

							rgb_colour
								colour;

							real_colour
								text_colour;

							colour = get_ui_object_colour ( obj );

							text_colour.red = colour.r;
							text_colour.green = colour.g;
							text_colour.blue = colour.b;
							text_colour.alpha = colour.a;

							ui_draw_texture_graphic (x1, y1, x2, y2, graphic, text_colour);
						}
						else
						{
				
							ui_draw_area (0, 0, x2 - x1, y2 - y1, obj);
						}
				
						break;
					}
/*
					case UI_OBJECT_GRAPHIC:
					{
			
						if (get_ui_object_state (obj) == UI_OBJECT_STATE_ON)
						{
		
							graphic = get_ui_object_graphic (obj);
		
							ui_draw_graphic (x1, y1, x2, y2, graphic);
	
							redraw_flag = TRUE;
						}
						else
						{
	
							parent = get_ui_object_parent (obj);
	
							if (parent)
							{
	
								graphic = get_ui_object_graphic (parent);
	
								px1 = get_ui_object_x (parent);
	
								py1 = get_ui_object_y (parent);
	
								x1 -= px1;
								x2 -= px1;
	
								y1 -= py1;
								y2 -= py1;
		
								ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
								redraw_flag = TRUE;
							}
						}
	
						break;
					}
	
					case UI_OBJECT_MEMORY_GRAPHIC:
					{
		
						memory_graphic = get_ui_object_memory_graphic (obj);
	
						if (lock_screen (memory_graphic))
						{
		
							width = get_screen_width (memory_graphic);
		
							height = get_screen_height (memory_graphic);
		
							data = get_screen_data (memory_graphic);
		
							pitch = get_screen_pitch (memory_graphic);
			
							ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, FALSE);
		
							unlock_screen (memory_graphic);
						}
	
						redraw_flag = TRUE;
	
						break;
					}
	
					case UI_OBJECT_ALPHA_GRAPHIC:
					{
			
						if (!get_ui_object_clear (obj))
						{
			
							graphic = get_ui_object_graphic (obj);
		
							ui_draw_alpha_graphic (x1, y1, x2, y2, graphic);
		
							redraw_flag = TRUE;
						}
						else
						{
		
							parent = get_ui_object_parent (obj);
		
							if (parent)
							{
		
								graphic = get_ui_object_graphic (parent);
		
								ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic);
		
								redraw_flag = TRUE;
							}
						}
		
						break;
					}
*/
					case UI_OBJECT_NO_GRAPHIC:
					default:
					{

						int
							state;

						state = get_ui_object_state (obj);

						if ((state == UI_OBJECT_STATE_OFF) && (get_ui_object_highlighted (obj)))
						{

							state = UI_OBJECT_STATE_HIGHLIGHTED;
						}

						ui_draw_button (x1, y1, x2, y2, state);
	
						redraw_flag = TRUE;
					}
				}
			}
		
			if (get_ui_object_text (obj))
			{

				const char
					*text_ptr;

				int
					count;

				float
					y3;
	
				ui_save_current_font ();

				ui_set_object_font (obj);

				// count number of lines spanned

				text_ptr = get_ui_object_text (obj);

				count = 0;

				while (text_ptr)
				{

					count ++;

					text_ptr = strchr (text_ptr, '\n');

					// if found, step over it and display the next part of string
					if (text_ptr)
					{

						text_ptr ++;
					}
				}

				// now draw text

				text_ptr = get_ui_object_text (obj);
			
				get_text_y_position (&y3, y1, y2, text_ptr, get_ui_object_text_justify (obj), count);

				while (text_ptr)
				{
			
					get_text_x_position (&x, x1, x2, text_ptr, get_ui_object_text_justify (obj));
			
					ui_display_text (text_ptr, x, y3);

					y3 += ui_get_font_height ();

					// check for carriage return
					text_ptr = strchr (text_ptr, '\n');

					// if found, step over it and display the next part of string
					if (text_ptr)
					{

						text_ptr ++;
					}
				}

				ui_restore_current_font ();
	
				redraw_flag = TRUE;
			}
	
			if (redraw_flag)
			{
	
				set_ui_repaint_area (x1 - 1, y1 - 1, x2 + 1, y2 + 1);
			}
	
//			unlock_screen (active_screen);
		}

		set_active_screen (old_active_screen);

		button->area.redraw --;

		call_ui_object_draw_function (obj, NULL);
	}
}