Page MenuHomePhabricator

evas_common: parse color in rgb()/rgba() format
ClosedPublic

Authored by ali.alzyod on Jul 12 2019, 3:22 PM.

Details

Summary

evas_common_format_color_parse: support rgb()/rgba() format

efl user can now specify colors in text formats and styles as rgb(0-255,0-255,0-255) & rgba(0-255,0-255,0-255,0-255) format.

This is related to task: T8068

Test Plan
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1

#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>

static void
_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
   efl_exit(0);
}

static void
_gui_setup()
{
   Eo *win, *box;

   win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
                 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
                 efl_text_set(efl_added, "Hello World"),
                 efl_ui_win_autodel_set(efl_added, EINA_TRUE));

   // when the user clicks "close" on a window there is a request to delete
   efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);

   box = efl_add(EFL_UI_BOX_CLASS, win,
                efl_content_set(win, efl_added),
                efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)));

   efl_add(EFL_UI_TEXT_CLASS, box,
           efl_text_markup_set(efl_added,
           "<color=rgb(255,0,0)>this is red color line(color = red)<color><br>"),
           efl_gfx_hint_weight_set(efl_added, 1.0, 0.9),
           efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
           efl_text_multiline_set(efl_added,EINA_TRUE),
           efl_pack(box, efl_added));

   efl_add(EFL_UI_BUTTON_CLASS, box,
           efl_text_set(efl_added, "Quit"),
           efl_gfx_hint_weight_set(efl_added, 1.0, 0.1),
           efl_pack(box, efl_added),
           efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
                                  _gui_quit_cb, efl_added));
}

EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   _gui_setup();
}
EFL_MAIN()

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ali.alzyod created this revision.Jul 12 2019, 3:22 PM

It seems that this patch has no reviewers specified. If you are unsure who can review your patch, please check this wiki page and see if anyone can be added: https://phab.enlightenment.org/w/maintainers_reviewers/

ali.alzyod requested review of this revision.Jul 12 2019, 3:22 PM
ali.alzyod retitled this revision from evas_common: parse color in rgb() formate to evas_common: parse color in rgb() format.Jul 12 2019, 3:26 PM
ali.alzyod edited the summary of this revision. (Show Details)
ali.alzyod edited the test plan for this revision. (Show Details)
ali.alzyod edited the summary of this revision. (Show Details)Jul 16 2019, 11:32 PM
ali.alzyod updated this revision to Diff 23541.Jul 20 2019, 5:31 AM
ali.alzyod edited the summary of this revision. (Show Details)
  • rgba and rgb
ali.alzyod retitled this revision from evas_common: parse color in rgb() format to evas_common: parse color in rgb()/rgba() format.Jul 20 2019, 5:32 AM
ali.alzyod edited the summary of this revision. (Show Details)
ali.alzyod edited the summary of this revision. (Show Details)Wed, Jul 24, 3:26 AM
ali.alzyod edited the summary of this revision. (Show Details)Wed, Jul 24, 11:32 PM

Nice patch, could you add a test to src/tests/evas?

ali.alzyod added a comment.EditedTue, Jul 30, 7:42 AM

@cedric Can you please suggest how to test this ?

I mean are there any similar case, in which you compare the output/content of canvas object with other object.

@cedric Can you please suggest how to test this ?

I was thinking of reading back the markup which I think is regenerated instead of being stored and so check that the color was properly understood.

ali.alzyod added a comment.EditedWed, Jul 31, 9:55 AM

@cedric the challenge is that markup saved as it is, I mean when you set color = "anytext", it will stay "anytext" even if is not understood internally.

regard to T8086
If possible and approved I like to move same functionality to efl_gfx_color where user can set string as color and internally efl understand it.
I think efl_gfx_color already have function for efl_gfx_color_color_code_set, now we can have efl_gfx_color_string_set and it will understand any string format color for colors

@cedric the challenge is that markup saved as it is, I mean when you set color = "anytext", it will stay "anytext" even if is not understood internally.

Dang, in that case, well, I do not have any good suggestion then. Will land this then.

regard to T8086
If possible and approved I like to move same functionality to efl_gfx_color where user can set string as color and internally efl understand it.
I think efl_gfx_color already have function for efl_gfx_color_color_code_set, now we can have efl_gfx_color_string_set and it will understand any string format color for colors

That proposal make sense.

Can you rebase this patch?

It does still fail to apply for me. Could you retry?

ali.alzyod updated this revision to Diff 23860.Thu, Aug 1, 4:00 PM

clear lines

cedric accepted this revision.Mon, Aug 19, 11:32 AM
This revision is now accepted and ready to land.Mon, Aug 19, 11:32 AM
This revision was automatically updated to reflect the committed changes.