void gui_list_box::draw() { if(!gui_object::handle_draw()) return; // TODO: handle disabled state theme->draw("list_box", "normal", position_abs, size_abs, true, true, get_parent_window()->get_background_color(), images); // manual scissor test: glScissor((GLint)floorf(position_abs.x), (GLint)floorf(position_abs.y), (GLsizei)ceilf(size_abs.x), (GLsizei)ceilf(size_abs.y)); size_t item_counter = 0; for(const auto& item : display_items) { // check if item is in box const float y_offset = float(item_counter) * item_height; const float y_next_offset = y_offset + item_height; item_counter++; if(y_next_offset < scroll_position && y_offset >= size_abs.y) { continue; } const float2 cur_position(position_abs + float2(0.0f, y_offset - scroll_position)); theme->draw("list_box", item == selected_item ? "item_active" : "item", cur_position, float2(size_abs.x, item_height), false, false, get_parent_window()->get_background_color(), images, [&item](const string&) -> string { return item->second; }); } glScissor(0, 0, (GLsizei)floor::get_physical_width(), (GLsizei)floor::get_physical_height()); }
void ProgressNode::initialization_finished() { my_line = boost::in_place( get_relayout_function() ); create_static_text( my_line->label, description ); run_in_GUI_thread( boost::bind( &make_progress_bar, my_line->contents, my_gauge, get_parent_window() ) ); add_entry_line( *my_line ); }
void gui_input_box::draw() { if(!gui_object::handle_draw()) return; // TODO: handle disabled state // below the text theme->draw("input_box", state.active ? "active" : "normal", position_abs, size_abs, true, true, get_parent_window()->get_background_color(), images); // draw the text // note: scissor will be reset in the next theme draw glScissor((int)floorf(position_abs.x + input_text_margin.x), (int)floorf(position_abs.y + input_text_margin.y), (int)ceilf(input_size_abs.x), (int)ceilf(input_size_abs.y)); fnt->draw_cached(input, input_text_position, theme->get_color_scheme().get("TEXT_INVERSE")); // draw blink character if(blink_state && blink_task && state.active) { auto limited_size = size_abs; auto blink_position = position_abs; const float blink_offset = cursor_position - input_text_interval.x; blink_position.x += blink_offset; limited_size.x -= blink_offset; theme->draw("input_box", "blink", blink_position, limited_size, false, // don't clear underlying input box true, get_parent_window()->get_background_color(), images); } // above the text theme->draw("input_box", state.active ? "active_top" : "normal_top", position_abs, size_abs, false, // don't clear underlying input box true, get_parent_window()->get_background_color(), images); }
void MyWidget::on_realize() { //Do not call base class Gtk::Widget::on_realize(). //It's intended only for widgets that set_has_window(false). set_realized(); //Get the themed style from the CSS file: get_style_property("example_scale", m_scale); std::cout << "m_scale (example_scale from the theme/css-file) is: " << m_scale << std::endl; if(!m_refGdkWindow) { //Create the GdkWindow: GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); Gtk::Allocation allocation = get_allocation(); //Set initial position and size of the Gdk::Window: attributes.x = allocation.get_x(); attributes.y = allocation.get_y(); attributes.width = allocation.get_width(); attributes.height = allocation.get_height(); attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; m_refGdkWindow = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y); set_window(m_refGdkWindow); //set colors override_background_color(Gdk::RGBA("red")); override_color(Gdk::RGBA("blue")); //make the widget receive expose events m_refGdkWindow->set_user_data(gobj()); } }
/** * Does something when the block bar is realized. */ void GtkBlockBar::on_realize() { //Do not call base class Gtk::Widget::on_realize(). //It's intended only for widgets that set_has_window(false). set_realized(); if(!m_refGdkWindow) { //Create the GdkWindow: GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); Gtk::Allocation allocation = get_allocation(); //Set initial position and size of the Gdk::Window: attributes.x = allocation.get_x(); attributes.y = allocation.get_y(); attributes.width = allocation.get_width(); attributes.height = allocation.get_height(); attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; m_refGdkWindow = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y); set_window(m_refGdkWindow); //set colors TODO //override_background_color(Gdk::RGBA("red")); //override_color(Gdk::RGBA("green")); //make the widget receive expose events m_refGdkWindow->set_user_data(gobj()); } }
int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { panel_t *panel = (panel_t*)ctrl; window_t *win = get_parent_window(ctrl); ctrl_t *child; int x, y; x = ((pos_t)arg2).x; y = ((pos_t)arg2).y; switch( msg ) { case 1: draw_panel((panel_t*)ctrl); break; case MSG_MOUSEMOVE: child = get_child(ctrl, x, y); if( win->child_over ) { if(child == win->child_over) send_message(child, msg, 0, arg2); else send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); } else if( child ) send_message(child, MSG_MOUSEENTER, 0, arg2); win->child_over = child; if( child ) send_message(child,msg,0,arg2); else if(main_cursor != 0) { set_cursor(0); main_cursor = 0; } break; case MSG_COMMAND: switch((short)arg1) { case ID_PLAY: case ID_STOP: case ID_PROGRESS: case ID_VOL_CTRL: win = get_parent_window(ctrl); send_message(win, msg, arg1, arg2); break; default: break; }; default: child = get_child(ctrl, x, y); if(child) return send_message(child, msg, 0, arg2); } return 1; };