Page MenuHomePhabricator

elm_entry: password mode with (single line mode + scroller)
Needs ReviewPublic

Authored by ali.alzyod on Jul 24 2019, 8:04 AM.

Details

Summary

This contains fix for two cases
1- enable/disable password mode, will always change single line mode to single line mode.

=> new behaviour: enable/disable password, will use previous single line mode.

2- enable password, enable scroll, disable single line mode, scroller expand

=> new behaviour: scroller mode keep as it is.

Fix:

Test Plan

#include <Elementary.h>

enum BUTTON{

BUTTON_PASSWORD          = 0,
BUTTON_ALL               = BUTTON_PASSWORD+1,

};

char* BUTTON_STR[BUTTON_ALL] ={

"PASSWORD",

};

enum BUTTON_STATE{

BUTTON_STATE_SCROLL            = 0,
BUTTON_STATE_SINGLE_LINE       = 1,
BUTTON_STATE_ALL               = BUTTON_STATE_SINGLE_LINE + 1,

};

char* BUTTON_STATE_STR[BUTTON_STATE_ALL] ={

"SCROLL",
"SINGLE_LINE",

};

typedef struct _APP
{

Evas_Object *win, *box, *entry, *boxHor, *boxHor2;
Eo *btn[BUTTON_ALL];
Eo *btnState[BUTTON_STATE_ALL];
char * str;

} APP;
APP *app;

static void _btn_clicked(void *data, Eo *obj, void *eventInfo){

if (obj == app->btn[BUTTON_PASSWORD]){
    Eina_Bool bVal = elm_entry_password_get(app->entry);
    if(bVal)
       elm_entry_password_set(app->entry,EINA_FALSE);
    else
       elm_entry_password_set(app->entry,EINA_TRUE);
 }

}

static void _btn_state_clicked(void *data, Eo *obj, void *eventInfo)
{

if (obj == app->btnState[BUTTON_STATE_SCROLL]){
   Eina_Bool bValue = elm_entry_scrollable_get(app->entry);

   if(bValue == EINA_TRUE){
      elm_entry_scrollable_set(app->entry,EINA_FALSE);
   } else {
      elm_entry_scrollable_set(app->entry,EINA_TRUE);
   }
} else if (obj == app->btnState[BUTTON_STATE_SINGLE_LINE]){
   Eina_Bool bValue = elm_entry_single_line_get(app->entry);

   if(bValue == EINA_TRUE){
      elm_entry_single_line_set(app->entry,EINA_FALSE);
   } else {
      elm_entry_single_line_set(app->entry,EINA_TRUE);
   }

}

}

EAPI_MAIN int
elm_main(int argc, char **argv)
{

app = calloc(sizeof(APP), 1);

elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

app->win = elm_win_util_standard_add("Main", "App");
elm_win_autodel_set(app->win, EINA_TRUE);

app->box = elm_box_add(app->win);
app->boxHor = elm_box_add(app->box);
app->boxHor2 = elm_box_add(app->box);
app->entry = elm_entry_add(app->box);

elm_entry_input_panel_enabled_set(app->entry,EINA_TRUE);

elm_box_horizontal_set(app->boxHor, EINA_TRUE);
elm_box_horizontal_set(app->boxHor2, EINA_TRUE);

evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);

elm_entry_entry_set(app->entry, "<color=#F00>Hello</color>");
evas_object_show(app->entry);
evas_object_show(app->box);
evas_object_show(app->boxHor);
evas_object_show(app->boxHor2);

elm_box_pack_end(app->box, app->entry);
elm_box_pack_end(app->box, app->boxHor);
elm_box_pack_end(app->box, app->boxHor2);

elm_win_resize_object_add(app->win, app->box);
evas_object_resize(app->win, 320, 480);

for(int i = 0 ; i < BUTTON_ALL ; i++){
   app->btn[i] = elm_button_add(app->boxHor);
   evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL);\
   elm_object_text_set(app->btn[i], BUTTON_STR[i]);
   elm_box_pack_end(app->boxHor, app->btn[i]);
   evas_object_show(app->btn[i]);
}

for(int i = 0 ; i < BUTTON_STATE_ALL ; i++){
   app->btnState[i] = elm_button_add(app->boxHor2);
   evas_object_smart_callback_add(app->btnState[i], "clicked", _btn_state_clicked, NULL);
   elm_object_text_set(app->btnState[i], BUTTON_STATE_STR[i]);
   elm_box_pack_end(app->boxHor2, app->btnState[i]);
   evas_object_show(app->btnState[i]);
}


evas_object_size_hint_weight_set(app->entry, EVAS_HINT_EXPAND, 0.1);
evas_object_size_hint_align_set(app->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);

evas_object_show(app->win);

elm_run();

return 0;

}
ELM_MAIN()

Diff Detail

Repository
rEFL core/efl
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 12374
Build 8978: arc lint + arc unit
ali.alzyod created this revision.Jul 24 2019, 8:04 AM

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 24 2019, 8:04 AM
ali.alzyod edited the summary of this revision. (Show Details)Jul 24 2019, 8:07 AM
ali.alzyod edited the test plan for this revision. (Show Details)Jul 24 2019, 9:02 AM
ali.alzyod added reviewers: zmike, woohyun.
cedric requested changes to this revision.Jul 24 2019, 3:09 PM
cedric added reviewers: bu5hm4n, segfaultxavi, reviewers.

I am very much on the fence for this patch. The old behavior requiring application to set single line and password to get a proper password mode seems not the simplest way to solve this. Now this is a change in behavior. If any application did rely on this before, it will be broken with no way to fix it, but I don't really believe such an application. So I am starting request for change to get other people feedback.

With the new API this could be much more clean. There could be a password mode that does set everything (single mode, '*') and a set of specific independent call for doing all of that separately.

This revision now requires changes to proceed.Jul 24 2019, 3:09 PM

@cedric I want to add one more thing.
The idea if you enable mode then disable it, every thing should return to previous state.
Here the main problem is that password enable/disable doesnot care to save state, so after disable password you will always become in single line mode

So I am starting request for change to get other people feedback.

@cedric We did not get much feedback so far

ali.alzyod requested review of this revision.Sun, Oct 27, 10:43 PM