Dear All, Hi!
If the ctxpopup is vertical mode and it has too long text item to display,
then the text item is not compressed and the ctxpopup has vertical
scrollbar, horizontal scrollbar both.
User can scroll both sides and diagonally(?) also.
So, the attached patch will compress text item, when the text item is
too long to display.
Please review this patch and give any feedback. Thanks.
Sincerely,
Shinwoo Kim.
Index: src/lib/elc_ctxpopup.c
===================================================================
--- src/lib/elc_ctxpopup.c (revision 63873)
+++ src/lib/elc_ctxpopup.c (working copy)
@@ -1,6 +1,5 @@
#include <Elementary.h>
#include "elm_priv.h"
-
typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
@@ -25,10 +24,11 @@ struct _Widget_Data
Eina_List *items;
Elm_Ctxpopup_Direction dir;
Elm_Ctxpopup_Direction dir_priority[4];
- Evas_Coord max_sc_w, max_sc_h;
+ Evas_Coord max_sc_w, max_sc_h, compress_size;
Eina_Bool horizontal:1;
Eina_Bool visible:1;
Eina_Bool finished:1;
+ Eina_Bool compress:1;
};
static const char *widtype = NULL;
@@ -236,6 +236,7 @@ _parent_resize(void *data,
if (!wd) return;
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
_hide(data);
}
@@ -251,6 +252,7 @@ _parent_move(void *data,
if (!wd) return;
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
{
@@ -600,6 +602,23 @@ _show_signal_emit(Evas_Object *obj, Elm_Ctxpopup_D
}
static void
+_compress_item(Evas_Object *obj)
+{
+ Widget_Data *wd;
+ Eina_List *elist;
+ Elm_Ctxpopup_Item *item;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ EINA_LIST_FOREACH(wd->items, elist, item)
+ {
+ _elm_theme_object_set(obj, item->base.view, "ctxpopup", "item_compress", elm_widget_style_get(obj));
+ edje_object_part_text_set(item->base.view, "elm.text", item->label);
+ }
+}
+
+static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd;
@@ -635,12 +654,28 @@ _sizing_eval(Evas_Object *obj)
if (!wd->content)
{
- evas_object_size_hint_min_set(wd->box, box_size.x, box_size.y);
- evas_object_size_hint_min_set(wd->scr, box_size.x, box_size.y);
+ if(!wd->horizontal && wd->compress)
+ {
+ evas_object_size_hint_min_set(wd->box, wd->compress_size, box_size.y);
+ evas_object_size_hint_min_set(wd->scr, wd->compress_size, box_size.y);
+ }
+ else
+ {
+ evas_object_size_hint_min_set(wd->box, box_size.x, box_size.y);
+ evas_object_size_hint_min_set(wd->scr, box_size.x, box_size.y);
+ }
}
//Base
wd->dir = _calc_base_geometry(obj, &rect);
+
+ if (!wd->horizontal && box_size.x > rect.w)
+ {
+ wd->compress = EINA_TRUE;
+ wd->compress_size = rect.w;
+ _compress_item(obj);
+ }
+
_show_signal_emit(obj, wd->dir);
_update_arrow(obj, wd->dir);
_shift_base_by_arrow(wd->arrow, wd->dir, &rect);
@@ -754,6 +789,7 @@ _theme_hook(Evas_Object *obj)
}
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
{
@@ -785,6 +821,7 @@ _content_set_hook(Evas_Object *obj, const char *pa
wd->content = content;
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
_sizing_eval(obj);
@@ -1093,6 +1130,7 @@ elm_ctxpopup_add(Evas_Object *parent)
wd->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
wd->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _ctxpopup_show,
NULL);
@@ -1134,6 +1172,7 @@ elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Ev
_item_icon_set(ctxpopup_it, icon);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
{
@@ -1163,6 +1202,7 @@ elm_ctxpopup_item_label_set(Elm_Object_Item *it, c
_item_label_set(ctxpopup_it, label);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
{
@@ -1235,6 +1275,7 @@ elm_ctxpopup_clear(Evas_Object * obj)
_remove_items(wd);
_list_del(wd);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
}
EAPI void
@@ -1264,6 +1305,7 @@ elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina
}
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
_sizing_eval(obj);
@@ -1321,6 +1363,7 @@ elm_ctxpopup_item_append(Evas_Object *obj, const c
elm_box_pack_end(wd->box, item->base.view);
wd->items = eina_list_append(wd->items, item);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
if (wd->visible)
{
@@ -1352,6 +1395,7 @@ elm_ctxpopup_item_del(Elm_Object_Item *it)
wd->items = eina_list_remove(wd->items, ctxpopup_it);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ wd->compress = EINA_FALSE;
elm_widget_item_del(ctxpopup_it);
@@ -1363,7 +1407,6 @@ elm_ctxpopup_item_del(Elm_Object_Item *it)
if (wd->visible)
_sizing_eval(ctxpopup_it->base.widget);
-
}
EAPI void
Index: src/bin/test_ctxpopup.c
===================================================================
--- src/bin/test_ctxpopup.c (revision 63873)
+++ src/bin/test_ctxpopup.c (working copy)
@@ -57,7 +57,7 @@ _list_item_cb(void *data __UNUSED__, Evas_Object *
ctxpopup = elm_ctxpopup_add(obj);
- ITEM_NEW(ctxpopup, "Go to home folder", "home");
+ ITEM_NEW(ctxpopup, "Go to home folder, But you have a long and long name!", "home");
ITEM_NEW(ctxpopup, "Save file", "file");
ITEM_NEW(ctxpopup, "Delete file", "delete");
ITEM_NEW(ctxpopup, "Navigate to folder", "folder");
@@ -106,7 +106,7 @@ _list_item_cb3(void *data __UNUSED__, Evas_Object
ctxpopup = elm_ctxpopup_add(obj);
- ITEM_NEW(ctxpopup, "Eina", NULL);
+ ITEM_NEW(ctxpopup, "Oh, Eina! You have a long and long name too!", NULL);
ITEM_NEW(ctxpopup, "Eet", NULL);
ITEM_NEW(ctxpopup, "Evas", NULL);
ITEM_NEW(ctxpopup, "Ecore", NULL);
Index: data/themes/widgets/ctxpopup.edc
===================================================================
--- data/themes/widgets/ctxpopup.edc (revision 63873)
+++ data/themes/widgets/ctxpopup.edc (working copy)
@@ -914,3 +914,149 @@ group {
}
}
}
+///////////////////////////////////////////////////////////////////////////////
+group {
+ name: "elm/ctxpopup/item_compress/default";
+ images {
+ image: "hoversel_entry_bg.png" COMP;
+ }
+ parts {
+ part { name: "event";
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ }
+ }
+ part { name: "bg";
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ rel1.offset: 2 2;
+ rel2.offset: -3 -3;
+ image { normal:"hoversel_entry_bg.png";
+ border: 0 0 2 2;
+ }
+ fill.smooth: 0;
+ color: 255 255 255 0;
+ }
+ description { state: "clicked" 0.0;
+ inherit: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part { name: "elm.swallow.icon";
+ type: SWALLOW;
+ clip_to: "disclip";
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 25 25;
+ max: 25 25;
+ align: 0 0.5;
+ aspect: 1.0 1.0;
+ rel1 { offset: 10 10; }
+ rel2 { offset: 0 -10; }
+ }
+ }
+ part { name: "elm.text";
+ type: TEXT;
+ mouse_events: 0;
+ clip_to: "disclip";
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 1 40;
+ fixed: 0 1;
+ align: 0.5 0.5;
+ rel1 { relative: 1.0 0.0; to: "elm.swallow.icon"; offset: 10 0; }
+ rel2 { relative: 1.0 1.0; }
+ color: 255 255 255 255;
+ text {
+ font: "Sans";
+ size: 10;
+ min: 0 1;
+ align: 0.0 0.5;
+ }
+ }
+ description { state: "clicked" 0.0;
+ inherit: "default" 0.0;
+ color: 0 0 0 255;
+ }
+ }
+ part { name: "over1";
+ mouse_events: 1;
+ repeat_events: 1;
+ ignore_flags: ON_HOLD;
+ description { state: "default" 0.0;
+ color: 255 255 255 0;
+ }
+ description { state: "clicked" 0.0;
+ inherit: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part { name: "over2";
+ mouse_events: 1;
+ repeat_events: 1;
+ description { state: "default" 0.0;
+ color: 255 255 255 0;
+ }
+ description { state: "clicked" 0.0;
+ inherit: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part { name: "disclip";
+ type: RECT;
+ description { state: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ description { state: "enabled" 0.0;
+ color: 127 127 127 127;
+ }
+ }
+ part { name: "blocker";
+ description { state: "default" 0.0;
+ visible: 0;
+ }
+ description { state: "enabled" 0.0;
+ visible: 1;
+ color: 0 0 0 0;
+ }
+ }
+ }
+ programs {
+ program {
+ name: "item_unclick";
+ signal: "mouse,up,1";
+ source: "over1";
+ action: SIGNAL_EMIT "elm,action,click" "";
+ }
+ program { name: "disable";
+ signal: "elm,state,disabled";
+ source: "elm";
+ action: STATE_SET "enabled" 0.0;
+ target: "disclip";
+ target: "blocker";
+ }
+ program { name: "enable";
+ signal: "elm,state,enabled";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "disclip";
+ target: "blocker";
+ }
+ program { name: "item_click2";
+ signal: "mouse,down,1";
+ source: "over2";
+ script {
+ set_state(PART:"elm.text", "clicked", 0.0);
+ set_state(PART:"bg", "clicked", 0.0);
+ }
+ }
+ program { name: "item_unclick2";
+ signal: "mouse,up,1";
+ source: "over2";
+ script {
+ set_state(PART:"elm.text", "default", 0.0);
+ set_state(PART:"bg", "default", 0.0);
+ }
+ }
+ }
+}
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel