I am ashamed that I need to ask this question, but my searching has found nothing and the documentation is unhelpful and borderline unusable.
I have (based on the native watchface template):
Window
Conformant
Box
Three labels
Code:
static void
create_base_gui(appdata_s *ad, int width, int height)
{
int ret;
watch_time_h watch_time = NULL;
/* Window */
ret = watch_app_get_elm_win(&ad->win);
if (ret != APP_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
return;
}
evas_object_resize(ad->win, width, height);
/* Conformant */
ad->conform = elm_conformant_add(ad->win);
evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win, ad->conform);
evas_object_show(ad->conform);
/* Box */
ad->box = elm_box_add(ad->win);
evas_object_size_hint_weight_set(ad->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ad->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(ad->conform, ad->box); // what does this do? do I need it?
evas_object_show(ad->box);
/* Time label*/
ad->time_label = elm_label_add(ad->conform);
evas_object_resize(ad->time_label, width, height / 3);
//evas_object_move(ad->time_label, 0, height / 3);
evas_object_size_hint_weight_set(ad->time_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//evas_object_size_hint_align_set(ad->time_label, 0.5, 0.5);
evas_object_show(ad->time_label);
elm_box_pack_end(ad->box, ad->time_label);
/* Date label*/
ad->date_label = elm_label_add(ad->box);
evas_object_resize(ad->date_label, width, height / 3);
//evas_object_move(ad->time_label, 0, height / 3);
evas_object_size_hint_weight_set(ad->date_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//evas_object_size_hint_align_set(ad->date_label, 0.5, 0.5);
evas_object_show(ad->date_label);
elm_box_pack_start(ad->box, ad->date_label);
/* Battery label */
ad->battery_label = elm_label_add(ad->box);
evas_object_resize(ad->battery_label, width, height / 3);
//evas_object_move(ad->time_label, 0, height / 3);
evas_object_size_hint_weight_set(ad->battery_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//evas_object_size_hint_align_set(ad->battery_label, 0.5, 0.5);
evas_object_show(ad->battery_label);
elm_box_pack_end(ad->box, ad->battery_label);
//elm_box_align_set(ad->box, 0.5, 0.5);
ret = watch_time_get_current_time(&watch_time);
if (ret != APP_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);
update_watch(ad, watch_time, 0);
watch_time_delete(watch_time);
/* Show window after base gui is set up */
evas_object_show(ad->win);
}
I’ve tried everything I can think of, but the box is never centered within the screen. It’s always stuck to the top-left corner, but all the labels are attached within the box. Screenshot attached:
How to center a box?
I am ashamed that I need to ask this question, but my searching has found nothing and the documentation is unhelpful and borderline unusable.
I have (based on the native watchface template):
Code:
I’ve tried everything I can think of, but the box is never centered within the screen. It’s always stuck to the top-left corner, but all the labels are attached within the box. Screenshot attached:
What is the code to center the box on the screen?
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio