You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -28,29 +28,27 @@
|
||||
/*************************************************************************/
|
||||
#include "grid_container.h"
|
||||
|
||||
|
||||
void GridContainer::_notification(int p_what) {
|
||||
|
||||
switch(p_what) {
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_SORT_CHILDREN: {
|
||||
|
||||
Map<int,int> col_minw;
|
||||
Map<int,int> row_minh;
|
||||
Map<int, int> col_minw;
|
||||
Map<int, int> row_minh;
|
||||
Set<int> col_expanded;
|
||||
Set<int> row_expanded;
|
||||
|
||||
int hsep=get_constant("hseparation");
|
||||
int vsep=get_constant("vseparation");
|
||||
int hsep = get_constant("hseparation");
|
||||
int vsep = get_constant("vseparation");
|
||||
|
||||
int idx=0;
|
||||
int max_row=0;
|
||||
int max_col=0;
|
||||
int idx = 0;
|
||||
int max_row = 0;
|
||||
int max_col = 0;
|
||||
|
||||
Size2 size = get_size();
|
||||
|
||||
|
||||
for(int i=0;i<get_child_count();i++) {
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
|
||||
Control *c = get_child(i)->cast_to<Control>();
|
||||
if (!c || !c->is_visible())
|
||||
@@ -61,55 +59,54 @@ void GridContainer::_notification(int p_what) {
|
||||
|
||||
Size2i ms = c->get_combined_minimum_size();
|
||||
if (col_minw.has(col))
|
||||
col_minw[col] = MAX(col_minw[col],ms.width);
|
||||
col_minw[col] = MAX(col_minw[col], ms.width);
|
||||
else
|
||||
col_minw[col]=ms.width;
|
||||
col_minw[col] = ms.width;
|
||||
|
||||
if (row_minh.has(row))
|
||||
row_minh[row] = MAX(row_minh[row],ms.height);
|
||||
row_minh[row] = MAX(row_minh[row], ms.height);
|
||||
else
|
||||
row_minh[row]=ms.height;
|
||||
row_minh[row] = ms.height;
|
||||
|
||||
// print_line("store row "+itos(row)+" mw "+itos(ms.height));
|
||||
// print_line("store row "+itos(row)+" mw "+itos(ms.height));
|
||||
|
||||
if (c->get_h_size_flags()&SIZE_EXPAND)
|
||||
if (c->get_h_size_flags() & SIZE_EXPAND)
|
||||
col_expanded.insert(col);
|
||||
if (c->get_v_size_flags()&SIZE_EXPAND)
|
||||
if (c->get_v_size_flags() & SIZE_EXPAND)
|
||||
row_expanded.insert(row);
|
||||
|
||||
max_col=MAX(col,max_col);
|
||||
max_row=MAX(row,max_row);
|
||||
max_col = MAX(col, max_col);
|
||||
max_row = MAX(row, max_row);
|
||||
idx++;
|
||||
}
|
||||
|
||||
Size2 ms;
|
||||
int expand_rows=0;
|
||||
int expand_cols=0;
|
||||
int expand_rows = 0;
|
||||
int expand_cols = 0;
|
||||
|
||||
for (Map<int,int>::Element *E=col_minw.front();E;E=E->next()) {
|
||||
ms.width+=E->get();
|
||||
for (Map<int, int>::Element *E = col_minw.front(); E; E = E->next()) {
|
||||
ms.width += E->get();
|
||||
if (col_expanded.has(E->key()))
|
||||
expand_cols++;
|
||||
}
|
||||
|
||||
for (Map<int,int>::Element *E=row_minh.front();E;E=E->next()) {
|
||||
ms.height+=E->get();
|
||||
for (Map<int, int>::Element *E = row_minh.front(); E; E = E->next()) {
|
||||
ms.height += E->get();
|
||||
if (row_expanded.has(E->key()))
|
||||
expand_rows++;
|
||||
}
|
||||
|
||||
ms.height+=vsep*max_row;
|
||||
ms.width+=hsep*max_col;
|
||||
ms.height += vsep * max_row;
|
||||
ms.width += hsep * max_col;
|
||||
|
||||
int row_expand = expand_rows?(size.y-ms.y)/expand_rows:0;
|
||||
int col_expand = expand_cols?(size.x-ms.x)/expand_cols:0;
|
||||
int row_expand = expand_rows ? (size.y - ms.y) / expand_rows : 0;
|
||||
int col_expand = expand_cols ? (size.x - ms.x) / expand_cols : 0;
|
||||
|
||||
int col_ofs = 0;
|
||||
int row_ofs = 0;
|
||||
idx = 0;
|
||||
|
||||
int col_ofs=0;
|
||||
int row_ofs=0;
|
||||
idx=0;
|
||||
|
||||
for(int i=0;i<get_child_count();i++) {
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
|
||||
Control *c = get_child(i)->cast_to<Control>();
|
||||
if (!c || !c->is_visible())
|
||||
@@ -117,78 +114,74 @@ void GridContainer::_notification(int p_what) {
|
||||
int row = idx / columns;
|
||||
int col = idx % columns;
|
||||
|
||||
if (col==0) {
|
||||
col_ofs=0;
|
||||
if (row>0 && row_minh.has(row-1))
|
||||
row_ofs+=row_minh[row-1]+vsep+(row_expanded.has(row-1)?row_expand:0);
|
||||
if (col == 0) {
|
||||
col_ofs = 0;
|
||||
if (row > 0 && row_minh.has(row - 1))
|
||||
row_ofs += row_minh[row - 1] + vsep + (row_expanded.has(row - 1) ? row_expand : 0);
|
||||
}
|
||||
|
||||
Size2 s;
|
||||
if (col_minw.has(col))
|
||||
s.width=col_minw[col];
|
||||
s.width = col_minw[col];
|
||||
if (row_minh.has(row))
|
||||
s.height=row_minh[row];
|
||||
s.height = row_minh[row];
|
||||
|
||||
if (row_expanded.has(row))
|
||||
s.height+=row_expand;
|
||||
s.height += row_expand;
|
||||
if (col_expanded.has(col))
|
||||
s.width+=col_expand;
|
||||
s.width += col_expand;
|
||||
|
||||
Point2 p(col_ofs,row_ofs);
|
||||
Point2 p(col_ofs, row_ofs);
|
||||
|
||||
// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
|
||||
fit_child_in_rect(c,Rect2(p,s));
|
||||
// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
|
||||
fit_child_in_rect(c, Rect2(p, s));
|
||||
//print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s));
|
||||
|
||||
if (col_minw.has(col)) {
|
||||
col_ofs+=col_minw[col]+hsep+(col_expanded.has(col)?col_expand:0);
|
||||
col_ofs += col_minw[col] + hsep + (col_expanded.has(col) ? col_expand : 0);
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GridContainer::set_columns(int p_columns) {
|
||||
|
||||
ERR_FAIL_COND(p_columns<1);
|
||||
columns=p_columns;
|
||||
ERR_FAIL_COND(p_columns < 1);
|
||||
columns = p_columns;
|
||||
queue_sort();
|
||||
minimum_size_changed();
|
||||
|
||||
}
|
||||
|
||||
int GridContainer::get_columns() const{
|
||||
int GridContainer::get_columns() const {
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
void GridContainer::_bind_methods(){
|
||||
void GridContainer::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
|
||||
ObjectTypeDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
|
||||
ObjectTypeDB::bind_method(_MD("set_columns", "columns"), &GridContainer::set_columns);
|
||||
ObjectTypeDB::bind_method(_MD("get_columns"), &GridContainer::get_columns);
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),_SCS("set_columns"),_SCS("get_columns"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns", PROPERTY_HINT_RANGE, "1,1024,1"), _SCS("set_columns"), _SCS("get_columns"));
|
||||
}
|
||||
|
||||
Size2 GridContainer::get_minimum_size() const {
|
||||
|
||||
Map<int,int> col_minw;
|
||||
Map<int,int> row_minh;
|
||||
Map<int, int> col_minw;
|
||||
Map<int, int> row_minh;
|
||||
|
||||
int hsep=get_constant("hseparation");
|
||||
int vsep=get_constant("vseparation");
|
||||
int hsep = get_constant("hseparation");
|
||||
int vsep = get_constant("vseparation");
|
||||
|
||||
int idx=0;
|
||||
int max_row=0;
|
||||
int max_col=0;
|
||||
int idx = 0;
|
||||
int max_row = 0;
|
||||
int max_col = 0;
|
||||
|
||||
for(int i=0;i<get_child_count();i++) {
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
|
||||
Control *c = get_child(i)->cast_to<Control>();
|
||||
if (!c || !c->is_visible())
|
||||
@@ -197,39 +190,37 @@ Size2 GridContainer::get_minimum_size() const {
|
||||
int col = idx % columns;
|
||||
Size2i ms = c->get_combined_minimum_size();
|
||||
if (col_minw.has(col))
|
||||
col_minw[col] = MAX(col_minw[col],ms.width);
|
||||
col_minw[col] = MAX(col_minw[col], ms.width);
|
||||
else
|
||||
col_minw[col]=ms.width;
|
||||
col_minw[col] = ms.width;
|
||||
|
||||
if (row_minh.has(row))
|
||||
row_minh[row] = MAX(row_minh[row],ms.height);
|
||||
row_minh[row] = MAX(row_minh[row], ms.height);
|
||||
else
|
||||
row_minh[row]=ms.height;
|
||||
max_col=MAX(col,max_col);
|
||||
max_row=MAX(row,max_row);
|
||||
row_minh[row] = ms.height;
|
||||
max_col = MAX(col, max_col);
|
||||
max_row = MAX(row, max_row);
|
||||
idx++;
|
||||
}
|
||||
|
||||
Size2 ms;
|
||||
|
||||
for (Map<int,int>::Element *E=col_minw.front();E;E=E->next()) {
|
||||
ms.width+=E->get();
|
||||
for (Map<int, int>::Element *E = col_minw.front(); E; E = E->next()) {
|
||||
ms.width += E->get();
|
||||
}
|
||||
|
||||
for (Map<int,int>::Element *E=row_minh.front();E;E=E->next()) {
|
||||
ms.height+=E->get();
|
||||
for (Map<int, int>::Element *E = row_minh.front(); E; E = E->next()) {
|
||||
ms.height += E->get();
|
||||
}
|
||||
|
||||
ms.height+=vsep*max_row;
|
||||
ms.width+=hsep*max_col;
|
||||
ms.height += vsep * max_row;
|
||||
ms.width += hsep * max_col;
|
||||
|
||||
return ms;
|
||||
|
||||
}
|
||||
|
||||
|
||||
GridContainer::GridContainer() {
|
||||
|
||||
set_stop_mouse(false);
|
||||
columns=1;
|
||||
columns = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user