2

I'm developing a Galaxy Gear S2 application that makes use of a genlist to display information. One of the requirements of the application is that the genlist should have a orange background instead of an black one. I have been using this site as guidance.

I have changed the background of the window but the the windows background seems to be behind the genlist background. What this means is that the background color only shows when changing between windows.

The genlist looks as follows.

static void create_first_list(appdata_s *ad){
    Evas_Object *genlist = NULL;
    Evas_Object *naviframe = ad ->naviframe;
    Elm_Object_Item *nf_it = NULL;
    Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
    Elm_Genlist_Item_Class *titc = elm_genlist_item_class_new();
    Elm_Genlist_Item_Class *pitc = elm_genlist_item_class_new();
    item_data *id = NULL;
    int index = 0;

    local_ad = ad;

    genlist = elm_genlist_add(naviframe);
    elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
    evas_object_smart_callback_add(genlist, "selected", NULL, NULL);

    ad->circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
    eext_circle_object_genlist_scroller_policy_set(ad->circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
    eext_rotary_object_event_activated_set(ad->circle_genlist, EINA_TRUE);

    itc->item_style = "1text";
    itc->func.text_get = _gl_main_text_getfirst;
    itc->func.del = _gl_menu_del;
    titc->item_style = "title";
    titc->func.text_get = _gl_title_text_get;
    titc->func.del = _gl_menu_del;
    pitc->item_style = "padding";
    elm_genlist_item_append(genlist, titc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, ad);
    id = calloc(sizeof(item_data), 1);
    id->index = index++;
    id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, btn_cb_connect, ad);
    elm_genlist_item_append(genlist, pitc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, ad);


    elm_genlist_item_class_free(titc);
    elm_genlist_item_class_free(itc);
    elm_genlist_item_class_free(pitc);
    local_ad->naviframe = naviframe;

    nf_it = elm_naviframe_item_push(naviframe, NULL, NULL, NULL, genlist, "empty");
    elm_naviframe_item_pop_cb_set(nf_it, _naviframe_pop_cb, ad->win);
}

This genlist only contains one item in it. I have attemped to change the background color by performing the following in the genlist generating method.

elm_bg_color_set(genlist, 255, 168, 0);

This does not work to change the background of the genlist. Is there a way to change the entire genlist background? If so, how?

Jonathan
  • 545
  • 1
  • 8
  • 27

2 Answers2

2

You can add custom genlist style:

collections {
images {
    image: "bg.png" COMP;
}
group {
    name: "elm/genlist/base/custom";
    parts {
        part { // Here you can set solid bg color
            name: "bg";
            type: RECT;
            description {
                color: 231 232 142 255; 
            }
        }
        part { // And any image as bg here
            name: "bg_image";
            type: IMAGE;
            description {
                image.normal: "bg.png"; 
            }
        }
        part {
            name: "pd.top";
            type: SPACER;
            description {
                min: 0 30;
                max: -1 30;
                fixed: 0 1;
                align: 0.5 0.0;
            }
        }
        part {
            name: "elm.swallow.content";
            type: SWALLOW;
            description {
                rel1 {
                    relative: 0.0 1.0;
                    to_y: "pd.top";
                }
            }
        }
    }
}

Extend default theme with the style:

elm_theme_extension_add(NULL, "path_to_file_containing_custom_style.edj");

And apply to genlist:

elm_object_style_set(genlist, "custom");
-1

You create Background Elementary Widget with elm_bg_add() but you did not set it visible.

And If you created window with elm_win_util_standard_add(). default background was created already in window.

So use elm_win_add() and elm_bg_add() separately.

Following code is implementation of elm_win_util_standard_add(). Just do like this code and change color of bg.

EAPI Evas_Object *
elm_win_util_standard_add(const char *name, const char *title)
{
   Evas_Object *win, *bg;

   win = elm_win_add(NULL, name, ELM_WIN_BASIC);
   if (!win) return NULL;

   elm_win_title_set(win, title);
   bg = elm_bg_add(win);
   if (!bg)
     {
        evas_object_del(win);
        return NULL;
     }
   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, bg);
   evas_object_show(bg);

   return win;
}
Jonathan
  • 545
  • 1
  • 8
  • 27
pius lee
  • 1,164
  • 1
  • 12
  • 28
  • This works great for setting the background color of the window, so when changing windows it flashes the color. But it does not change the background of the genlist. Is it even possible to change the background color of an entire genlist? – Jonathan Jan 20 '17 at 06:16