-proper minimum size computation for TabContainer

This commit is contained in:
Juan Linietsky 2015-01-02 22:34:22 -03:00
parent 7a5a4d135e
commit d722537154
3 changed files with 40 additions and 2 deletions

View file

@ -8188,14 +8188,17 @@ void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int* p_indic
}
if (p_indices) {
static const int _max_draw_poly_indices = 8*1024; // change this size if needed!!!
#ifdef GLEW_ENABLED
glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices );
#else
static const int _max_draw_poly_indices = 16*1024; // change this size if needed!!!
ERR_FAIL_COND(p_vertex_count > _max_draw_poly_indices);
static uint16_t _draw_poly_indices[_max_draw_poly_indices];
for (int i=0; i<p_vertex_count; i++) {
_draw_poly_indices[i] = p_indices[i];
};
glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, _draw_poly_indices );
#endif
//glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices );
} else {
glDrawArrays(GL_TRIANGLES,0,p_vertex_count);

View file

@ -602,6 +602,39 @@ void TabContainer::get_translatable_strings(List<String> *p_strings) const {
}
Size2 TabContainer::get_minimum_size() const {
Size2 ms;
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
if (!c->has_meta("_tab_name"))
continue;
if (!c->is_visible())
continue;
Size2 cms = c->get_minimum_size();
ms.x=MAX(ms.x,cms.x);
ms.y=MAX(ms.y,cms.y);
}
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Font> font = get_font("font");
ms.y+=MAX(tab_bg->get_minimum_size().y,tab_fg->get_minimum_size().y);
ms.y+=font->get_height();
return ms;
}
void TabContainer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&TabContainer::_input_event);

View file

@ -85,6 +85,8 @@ public:
void set_current_tab(int p_current);
int get_current_tab() const;
virtual Size2 get_minimum_size() const;
virtual void get_translatable_strings(List<String> *p_strings) const;
TabContainer();