Пример #1
0
void
display_gui_draw_scrollbar()
{
    if (gui_menu_option_count <= MAX_MENU_ENTRIES)
        return;

    uint8_t width = 5;

    display_set_inverted (true);

    display_draw_rect (DISPLAY_WIDTH - width, DISPLAY_FONT0_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT - BUTTON_INFO_BAR_HEIGHT - 2, true);

    display_set_inverted (false);

    display_draw_line (DISPLAY_WIDTH - width, DISPLAY_FONT0_HEIGHT, DISPLAY_WIDTH - width, DISPLAY_HEIGHT - BUTTON_INFO_BAR_HEIGHT - 2);

    display_set_inverted (true);

    display_draw_line (DISPLAY_WIDTH - width - 1, DISPLAY_FONT0_HEIGHT + 1, DISPLAY_WIDTH - width - 1, DISPLAY_HEIGHT - BUTTON_INFO_BAR_HEIGHT - 3);

    display_set_inverted (false);


    double height = DISPLAY_HEIGHT - DISPLAY_FONT0_HEIGHT - BUTTON_INFO_BAR_HEIGHT - 2;

    uint8_t bar_size = (uint8_t) (MAX_MENU_ENTRIES / (double) gui_menu_option_count * height);

    if (bar_size < 2)
        bar_size = 2;

    uint8_t pos = (uint8_t) (gui_menu_first_option_shown / (double) gui_menu_option_count * height);

    display_draw_rect (DISPLAY_WIDTH - width + 2, DISPLAY_FONT0_HEIGHT + pos, DISPLAY_WIDTH, DISPLAY_FONT0_HEIGHT + 1 + pos + bar_size, true);

}
Пример #2
0
Файл: osint.c Проект: visy/vecx
void osint_render(void){

	SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0,0,0));

	render();

	int v;
	for(v = 0; v < vector_draw_cnt; v++){
		Uint8 c = vectors_draw[v].color * 256 / VECTREX_COLORS;

		display_draw_line(
				offx + vectors_draw[v].x0 / scl_factor,
				offy + vectors_draw[v].y0 / scl_factor,
				offx + vectors_draw[v].x1 / scl_factor,
				offy + vectors_draw[v].y1 / scl_factor,
				c);
	}
	if(overlay){
		SDL_Rect dest_rect = {offx, offy, 0, 0};
//		SDL_BlitSurface(overlay, NULL, screen, &dest_rect);
	}
  // Remember to unlock..
  SDL_UnlockSurface(screen);

  // Tell SDL to update the whole screen
  SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);    
}
Пример #3
0
void render_item_graph(screen_item &item, bool selected) {

  uint32_t data_size=240;
  uint32_t data_offset=600-240;
  uint32_t data_increment=2;
  float   max_height = 80;

  uint32_t m_x = item.val1;
  uint32_t m_y = item.val2;


  // find min and max in data
  uint32_t nmax = source_graph_data[data_offset];
  uint32_t nmin = source_graph_data[data_offset];
  for(uint32_t n=data_offset;n<(data_offset+data_size);n++) {
    if(source_graph_data[n] > nmax) nmax = source_graph_data[n];
    if(source_graph_data[n] < nmin) nmin = source_graph_data[n];
  }

  // axis
  display_draw_line(m_x,m_y           ,m_x+(data_size/data_increment),m_y           ,FOREGROUND_COLOR);
  display_draw_line(m_x,m_y-max_height,m_x+(data_size/data_increment),m_y-max_height,FOREGROUND_COLOR);

  // if there's no data just draw labels and return.
  if((nmin == 0) && (nmax == 0)) {
    display_draw_tinynumber(m_x+5,m_y-max_height-10,nmax,4,FOREGROUND_COLOR);
    display_draw_tinynumber(m_x+5,m_y-10           ,nmin,4,FOREGROUND_COLOR);
    return;
  }


  // rescale data
  float source_y_range = nmax-nmin;
  float   dest_y_range = max_height;
  float source_x_range = data_size;
  float   dest_x_range = 120;

  float m_graph_count[120];
  for(int n=0;n<120;n++) m_graph_count[n]=0;
  for(int n=0;n<120;n++) m_graph_data [n]=0;

  for(uint32_t n=data_offset;n<(data_offset+data_size);n++) {
    // put data point in the range 0->1
    float data_point = (source_graph_data[n]-nmin)/source_y_range;

    // put data point in the range m_y -> m_y+dest_y_range
    data_point = (data_point*dest_y_range);

    uint32_t xpos = ((float)(n-data_offset)/source_x_range)*dest_x_range;
    m_graph_data [xpos] += data_point;
    m_graph_count[xpos]++;
  }

  // apply averaging, and offset to data.
  for(uint32_t n=0;n<120;n++) {
    if(m_graph_count[n] != 0) m_graph_data[n] = m_y - m_graph_data[n]/m_graph_count[n];
                         else m_graph_data[n] = 0;
  }

  // start clearing data, clear first 2.
  if(!first_render) display_draw_line(0,m_old_graph_data[0],1,m_old_graph_data[1],BACKGROUND_COLOR);
  if(!first_render) display_draw_line(1,m_old_graph_data[1],2,m_old_graph_data[2],BACKGROUND_COLOR);

  // render the data
  for(uint32_t n=1;n<120;n++) {
    uint32_t cx = n;

    if(!first_render && (n<118)) {
      display_draw_line(cx+1,m_old_graph_data[n+1],cx+2,m_old_graph_data[n+2],BACKGROUND_COLOR);
    }

    display_draw_line(cx-1,m_graph_data[n-1],cx,m_graph_data[n],FOREGROUND_COLOR);
  }

  for(uint32_t n=0;n<120;n++) {
    m_old_graph_data[n] = m_graph_data[n];
  }

  display_draw_tinynumber(m_x+5,m_y-max_height-10,nmax,4,FOREGROUND_COLOR);
  display_draw_tinynumber(m_x+5,m_y-10           ,nmin,4,FOREGROUND_COLOR);

}