void draw(const GraphicContextState& state, CL_GraphicContext* gc) { // FIXME: We need to stop onion layer to draw onto itself surface.set_blend_func(blend_one, blend_one_minus_src_alpha); surface.set_scale(SCALE, SCALE); surface.draw(0, 0); }
void draw() { float old_r, old_g, old_b, old_a; surface.get_color(old_r, old_g, old_b, old_a); surface.set_color(0, 0, 0, 0.4); surface.set_scale(1, 0.5); surface.draw(x, y + surface.get_height() / 2); surface.set_scale(1, 1); surface.set_color(old_r, old_g, old_b, old_a); }
void CL_TreeItem_Silver::on_paint() { CL_Rect rect = item->get_screen_rect(); int height = rect.get_height(); int font_height = font->get_height(item->get_text(0)); if(item->has_mouse_over()) CL_Display::fill_rect(rect, CL_Color(232, 236, 241)); if(item->get_node()->is_selected()) CL_Display::fill_rect(rect, CL_Color(184, 195, 209, 150)); CL_TreeView *treeview = item->get_node()->get_treeview(); int columns = treeview->get_column_count(); if(columns == 0) columns = 1; // Draw columns for(int x = 0, i = 0; i < columns; ++i) { int dx = 0; if(i == 0) { dx += item->get_text_margin(); CL_Surface *icon = item->get_icon(); if(icon) { icon->draw( rect.left + x + 1, rect.top + (height - icon->get_height()) / 2); dx += icon->get_width(); } } CL_Component *comp = item->get_component(i); if(comp) { comp->set_position(CL_Rect(x + dx + 4, 0, x + dx + 4 + treeview->get_column_width(i), height)); comp->paint(); } else { font->draw( rect.left + x + dx + 4, rect.top + (height - font_height) / 2, item->get_text(i)); } x += treeview->get_column_width(i); if(i == 0) x -= item->get_node()->get_placement_offset(); } }
void draw() { surface.draw(x, y); }
void CL_Button_Silver::on_paint() { int text_width = 0; int text_height = 0; if(font) { text_width = font->get_width(button->get_text().c_str()); text_height = font->get_height(); } CL_Rectf rect = button->get_screen_rect(); int font_xpos = static_cast<int>(rect.left + (rect.right - rect.left - text_width) / 2); int font_ypos = static_cast<int>(rect.top + (rect.bottom - rect.top - text_height) / 2); if(button->is_enabled() == false) { if(draw_only_surfaces == false || sur_disabled == NULL) { CL_Display::draw_rect(rect, CL_Color(203, 209, 216)); } if(sur_disabled) { sur_disabled->draw(rect.left + (rect.get_width() - sur_disabled->get_width()) / 2, rect.top + (rect.get_height() - sur_disabled->get_height()) / 2); } if(font_disabled) { font_disabled->draw(font_xpos, font_ypos, button->get_text()); } else if(font) { font->draw(font_xpos, font_ypos, button->get_text()); } } else { if(button->is_drawn_down()) { if(draw_only_surfaces == false || sur_down == NULL) { // Main border CL_Display::draw_rect( rect, CL_Color(128, 142, 159)); // Dark inner border CL_Display::draw_rect( CL_Rectf(rect.left + 1, rect.top + 1, rect.right - 1, rect.bottom - 1), CL_Color(73, 94, 120)); // Outer gradient CL_Display::fill_rect( CL_Rectf(rect.left + 2, rect.top + 2, rect.right - 1, rect.bottom - 1), CL_Gradient(CL_Color::white, CL_Color::white, CL_Color(230, 235, 240), CL_Color(230, 235, 240))); // Inner fill CL_Display::fill_rect( CL_Rectf(rect.left + 4, rect.top + 4, rect.right - 1, rect.bottom - 1), CL_Color(240, 242, 244)); } if(sur_down) { sur_down->draw(rect.left + (rect.get_width() - sur_down->get_width()) / 2, rect.top + (rect.get_height() - sur_down->get_height()) / 2); } if(font) { font->draw(font_xpos + 1, font_ypos + 1, button->get_text()); } } else { bool need_highlight = false; if (button->has_mouse_over()) { if (!button->get_gui_manager() || (!button->get_gui_manager()->get_modal_component() || button->has_modal_parent())) { need_highlight = true; } } CL_Surface *sur = NULL; if(sur_highlighted && need_highlight) { sur = sur_highlighted; } else if(sur_up) { sur = sur_up; } if(draw_only_surfaces == false || sur == NULL) { // Highlight if(need_highlight) { // Main border CL_Display::draw_rect( rect, CL_Color(209, 149, 32)); // Highlight CL_Display::draw_rect( CL_Rectf(rect.left - 1, rect.top - 1, rect.right + 1, rect.bottom + 1), CL_Color(250, 236, 204)); // Outer gradient CL_Display::fill_rect( CL_Rectf(rect.left + 1, rect.top + 1, rect.right - 1, rect.bottom - 1), CL_Gradient(CL_Color::white, CL_Color::white, CL_Color(230, 235, 240), CL_Color(230, 235, 240))); // Inner fill CL_Display::fill_rect( CL_Rectf(rect.left + 3, rect.top + 3, rect.right - 3, rect.bottom - 3), CL_Color(240, 242, 244)); } // Focus else if(button->has_focus()) { // Main border CL_Display::draw_rect( rect, CL_Color(119, 138, 187)); // Highlight CL_Display::draw_rect( CL_Rectf(rect.left - 1, rect.top - 1, rect.right + 1, rect.bottom + 1), CL_Color(206, 220, 233)); // Outer gradient CL_Display::fill_rect( CL_Rectf(rect.left + 1, rect.top + 1, rect.right - 1, rect.bottom - 1), CL_Gradient(CL_Color::white, CL_Color::white, CL_Color(230, 235, 240), CL_Color(230, 235, 240))); // Inner fill CL_Display::fill_rect( CL_Rectf(rect.left + 3, rect.top + 3, rect.right - 3, rect.bottom - 3), CL_Color(240, 242, 244)); } // Normal else { // Main border CL_Display::draw_rect( rect, CL_Color(128, 142, 159)); // Outer gradient CL_Display::fill_rect( CL_Rectf(rect.left + 1, rect.top + 1, rect.right - 1, rect.bottom - 1), CL_Gradient(CL_Color::white, CL_Color::white, CL_Color(230, 235, 240), CL_Color(230, 235, 240))); // Inner fill CL_Display::fill_rect( CL_Rectf(rect.left + 3, rect.top + 3, rect.right - 3, rect.bottom - 3), CL_Color(240, 242, 244)); } } if(sur) { sur->draw(rect.left + (rect.get_width() - sur->get_width()) / 2, rect.top + (rect.get_height() - sur->get_height()) / 2); } if(font) { font->draw(font_xpos, font_ypos, button->get_text()); } } } }