elm_code: Update resizing to reflect only the space that's required

This commit is contained in:
Andy Williams 2015-01-27 22:13:45 +00:00
parent 61912e962a
commit be7119c787
1 changed files with 17 additions and 10 deletions

View File

@ -55,15 +55,24 @@ _elm_code_widget_class_constructor(Eo_Class *klass EINA_UNUSED)
} }
static Eina_Bool static Eina_Bool
_elm_code_widget_resize(Evas_Object *o) _elm_code_widget_resize(Elm_Code_Widget_Data *pd)
{ {
Elm_Code_Line *line;
Eina_List *item;
int w, h, cw, ch; int w, h, cw, ch;
evas_object_geometry_get(o, NULL, NULL, &w, &h); if (!pd->code)
evas_object_textgrid_cell_size_get(o, &cw, &ch); return EINA_FALSE;
evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch);
evas_object_textgrid_size_set(o, ceil(((double) w) / cw), w = 0;
ceil(((double) h) / ch)); h = elm_code_file_lines_get(pd->code->file);
EINA_LIST_FOREACH(pd->code->file->lines, item, line)
if (line->length + 2 > w)
w = line->length + 2;
evas_object_textgrid_size_set(pd->grid, w, h);
evas_object_size_hint_min_set(pd->grid, w*cw, h*ch);
return h > 0 && w > 0; return h > 0 && w > 0;
} }
@ -110,7 +119,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget_Data *pd, Evas_Textgrid_Cell *cells,
unsigned int length, x; unsigned int length, x;
int w; int w;
if (!_elm_code_widget_resize(pd->grid)) if (!_elm_code_widget_resize(pd))
return; return;
length = line->length; length = line->length;
@ -153,10 +162,10 @@ _elm_code_widget_fill(Elm_Code_Widget_Data *pd)
{ {
Elm_Code_Line *line; Elm_Code_Line *line;
Evas_Textgrid_Cell *cells; Evas_Textgrid_Cell *cells;
int w, h, cw, ch; int w, h;
unsigned int y; unsigned int y;
if (!_elm_code_widget_resize(pd->grid)) if (!_elm_code_widget_resize(pd))
return; return;
evas_object_textgrid_size_get(pd->grid, &w, &h); evas_object_textgrid_size_get(pd->grid, &w, &h);
@ -167,8 +176,6 @@ _elm_code_widget_fill(Elm_Code_Widget_Data *pd)
cells = evas_object_textgrid_cellrow_get(pd->grid, y - 1); cells = evas_object_textgrid_cellrow_get(pd->grid, y - 1);
_elm_code_widget_fill_line(pd, cells, line); _elm_code_widget_fill_line(pd, cells, line);
} }
evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch);
evas_object_size_hint_min_set(pd->grid, w*cw, y*ch);
} }
static Eina_Bool static Eina_Bool