ui: button_add and tab_add.

Consistent tab sizing and button sizing.
This commit is contained in:
Alastair Poole 2020-06-21 17:14:35 +01:00
parent 700a21573d
commit 95f6967c5e
4 changed files with 69 additions and 35 deletions

View File

@ -1236,7 +1236,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_object_style_set(border, "pad_small");
evas_object_show(border);
btn = evisum_ui_button_add(parent, &ui->btn_general, _("General"),
btn = evisum_ui_tab_add(parent, &ui->btn_general, _("General"),
_tab_system_activity_clicked_cb, ui);
elm_object_disabled_set(ui->btn_general, EINA_TRUE);
elm_object_content_set(border, btn);
@ -1248,7 +1248,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_object_style_set(border, "pad_small");
evas_object_show(border);
btn = evisum_ui_button_add(parent, &ui->btn_cpu, _("CPU"),
btn = evisum_ui_tab_add(parent, &ui->btn_cpu, _("CPU"),
_tab_cpu_activity_clicked_cb, ui);
elm_object_content_set(border, btn);
elm_box_pack_end(hbox, border);
@ -1259,7 +1259,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_object_style_set(border, "pad_small");
evas_object_show(border);
btn = evisum_ui_button_add(parent, &ui->btn_mem, _("Memory"),
btn = evisum_ui_tab_add(parent, &ui->btn_mem, _("Memory"),
_tab_memory_activity_clicked_cb, ui);
elm_object_content_set(border, btn);
elm_box_pack_end(hbox, border);
@ -1270,7 +1270,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_object_style_set(border, "pad_small");
evas_object_show(border);
btn = evisum_ui_button_add(parent, &ui->btn_storage, _("Storage"),
btn = evisum_ui_tab_add(parent, &ui->btn_storage, _("Storage"),
_tab_disk_activity_clicked_cb, ui);
elm_object_content_set(border, btn);
elm_box_pack_end(hbox, border);
@ -1281,7 +1281,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
elm_object_style_set(border, "pad_small");
evas_object_show(border);
btn = evisum_ui_button_add(parent, &ui->btn_misc, _("Misc"),
btn = evisum_ui_tab_add(parent, &ui->btn_misc, _("Misc"),
_tab_misc_clicked_cb, ui);
elm_object_content_set(border, btn);
elm_box_pack_end(hbox, border);

View File

@ -583,7 +583,7 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
hbox = elm_box_add(parent);
evas_object_size_hint_weight_set(hbox, 0.5, EXPAND);
evas_object_size_hint_align_set(hbox, FILL, FILL);
evas_object_size_hint_align_set(hbox, FILL, 0);
elm_box_horizontal_set(hbox, EINA_TRUE);
evas_object_show(hbox);
elm_table_pack(table, hbox, 0, i, 2, 1);
@ -596,50 +596,38 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
elm_box_pack_end(hbox, border);
border = elm_frame_add(parent);
evas_object_size_hint_weight_set(border, 0.2, EXPAND);
evas_object_size_hint_align_set(border, FILL, 0.5);
evas_object_size_hint_align_set(border, FILL, FILL);
elm_object_style_set(border, "pad_small");
evas_object_show(border);
ui->btn_stop = button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
elm_object_text_set(button, _("Stop"));
evas_object_show(button);
evas_object_smart_callback_add(button, "clicked", _btn_stop_clicked_cb, ui);
button = evisum_ui_button_add(parent, &ui->btn_stop, _("Stop"),
_btn_stop_clicked_cb, ui);
ui->btn_stop = button;
elm_object_content_set(border, button);
elm_box_pack_end(hbox, border);
border = elm_frame_add(parent);
evas_object_size_hint_weight_set(border, 0.2, EXPAND);
evas_object_size_hint_align_set(border, FILL, 0.5);
evas_object_size_hint_align_set(border, FILL, FILL);
elm_object_style_set(border, "pad_small");
evas_object_show(border);
ui->btn_start = button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
elm_object_text_set(button, _("Start"));
button = evisum_ui_button_add(parent, &ui->btn_start, _("Start"),
_btn_start_clicked_cb, ui);
ui->btn_start = button;
elm_object_content_set(border, button);
evas_object_show(button);
elm_box_pack_end(hbox, border);
evas_object_smart_callback_add(button, "clicked", _btn_start_clicked_cb, ui);
border = elm_frame_add(parent);
evas_object_size_hint_weight_set(border, 0.2, EXPAND);
evas_object_size_hint_align_set(border, FILL, 0.5);
evas_object_size_hint_align_set(border, FILL, FILL);
elm_object_style_set(border, "pad_small");
evas_object_show(border);
ui->btn_kill = button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
elm_object_text_set(button, _("Kill"));
elm_box_pack_end(hbox, border);
evas_object_show(button);
button = evisum_ui_button_add(parent, &ui->btn_kill, _("Kill"),
_btn_kill_clicked_cb, ui);
ui->btn_kill = button;
elm_object_content_set(border, button);
evas_object_smart_callback_add(button, "clicked", _btn_kill_clicked_cb, ui);
elm_box_pack_end(hbox, border);
return frame;
}
@ -944,7 +932,7 @@ _tabs_add(Evas_Object *parent, Ui_Process *ui)
evas_object_size_hint_align_set(pad, FILL, FILL);
evas_object_show(pad);
btn = evisum_ui_button_add(parent, &ui->btn_main, _("Process"),
btn = evisum_ui_tab_add(parent, &ui->btn_main, _("Process"),
_btn_process_clicked_cb, ui);
elm_object_disabled_set(ui->btn_main, EINA_TRUE);
elm_object_content_set(pad, btn);
@ -956,7 +944,7 @@ _tabs_add(Evas_Object *parent, Ui_Process *ui)
evas_object_size_hint_align_set(pad, FILL, FILL);
evas_object_show(pad);
btn = evisum_ui_button_add(parent, &ui->btn_thread, _("Threads"),
btn = evisum_ui_tab_add(parent, &ui->btn_thread, _("Threads"),
_btn_threads_clicked_cb, ui);
elm_object_content_set(pad, btn);
elm_box_pack_end(hbox, pad);
@ -967,7 +955,7 @@ _tabs_add(Evas_Object *parent, Ui_Process *ui)
evas_object_size_hint_align_set(pad, FILL, FILL);
evas_object_show(pad);
btn = evisum_ui_button_add(parent, &ui->btn_info, _("Manual"),
btn = evisum_ui_tab_add(parent, &ui->btn_info, _("Manual"),
_btn_info_clicked_cb, ui);
elm_object_content_set(pad, btn);
elm_box_pack_end(hbox, pad);

View File

@ -3,7 +3,7 @@
#include "config.h"
Evas_Object *
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
Evas_Smart_Cb clicked_cb, void *data)
{
Evas_Object *tbl, *rect, *button, *label;
@ -42,6 +42,46 @@ evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
return tbl;
}
Evas_Object *
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
Evas_Smart_Cb clicked_cb, void *data)
{
Evas_Object *tbl, *rect, *button, *label;
tbl = elm_table_add(parent);
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
evas_object_size_hint_align_set(tbl, FILL, FILL);
rect = evas_object_rectangle_add(tbl);
evas_object_size_hint_weight_set(rect, EXPAND, EXPAND);
evas_object_size_hint_align_set(rect, FILL, FILL);
evas_object_size_hint_min_set(rect,
BTN_WIDTH * elm_config_scale_get(),
BTN_HEIGHT * elm_config_scale_get());
button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_show(button);
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
label = elm_label_add(parent);
evas_object_size_hint_weight_set(label, EXPAND, EXPAND);
evas_object_size_hint_align_set(label, FILL, FILL);
evas_object_show(label);
elm_object_text_set(label,
eina_slstr_printf("%s", text));
elm_layout_content_set(button, "elm.swallow.content", label);
elm_table_pack(tbl, rect, 0, 0, 1, 1);
elm_table_pack(tbl, button, 0, 0, 1, 1);
if (alias)
*alias = button;
return tbl;
}
const char *
evisum_size_format(unsigned long long bytes)
{

View File

@ -8,6 +8,12 @@
#define TAB_BTN_WIDTH 96
#define TAB_BTN_HEIGHT 32
#define BTN_WIDTH 80
#define BTN_HEIGHT 24
Evas_Object *
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
Evas_Smart_Cb clicked_cb, void *data);
Evas_Object *
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,