Languages

Menu
Sites
Language
Scroller within Box

Hi All,

I am trying to develop terms and condition screen. Where I have a box and inside that a scrollable area (scroller) where user can scroll the terms & condition text message.

I have written following sample code. But I am not able to see any content on the screen. 

What is the wrong with the below code?

    Evas_Object *main_box = elm_box_add(ad->nframe);
    evas_object_size_hint_weight_set(main_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(main_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(main_box);

//Here I will add header ("Terms of Use") and progress bar in box. Then comes below scroller.

    Evas_Object *scroller = elm_scroller_add(main_box);
    elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
    elm_scroller_page_size_set(scroller, 100, 100);
    elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_ON,ELM_SCROLLER_POLICY_ON);
    elm_box_pack_end(main_box, scroller);
    evas_object_show(scroller);


    Evas_Object *terms_of_use_text = elm_label_add(scroller);
    std::string msg_text;
    msg_text.assign("<p><wrap=word><color='#000000'>");
    msg_text.append("My personal terms of use. This text should be visible in scrollable area.");
    msg_text.append("</color></word></p>");
    elm_object_text_set(terms_of_use_text, msg_text.c_str());
    evas_object_size_hint_weight_set(terms_of_use_text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(terms_of_use_text, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_min_set(terms_of_use_text, 500, 500);

    evas_object_show(terms_of_use_text);
    elm_object_content_set(scroller, terms_of_use_text);

    elm_naviframe_item_push(ad->nframe, "Hello", NULL, NULL, main_box, NULL);

 

Please help.

Edited by: Dharmesh Guna on 30 Jun, 2015

Responses

3 Replies
Carsten Haitzler

first...

evas_object_size_hint_min_set(terms_of_use_text, 500, 500);

is "wrong". the label will later calculate its own min size. all you do is fight. only a few widgets allow you to set a min size. as wel as basic evas objects (evas text, textblock, rect, image, etc. as oppsoed to elm widgets). only elm grid allows you to set min size as it never calculates a min size . so don't do that. just an aside - why create a c++ stdstring? isn't it far simpler to:

elm_object_text_set(terms_of_use_text, "<p><wrap=word><color='#000000'>"
                                                                   "My personal terms of use. This text should be visible in scrollable area."
                                                                   "</color></word></p>");

?

also your markup should be:

"<p><wrap=word><color='#000000'>"
"My personal terms of use. This text should be visible in scrollable area."
"</color></wrap></p>"

you can even shorten the closing tags:

"<p><wrap=word><color='#000000'>"
"My personal terms of use. This text should be visible in scrollable area."
"</></></>"

:)

anyway - that aside. the core reason i think is the box the scroller is being packed into. i bet the bos is not expanding the scroller. right? it's a vertical box. is the vertical box not expaned - eg by it being a resize object of the window etc? anyway - main box has to somehow expand (eg its parent causes it to expand). the other and actual initial problem is you have no hints on the scroller to expand. by default all objects want to pack at their minimum size. the scrollers minimum size is.. well rather small. so set it to expand (and fill) its parent allocation:

evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);

FYI elementary has a huge amount of examples on how to create widgets and pack them in elementary_test. its a test/demo tool. the src code is easy to find:

https://git.enlightenment.org/core/elementary.git/tree/src/bin

all the test_*.c fiels are the src for the tests in elementary_test. in the gui just click the button ofr that test - a window appears. the src here for thattest is in the file names similarly to the tests. :) use this as a big collection of sample code on how to build UIs with elementary. it's pretty complete.

 

 

 

 

Dharmesh Guna

Hi Carsten Haitzler,

Thank you so much for the detailed explanation.

It got resolved by adding weight and align hints.

The git link you shared will help me a lot for UI development.

Thank you.

Carsten Haitzler

no worries. :) btw - i only sometimes look in to the forums. they are pretty inconvenient for keeping up with vs email. as a general note here, you could/should also try contacting the enlightenment mailing lists too - thats where core efl developers "hang out" and do their work and it has a lot more traffic and people who know efl - the toolkit apis for widets/ui that you are using. we'd also point you to the src code for examples etc.

i find that very few peolpe know of or look at the src for information. the test code was built for 2 reasons. one to test features and another to serve as an example of how to use these apis and features. it won't over everything, but at least 80-90%, and for other thngs there is yet more code buried in apps like terminology, rage, enlightenment itself and many others too besides. git.enlightenment.org has a LOT of source code to go over for hints and ideas. asking for what you want can lead to a pointer to the right bit of src to look at. if there isnt a known example, then better answers can be given. tizen of course has good docs too on efl. i'mjust saying - don't ONLY use this and assume nothing else exists. we are pulling more documentation together on our primary wiki:

https://www.enlightenment.org/docs

there's even a c primer for those not used to c. combine that with other books on c and sample code and you should be doing well. then use a lot of the source that is public as reference. :)