void ui_draw(SDL_Point* viewport) { const int NLINES = 32; if (console_enabled || console_fade > 0) { int console_width = (640 > viewport->x) ? viewport->x : 640; size_t max_display = console_width/UI_CHAR_W - 1; size_t len, offset; float elastic_fade = enQuinticInOut(console_fade); uint32_t alpha = (uint32_t)(ML_MAX(elastic_fade, 0.1f)*255.5f); float yoffs = (float)(NLINES*UI_CHAR_H) * elastic_fade; ui_rect(0, viewport->y - (int)yoffs, console_width, NLINES*UI_CHAR_H, ((alpha * 5 / 6)<<24)|0x2c3e50); ui_rect(0, viewport->y - (int)yoffs - UI_CHAR_H - 4, console_width, UI_CHAR_H + 4, (alpha<<24)|0x34495e); int sby = viewport->y - (int)yoffs + 2; int sbpos = (console_scrollback_pos - 1) % CONSOLE_SCROLLBACK; if (sbpos < 0) sbpos = CONSOLE_SCROLLBACK - 1; while (sbpos != console_scrollback_pos && sby < viewport->y) { if (console_scrollback[sbpos] == '\0') break; len = strlen(console_scrollback[sbpos]); offset = (len > max_display) ? (len - max_display) : 0; ui_text(2, sby, (alpha<<24)|0xbdc3c7, "%s", console_scrollback[sbpos] + offset); sby += UI_CHAR_H; sbpos = (sbpos - 1) % CONSOLE_SCROLLBACK; if (sbpos < 0) sbpos = CONSOLE_SCROLLBACK - 1; } len = strlen(console_cmdline); offset = (len > (max_display - 1)) ? (len - (max_display - 1)) : 0; ui_text(2, viewport->y - (int)yoffs - UI_CHAR_H - 2, (alpha<<24)|0xeeeeec, "#%s", console_cmdline + offset); } if (ui_count > 0) { vec2_t screensize = { (float)viewport->x, (float)viewport->y }; glEnable(GL_BLEND); // glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glUseProgram(ui_material->program); m_tex2d_bind(&ui_font, 0); glUniform2fv(ui_screensize_index, 1, (float*)&screensize); glUniform1i(ui_tex0_index, 0); glBindVertexArray(ui_vao); glBindBuffer(GL_ARRAY_BUFFER, ui_vbo); if (ui_count > ui_maxcount) { glBufferData(GL_ARRAY_BUFFER, (unsigned long)(ui_count)*sizeof(uivert_t), ui_vertices, GL_DYNAMIC_DRAW); ui_maxcount = ui_count; } else { glBufferSubData(GL_ARRAY_BUFFER, 0, (unsigned long)(ui_count)*sizeof(uivert_t), ui_vertices); } glDrawArrays(GL_TRIANGLES, 0, ui_count); glBindVertexArray(0); glUseProgram(0); glDisable(GL_BLEND); // glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); ui_count = 0; } }
void UI_SCROLLBAR::draw() { UI_GADGET::draw(); if (uses_bmaps) { gr_reset_clip(); if (disabled_flag) { if ( bmap_ids[SB_DISABLED] != -1 ) { gr_set_bitmap(bmap_ids[SB_DISABLED]); gr_bitmap(x,y,GR_RESIZE_MENU); } } else { if ( bmap_ids[SB_NORMAL] != -1 ) { gr_set_bitmap(bmap_ids[SB_NORMAL]); gr_bitmap(x,y,GR_RESIZE_MENU); } } gr_set_clip( x, y, w, h, GR_RESIZE_MENU ); ui_draw_box_out( 0, bar_position, w - 1, bar_position + bar_size - 1 ); } else { font::set_font(my_wnd->f_id); gr_set_clip( x, y, w, h, GR_RESIZE_MENU ); if (my_wnd->selected_gadget == this) gr_set_color_fast(&CBRIGHT_GREEN); else gr_set_color_fast(&CGRAY); ui_rect( 0, 0, w-1, h-1 ); ui_draw_box_out( 0, bar_position, w - 1, bar_position + bar_size - 1 ); } }
/* Process an opaque rectangle order */ static void process_rect(STREAM s, RECT_ORDER * os, uint32 present, BOOL delta) { if (present & 0x01) rdp_in_coord(s, &os->x, delta); if (present & 0x02) rdp_in_coord(s, &os->y, delta); if (present & 0x04) rdp_in_coord(s, &os->cx, delta); if (present & 0x08) rdp_in_coord(s, &os->cy, delta); if (present & 0x10) in_uint8(s, os->colour); DEBUG(("RECT(x=%d,y=%d,cx=%d,cy=%d,fg=0x%x)\n", os->x, os->y, os->cx, os->cy, os->colour)); ui_rect(os->x, os->y, os->cx, os->cy, os->colour); }
void UI_LISTBOX::draw() { int i, x1, y1, stop; int w1, h1; UI_GADGET::draw(); gr_set_font(my_wnd->f_id); if (uses_bmaps) { if (disabled_flag) { if ( bmap_ids[LBOX_DISABLED] >= 0 ) { gr_set_bitmap(bmap_ids[LBOX_DISABLED]); gr_bitmap(x, y); } } else { if ( bmap_ids[LBOX_NORMAL] >= 0 ) { gr_set_bitmap(bmap_ids[LBOX_NORMAL]); gr_bitmap(x, y); } } } else { gr_set_color_fast(&CBLACK); gr_set_clip( x, y, w, h ); ui_rect( 0, 0, w-1, h-1 ); gr_reset_clip(); if (has_scrollbar) { ui_draw_sunken_border( x-2, y-2, x+w+scrollbar.w+4, y+h+1 ); } else { ui_draw_sunken_border( x-2, y-2, x+w+4, y+h+1 ); } } stop = first_item+num_items_displayed; if (stop>num_items) stop = num_items; x1 = y1 = 0; gr_set_clip( x, y, w, h ); for ( i=first_item; i<stop; i++ ) { gr_get_string_size( &w1, &h1,list[i] ); if (check_list) w1 += 18; if (i !=current_item) { /* if ((current_item == -1) && (my_wnd->selected_gadget == this ) && (i == first_item) ) { if ( !uses_bmaps ) { gr_set_color_fast( &CBLACK ); gr_rect( x1, y1, w1+2, h1 ); } current_item = first_item; gr_set_color_fast( &CBRIGHT_GREEN ); } else { if ( !uses_bmaps ) { gr_set_color_fast( &CBLACK ); gr_rect( x1, y1, w1+2, h1 ); } gr_set_color_fast( &CWHITE ); } */ if (!uses_bmaps) { gr_set_color_fast( &CBLACK ); gr_rect( x1, y1, w1+2, h1 ); } gr_set_color_fast(&CWHITE); } else { if (my_wnd->selected_gadget == this) { gr_set_color_fast( &CGRAY ); gr_rect( x1, y1, w1+2, h1 ); gr_set_color_fast( &CBRIGHT_GREEN ); } else { gr_set_color_fast( &CGRAY ); gr_rect( x1, y1, w1+2, h1 ); gr_set_color_fast( &CBLACK ); } } if ( check_list ) { if ( check_list[i] ) { gr_string( x1+2, y1, "X" ); } gr_string( x1+16, y1, list[i] ); } else gr_string( x1+2, y1, list[i] ); if (i==current_item) gr_set_color_fast( &CGRAY ); else gr_set_color_fast( &CBLACK ); if ( !uses_bmaps ) { ui_rect( x1+w1+2, y1, w-1, y1+h1-1 ); ui_rect( x1, y1, x1+1, y1+h1-1 ); } y1 += h1; } if (stop < num_items_displayed-1 && !uses_bmaps) { gr_set_color_fast(&CBLACK); ui_rect( x1, y1, w-1, h-1 ); } }