// VSX_WIDGET_POPUP **************************************************************************************************** // VSX_WIDGET_POPUP **************************************************************************************************** // VSX_WIDGET_POPUP **************************************************************************************************** // VSX_WIDGET_POPUP **************************************************************************************************** void vsx_widget_popup_menu::i_draw() { render_type = VSX_WIDGET_RENDER_2D; target_size.y = (float)(menu_items.count())*row_size; if (visible >= 1) { if (a_focus->widget_type != VSX_WIDGET_TYPE_2D_MENU_POPUP && visible != 2) { visible = 0; return; } else { if (visible == 2 && a_focus->widget_type == VSX_WIDGET_TYPE_2D_MENU_POPUP) { // in case of another menu being open before us if (a_focus != this) if (a_focus != parent) { a_focus->visible = 0; } } if (visible == 2) { hide_children(); over = 0; oversub = false; target_pos.y -= target_size.y; pos.y = target_pos.y; } visible = 1; a_focus = this; if (parent->widget_type != VSX_WIDGET_TYPE_2D_MENU_POPUP) { if (pos.x+size.x > 1) pos.x = 1-size.x; } } float sx = target_pos.x; float alpha = 0.8f; //if (!oversub) alpha = 1.0f; else alpha = 1.0f; //glBegin(GL_QUADS); if (parent->widget_type == VSX_WIDGET_TYPE_2D_MENU_POPUP) { if (((vsx_widget_popup_menu*)parent)->over && ((vsx_widget_popup_menu*)parent)->over != id_over) visible = 0; else { alpha = 1.0f; glColor4f(skin_color[0].r*alpha,skin_color[0].g,skin_color[0].b,skin_color[0].a*alpha); draw_box(vsx_vector((sx-0.001)*screen_aspect,target_pos.y+0.001+target_size.y),(size.x+0.002)*screen_aspect,-((float)menu_items.count())*row_size-0.002); } } else { glColor4f(skin_color[0].r*alpha,skin_color[0].g,skin_color[0].b,skin_color[0].a*alpha); draw_box(vsx_vector((sx-0.001)*screen_aspect,target_pos.y+0.001+target_size.y),(size.x+0.002)*screen_aspect,-((float)menu_items.count())*row_size-0.002); myf.print(vsx_vector(sx*screen_aspect,target_pos.y+target_size.y),parent->title,row_size); } double y = target_pos.y+target_size.y; vsx_command_s *t; menu_items.reset(); int c = 1; while ( (t = menu_items.get()) ) { if (c == over && over != 0) { current_command_over = t; glColor4f(skin_color[4].r,skin_color[4].g,skin_color[4].b,skin_color[4].a); if (t->cmd == "" && l_list.find(t->title) != l_list.end()) { vsx_widget_popup_menu* sub = ((vsx_widget_popup_menu*)l_list[t->title]); if (!sub->visible) { sub->visible = 2; sub->target_pos.x = target_pos.x+(1/screen_aspect)*row_size*(float)t->title.size()*0.33; sub->target_pos.y = y; sub->size = size; sub->id_over = over; } oversub = true; } else { oversub = false; } } else glColor4f(skin_color[1].r,skin_color[1].g,skin_color[1].b,skin_color[1].a*alpha); draw_box(vsx_vector((sx)*screen_aspect,y),size.x*screen_aspect,-row_size); myf.print(vsx_vector((sx+0.003)*screen_aspect,y-row_size),t->title,row_size*0.8); y-=row_size; ++c; } draw_children_2d(); } }
void vsx_widget_popup_menu::i_draw() { target_size.y = (float)(menu_items.count())*row_size; req(visible > 0.0f); if (a_focus->widget_type != VSX_WIDGET_TYPE_2D_MENU_POPUP && !FLOAT_EQUALS(visible, 2.0f) ) { visible = 0.0f; return; } // in case of another menu being open before us if (FLOAT_EQUALS(visible, 2.0f) && a_focus->widget_type == VSX_WIDGET_TYPE_2D_MENU_POPUP) if (a_focus != this) if (a_focus != parent) a_focus->visible = 0; if (FLOAT_EQUALS(visible, 2.0f)) { hide_children(); over = 0; oversub = false; target_pos.y -= target_size.y; pos.y = target_pos.y; } visible = 1.0f; a_focus = this; if (parent->widget_type != VSX_WIDGET_TYPE_2D_MENU_POPUP) if (pos.x+size.x > 1) pos.x = 1-size.x; float sx = target_pos.x; font.color = vsx_color<>(1,1,1,1); vsx_color<> background_color = vsx_widget_skin::get_instance()->get_color(0); glColor4f(background_color.r, background_color.g, background_color.b, 0.9f); // vsx_widget_skin::get_instance()->set_color_gl(0); if (parent->widget_type == VSX_WIDGET_TYPE_2D_MENU_POPUP) { if (((vsx_widget_popup_menu*)parent)->over && ((vsx_widget_popup_menu*)parent)->over != id_over) visible = 0; else draw_box(vsx_vector3<>((sx-0.001f)*screen_aspect,target_pos.y+0.001f+target_size.y),(size.x+0.002f)*screen_aspect,-((float)menu_items.count())*row_size-0.002f); } else if (draw_title) { draw_box(vsx_vector3<>((sx-0.001f)*screen_aspect,target_pos.y+0.001f+target_size.y),(size.x+0.002f)*screen_aspect,-((float)menu_items.count())*row_size-0.002f); font.print(vsx_vector3<>(sx*screen_aspect,target_pos.y+target_size.y), parent->title, row_size); } float y = target_pos.y+target_size.y; vsx_command_s *t; menu_items.reset(); int c = 1; while ( (t = menu_items.get()) ) { if (c == over && over != 0) { current_command_over = t; vsx_widget_skin::get_instance()->set_color_gl(4); if (t->cmd == "" && l_list.find(t->title) != l_list.end()) { vsx_widget_popup_menu* sub = ((vsx_widget_popup_menu*)l_list[t->title]); if (!(sub->visible > 0.0f)) { sub->visible = 2; sub->target_pos.x = target_pos.x+(1/screen_aspect)*row_size*(float)t->title.size()*0.33f; sub->target_pos.y = y; sub->size = size; sub->id_over = over; } oversub = true; } else { oversub = false; } } else vsx_widget_skin::get_instance()->set_color_gl(1); draw_box(vsx_vector3<>((sx)*screen_aspect,y),size.x*screen_aspect,-row_size); font.print(vsx_vector3<>((sx+0.003f)*screen_aspect,y-row_size),t->title,row_size*0.8f); y -= row_size; ++c; } draw_children_2d(); }