forked from enlightenment/efl
new elm api - more evas liek and evas/edje freindly. i can mvoe forward now.
SVN revision: 36487
This commit is contained in:
parent
40655e28d5
commit
e8ef0d8bab
|
@ -56,7 +56,7 @@ collections {
|
|||
}
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.contents";
|
||||
part { name: "elm.swallow.content";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
rel1.offset: 4 4;
|
||||
|
@ -398,7 +398,7 @@ collections {
|
|||
image.normal: "bt_base1.png";
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.contents";
|
||||
part { name: "elm.swallow.content";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
|
@ -423,7 +423,7 @@ collections {
|
|||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
rel1.to_x: "elm.swallow.contents";
|
||||
rel1.to_x: "elm.swallow.content";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel1.offset: 0 4;
|
||||
rel2.offset: -5 -5;
|
||||
|
@ -501,13 +501,13 @@ collections {
|
|||
signal: "elm,state,icon,visible";
|
||||
source: "elm";
|
||||
action: STATE_SET "visible" 0.0;
|
||||
target: "elm.swallow.contents";
|
||||
target: "elm.swallow.content";
|
||||
}
|
||||
program { name: "icon_hide";
|
||||
signal: "elm,state,icon,hidden";
|
||||
source: "elm";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "elm.swallow.contents";
|
||||
target: "elm.swallow.content";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ collections {
|
|||
}
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.contents";
|
||||
part { name: "elm.swallow.content";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
|
@ -720,7 +720,7 @@ collections {
|
|||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
rel1.to_x: "elm.swallow.contents";
|
||||
rel1.to_x: "elm.swallow.content";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel1.offset: 0 4;
|
||||
rel2.to_x: "bg";
|
||||
|
@ -790,13 +790,13 @@ collections {
|
|||
signal: "elm,state,icon,visible";
|
||||
source: "elm";
|
||||
action: STATE_SET "visible" 0.0;
|
||||
target: "elm.swallow.contents";
|
||||
target: "elm.swallow.content";
|
||||
}
|
||||
program { name: "icon_hide";
|
||||
signal: "elm,state,icon,hidden";
|
||||
source: "elm";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "elm.swallow.contents";
|
||||
target: "elm.swallow.content";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2141,7 +2141,7 @@ collections {
|
|||
image.normal: "bt_base1.png";
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.contents";
|
||||
part { name: "elm.swallow.content";
|
||||
type: SWALLOW;
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
|
@ -2162,7 +2162,7 @@ collections {
|
|||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 1.0;
|
||||
rel1.to_x: "elm.swallow.contents";
|
||||
rel1.to_x: "elm.swallow.content";
|
||||
rel1.relative: 1.0 1.0;
|
||||
rel1.offset: 0 -5;
|
||||
rel2.offset: -5 -5;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -61,104 +61,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// FIXME: need to be able to enable/disable widgets
|
||||
// FIXME: need to determine scale from dpi
|
||||
/* Types here */
|
||||
typedef enum _Elm_Obj_Type
|
||||
{
|
||||
ELM_OBJ_OBJ,
|
||||
ELM_OBJ_CB,
|
||||
ELM_OBJ_WIDGET,
|
||||
ELM_OBJ_WIN,
|
||||
ELM_OBJ_BG,
|
||||
ELM_OBJ_SCROLLER,
|
||||
ELM_OBJ_LABEL,
|
||||
ELM_OBJ_BOX,
|
||||
ELM_OBJ_TABLE,
|
||||
ELM_OBJ_BUTTON,
|
||||
ELM_OBJ_ICON,
|
||||
ELM_OBJ_TOGGLE,
|
||||
ELM_OBJ_CLOCK,
|
||||
ELM_OBJ_FRAME,
|
||||
ELM_OBJ_PAD,
|
||||
ELM_OBJ_CONTACTLIST
|
||||
// ELM_OBJ_CHECK, // FIXME: do
|
||||
// ELM_OBJ_RADIO, // FIXME: do
|
||||
// ELM_OBJ_SEP, // FIXME: do (separator horiz or vert)
|
||||
// ELM_OBJ_EXPANDER // FIXME: do (like a paned but slides open/closed)
|
||||
// ELM_OBJ_SPIN, // FIXME: do
|
||||
// ELM_OBJ_SLIDER, // FIXME: do
|
||||
// ELM_OBJ_ENTRY, // FIXME: do
|
||||
// ELM_OBJ_EDITOR, // FIXME: do
|
||||
// ELM_OBJ_LISTITEM, // FIXME: do
|
||||
// ELM_OBJ_BUSY, // FIXME: do
|
||||
// // FIXME: list more widgets to do here like:
|
||||
// // CONTACT, SELECTOR, FILES, PREVIEW, SIGNALINFO, CALLINFO,
|
||||
// // CELLEDIT (csv - maybe later xls or some other cell format),
|
||||
// // COLORSEL, TACHO ...
|
||||
//
|
||||
// wrap other basic ecore things:
|
||||
// ELM_OBJ_TIMER,
|
||||
// ELM_OBJ_ANIMATOR,
|
||||
// ELM_OBJ_JOB,
|
||||
} Elm_Obj_Type;
|
||||
|
||||
typedef enum _Elm_Cb_Type
|
||||
{
|
||||
ELM_CB_DEL,
|
||||
ELM_CB_CHILD_ADD,
|
||||
ELM_CB_CHILD_DEL,
|
||||
ELM_CB_UNPARENT,
|
||||
ELM_CB_PARENT,
|
||||
ELM_CB_DEL_REQ,
|
||||
ELM_CB_RESIZE,
|
||||
ELM_CB_CHANGED,
|
||||
ELM_CB_ACTIVATED
|
||||
} Elm_Cb_Type;
|
||||
|
||||
/**************************************************************************/
|
||||
/* Objects */
|
||||
typedef enum _Elm_Win_Type
|
||||
{
|
||||
ELM_WIN_BASIC,
|
||||
ELM_WIN_DIALOG_BASIC
|
||||
} Elm_Win_Type;
|
||||
|
||||
typedef struct _Elm_Obj_Class Elm_Obj_Class;
|
||||
typedef struct _Elm_Obj Elm_Obj;
|
||||
typedef struct _Elm_Cb_Class Elm_Cb_Class;
|
||||
typedef struct _Elm_Cb Elm_Cb;
|
||||
typedef struct _Elm_Win_Class Elm_Win_Class;
|
||||
typedef struct _Elm_Win Elm_Win;
|
||||
typedef struct _Elm_Widget_Class Elm_Widget_Class;
|
||||
typedef struct _Elm_Widget Elm_Widget;
|
||||
typedef struct _Elm_Bg_Class Elm_Bg_Class;
|
||||
typedef struct _Elm_Bg Elm_Bg;
|
||||
typedef struct _Elm_Scroller_Class Elm_Scroller_Class;
|
||||
typedef struct _Elm_Scroller Elm_Scroller;
|
||||
typedef struct _Elm_Label_Class Elm_Label_Class;
|
||||
typedef struct _Elm_Label Elm_Label;
|
||||
typedef struct _Elm_Box_Class Elm_Box_Class;
|
||||
typedef struct _Elm_Box Elm_Box;
|
||||
typedef struct _Elm_Table_Class Elm_Table_Class;
|
||||
typedef struct _Elm_Table Elm_Table;
|
||||
typedef struct _Elm_Button_Class Elm_Button_Class;
|
||||
typedef struct _Elm_Button Elm_Button;
|
||||
typedef struct _Elm_Icon_Class Elm_Icon_Class;
|
||||
typedef struct _Elm_Icon Elm_Icon;
|
||||
typedef struct _Elm_Toggle_Class Elm_Toggle_Class;
|
||||
typedef struct _Elm_Toggle Elm_Toggle;
|
||||
typedef struct _Elm_Clock_Class Elm_Clock_Class;
|
||||
typedef struct _Elm_Clock Elm_Clock;
|
||||
typedef struct _Elm_Frame_Class Elm_Frame_Class;
|
||||
typedef struct _Elm_Frame Elm_Frame;
|
||||
typedef struct _Elm_Pad_Class Elm_Pad_Class;
|
||||
typedef struct _Elm_Pad Elm_Pad;
|
||||
typedef struct _Elm_Contactlist_Class Elm_Contactlist_Class;
|
||||
typedef struct _Elm_Contactlist Elm_Contactlist;
|
||||
|
||||
typedef void (*Elm_Cb_Func) (void *data, Elm_Obj *obj, Elm_Cb_Type type, void *info);
|
||||
|
||||
/* API calls here */
|
||||
|
||||
/**************************************************************************/
|
||||
/* General calls */
|
||||
EAPI void elm_init(int argc, char **argv);
|
||||
|
@ -166,414 +76,92 @@ extern "C" {
|
|||
EAPI void elm_run(void);
|
||||
EAPI void elm_exit(void);
|
||||
|
||||
/**************************************************************************/
|
||||
/* Generic Elm Object */
|
||||
#define Elm_Obj_Class_Methods \
|
||||
void (*del) (Elm_Obj *obj); \
|
||||
void (*ref) (Elm_Obj *obj); \
|
||||
void (*unref) (Elm_Obj *obj); \
|
||||
Elm_Cb *(*cb_add) (Elm_Obj *obj, Elm_Cb_Type type, Elm_Cb_Func func, void *data); \
|
||||
void (*child_add) (Elm_Obj *obj, Elm_Obj *child); \
|
||||
void (*unparent) (Elm_Obj *obj); \
|
||||
int (*hastype) (Elm_Obj *obj, Elm_Obj_Type type)
|
||||
#define Elm_Obj_Class_All Elm_Obj_Class_Methods; \
|
||||
Elm_Obj_Type type; \
|
||||
void *clas; /* the obj class and parent classes */ \
|
||||
Elm_Obj *parent; \
|
||||
Evas_List *children; \
|
||||
Evas_List *cbs; \
|
||||
int refs; \
|
||||
unsigned char delete_me : 1; \
|
||||
unsigned char delete_deferred : 1
|
||||
EAPI Evas_Object *elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type);
|
||||
EAPI void elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj);
|
||||
EAPI void elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj);
|
||||
EAPI void elm_win_title_set(Evas_Object *obj, const char *title);
|
||||
EAPI void elm_win_autodel_set(Evas_Object *obj, Evas_Bool autodel);
|
||||
EAPI void elm_win_activate(Evas_Object *obj);
|
||||
EAPI void elm_win_borderless_set(Evas_Object *obj, Evas_Bool borderless);
|
||||
EAPI void elm_win_shaped_set(Evas_Object *obj, Evas_Bool shaped);
|
||||
EAPI void elm_win_alpha_set(Evas_Object *obj, Evas_Bool alpha);
|
||||
EAPI void elm_win_override_set(Evas_Object *obj, Evas_Bool override);
|
||||
// FIXME: implement more of the above calls
|
||||
/* smart callbacks elm_win objects will call:
|
||||
* "delete-request" - the user requested to delete the window
|
||||
*/
|
||||
|
||||
struct _Elm_Obj_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Obj_Class_Methods;
|
||||
};
|
||||
struct _Elm_Obj
|
||||
{
|
||||
Elm_Obj_Class_All;
|
||||
};
|
||||
#define ELM_OBJ(o) ((Elm_Obj *)o)
|
||||
EAPI Evas_Object *elm_bg_add(Evas_Object *parent);
|
||||
EAPI void elm_bg_file_set(Evas_Object *obj, const char *file, const char *group);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
/**************************************************************************/
|
||||
/* Callback Object */
|
||||
#define Elm_Cb_Class_Methods
|
||||
#define Elm_Cb_Class_All Elm_Obj_Class_All; Elm_Cb_Class_Methods; \
|
||||
Elm_Cb_Class_Methods; \
|
||||
Elm_Cb_Type cb_type; \
|
||||
Elm_Cb_Func func; \
|
||||
void *data;
|
||||
struct _Elm_Cb_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Cb_Class_Methods;
|
||||
};
|
||||
struct _Elm_Cb
|
||||
{
|
||||
Elm_Cb_Class_All;
|
||||
};
|
||||
EAPI Evas_Object *elm_icon_add(Evas_Object *parent);
|
||||
EAPI void elm_icon_file_set(Evas_Object *obj, const char *file, const char *group);
|
||||
EAPI void elm_icon_smooth_set(Evas_Object *obj, Evas_Bool smooth);
|
||||
EAPI void elm_icon_no_scale_set(Evas_Object *obj, Evas_Bool no_scale);
|
||||
EAPI void elm_icon_scale_set(Evas_Object *obj, Evas_Bool scale_up, Evas_Bool scale_down);
|
||||
EAPI void elm_icon_fill_outside_set(Evas_Object *obj, Evas_Bool fill_outside);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
/**************************************************************************/
|
||||
/* Widget Object */
|
||||
#define Elm_Widget_Class_Methods \
|
||||
void (*geom_set) (Elm_Widget *wid, int x, int y, int w, int h); \
|
||||
void (*show) (Elm_Widget *wid); \
|
||||
void (*hide) (Elm_Widget *wid); \
|
||||
void (*size_alloc) (Elm_Widget *wid, int w, int h); \
|
||||
void (*size_req) (Elm_Widget *wid, Elm_Widget *child, int w, int h); \
|
||||
void (*above) (Elm_Widget *wid, Elm_Widget *above); \
|
||||
void (*below) (Elm_Widget *wid, Elm_Widget *below)
|
||||
EAPI Evas_Object *elm_box_add(Evas_Object *parent);
|
||||
EAPI void elm_box_horizontal_set(Evas_Object *obj, Evas_Bool horizontal);
|
||||
EAPI void elm_box_homogenous_set(Evas_Object *obj, Evas_Bool homogenous);
|
||||
EAPI void elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj);
|
||||
EAPI void elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj);
|
||||
EAPI void elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before);
|
||||
EAPI void elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
#define Elm_Widget_Class_All Elm_Obj_Class_All; Elm_Widget_Class_Methods; \
|
||||
int x, y, w, h; \
|
||||
struct { int w, h; } req; \
|
||||
Evas_Object *base; \
|
||||
double align_x, align_y; \
|
||||
unsigned char expand_x : 1; \
|
||||
unsigned char expand_y : 1; \
|
||||
unsigned char fill_x : 1; \
|
||||
unsigned char fill_y : 1
|
||||
EAPI Evas_Object *elm_button_add(Evas_Object *parent);
|
||||
EAPI void elm_button_label_set(Evas_Object *obj, const char *label);
|
||||
EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
* "clicked" - the user clicked the button
|
||||
*/
|
||||
|
||||
/* Object specific ones */
|
||||
// FIXME: should this be a function or widget method call?
|
||||
EAPI void elm_widget_sizing_update(Elm_Widget *wid);
|
||||
struct _Elm_Widget_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Widget_Class_Methods;
|
||||
};
|
||||
struct _Elm_Widget
|
||||
{
|
||||
Elm_Widget_Class_All;
|
||||
};
|
||||
EAPI Evas_Object *elm_scroller_add(Evas_Object *parent);
|
||||
EAPI void elm_scroller_child_set(Evas_Object *obj, Evas_Object *child);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
EAPI Evas_Object *elm_label_add(Evas_Object *parent);
|
||||
EAPI void elm_label_label_set(Evas_Object *obj, const char *label);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
/**************************************************************************/
|
||||
/* Window Object */
|
||||
#define Elm_Win_Class_Methods \
|
||||
void (*name_set) (Elm_Win *win, const char *name); \
|
||||
void (*title_set) (Elm_Win *win, const char *title)
|
||||
// FIXME:
|
||||
// cover methods & state for:
|
||||
// type, fullscreen, icon, activate, shaped, alpha, borderless, iconified,
|
||||
// setting parent window (for dialogs)
|
||||
#define Elm_Win_Class_All Elm_Widget_Class_All; Elm_Win_Class_Methods; \
|
||||
Elm_Win_Type win_type; \
|
||||
const char *name; \
|
||||
const char *title; \
|
||||
unsigned char autodel : 1
|
||||
EAPI Evas_Object *elm_toggle_add(Evas_Object *parent);
|
||||
EAPI void elm_toggle_label_set(Evas_Object *obj, const char *label);
|
||||
EAPI void elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon);
|
||||
EAPI void elm_toggle_states_labels_set(Evas_Object *obj, const char *onlabel, const char *offlabel);
|
||||
EAPI void elm_toggle_state_set(Evas_Object *obj, Evas_Bool state);
|
||||
EAPI void elm_toggle_state_pointer_set(Evas_Object *obj, Evas_Bool *statep);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
* "changed" - the user toggled the state
|
||||
*/
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Win *elm_win_new(void);
|
||||
struct _Elm_Win_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Win_Class_Methods;
|
||||
};
|
||||
struct _Elm_Win
|
||||
{
|
||||
Elm_Win_Class_All;
|
||||
EAPI Evas_Object *elm_frame_add(Evas_Object *parent);
|
||||
EAPI void elm_frame_label_set(Evas_Object *obj, const char *label);
|
||||
EAPI void elm_frame_content_set(Evas_Object *obj, Evas_Object *content);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
Ecore_Evas *ee; /* private */
|
||||
Evas *evas; /* private */
|
||||
Ecore_X_Window xwin; /* private */
|
||||
Ecore_Job *deferred_resize_job; /* private */
|
||||
Ecore_Job *deferred_child_eval_job; /* private */
|
||||
unsigned char showme : 1; /* private */
|
||||
};
|
||||
EAPI Evas_Object *elm_table_add(Evas_Object *parent);
|
||||
EAPI void elm_table_homogenous_set(Evas_Object *obj, Evas_Bool homogenous);
|
||||
EAPI void elm_table_pack(Evas_Object *obj, Evas_Object *subobj, int x, int y, int w, int h);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
*/
|
||||
|
||||
/**************************************************************************/
|
||||
/* Background Object */
|
||||
#define Elm_Bg_Class_Methods \
|
||||
void (*file_set) (Elm_Bg *bg, const char *file, const char *group);
|
||||
#define Elm_Bg_Class_All Elm_Widget_Class_All; Elm_Bg_Class_Methods; \
|
||||
const char *file; \
|
||||
const char *group
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Bg *elm_bg_new(Elm_Win *win);
|
||||
struct _Elm_Bg_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Bg_Class_Methods;
|
||||
};
|
||||
struct _Elm_Bg
|
||||
{
|
||||
Elm_Bg_Class_All;
|
||||
|
||||
Evas_Object *custom_bg;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Scroller (scrollframe/scrolledview) Object */
|
||||
#define Elm_Scroller_Class_Methods
|
||||
#define Elm_Scroller_Class_All Elm_Widget_Class_All; Elm_Scroller_Class_Methods;
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Scroller *elm_scroller_new(Elm_Win *win);
|
||||
struct _Elm_Scroller_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Scroller_Class_Methods;
|
||||
};
|
||||
struct _Elm_Scroller
|
||||
{
|
||||
Elm_Scroller_Class_All;
|
||||
|
||||
Evas_Object *scroller_pan;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Label Object */
|
||||
#define Elm_Label_Class_Methods \
|
||||
void (*text_set) (Elm_Label *lb, const char *text)
|
||||
#define Elm_Label_Class_All Elm_Widget_Class_All; Elm_Label_Class_Methods; \
|
||||
const char *text; \
|
||||
int minw, minh
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Label *elm_label_new(Elm_Win *win);
|
||||
struct _Elm_Label_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Label_Class_Methods;
|
||||
};
|
||||
struct _Elm_Label
|
||||
{
|
||||
Elm_Label_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Box Object */
|
||||
#define Elm_Box_Class_Methods \
|
||||
void (*layout_update) (Elm_Box *bx); \
|
||||
void (*pack_start) (Elm_Box *bx, Elm_Widget *wid); \
|
||||
void (*pack_end) (Elm_Box *bx, Elm_Widget *wid); \
|
||||
void (*pack_before) (Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before); \
|
||||
void (*pack_after) (Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after);
|
||||
|
||||
#define Elm_Box_Class_All Elm_Widget_Class_All; Elm_Box_Class_Methods; \
|
||||
unsigned char horizontal : 1; \
|
||||
unsigned char homogenous : 1
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Box *elm_box_new(Elm_Win *win);
|
||||
struct _Elm_Box_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Box_Class_Methods;
|
||||
};
|
||||
struct _Elm_Box
|
||||
{
|
||||
Elm_Box_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Table Object */
|
||||
#define Elm_Table_Class_Methods \
|
||||
void (*layout_update) (Elm_Table *tb); \
|
||||
void (*pack) (Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h)
|
||||
#define Elm_Table_Class_All Elm_Widget_Class_All; Elm_Table_Class_Methods; \
|
||||
unsigned char homogenous : 1
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Table *elm_table_new(Elm_Win *win);
|
||||
struct _Elm_Table_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Table_Class_Methods;
|
||||
};
|
||||
struct _Elm_Table
|
||||
{
|
||||
Elm_Table_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Button Object */
|
||||
#define Elm_Button_Class_Methods \
|
||||
void (*text_set) (Elm_Button *bt, const char *text)
|
||||
#define Elm_Button_Class_All Elm_Widget_Class_All; Elm_Button_Class_Methods; \
|
||||
const char *text; \
|
||||
int minw, minh
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Button *elm_button_new(Elm_Win *win);
|
||||
struct _Elm_Button_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Button_Class_Methods;
|
||||
};
|
||||
struct _Elm_Button
|
||||
{
|
||||
Elm_Button_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Icon Object */
|
||||
#define Elm_Icon_Class_Methods \
|
||||
void (*file_set) (Elm_Icon *icon, const char *file, const char *group); \
|
||||
void (*layout_update) (Elm_Icon *icon)
|
||||
#define Elm_Icon_Class_All Elm_Widget_Class_All; Elm_Icon_Class_Methods; \
|
||||
unsigned char scale_up : 1; \
|
||||
unsigned char scale_down : 1; \
|
||||
unsigned char fill_outside : 1; \
|
||||
unsigned char smooth : 1; \
|
||||
unsigned char no_scale : 1; \
|
||||
const char *file; \
|
||||
const char *group
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Icon *elm_icon_new(Elm_Win *win);
|
||||
struct _Elm_Icon_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Icon_Class_Methods;
|
||||
};
|
||||
struct _Elm_Icon
|
||||
{
|
||||
Elm_Icon_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Toggle Object */
|
||||
#define Elm_Toggle_Class_Methods \
|
||||
void (*text_set) (Elm_Toggle *tg, const char *text); \
|
||||
void (*layout_update) (Elm_Toggle *tg); \
|
||||
void (*states_text_set) (Elm_Toggle *tg, const char *ontext, const char *offtext)
|
||||
#define Elm_Toggle_Class_All Elm_Widget_Class_All; Elm_Toggle_Class_Methods; \
|
||||
const char *text; \
|
||||
int minw, minh; \
|
||||
int state; \
|
||||
int *state_ptr
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Toggle *elm_toggle_new(Elm_Win *win);
|
||||
struct _Elm_Toggle_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Toggle_Class_Methods;
|
||||
};
|
||||
struct _Elm_Toggle
|
||||
{
|
||||
Elm_Toggle_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Clock Object */
|
||||
#define Elm_Clock_Class_Methods \
|
||||
void (*time_update) (Elm_Clock *ck)
|
||||
#define Elm_Clock_Class_All Elm_Widget_Class_All; Elm_Clock_Class_Methods; \
|
||||
int hrs, min, sec; \
|
||||
int minw, minh; \
|
||||
unsigned char seconds : 1; \
|
||||
unsigned char am_pm : 1; \
|
||||
unsigned char edit : 1
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Clock *elm_clock_new(Elm_Win *win);
|
||||
struct _Elm_Clock_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Clock_Class_Methods;
|
||||
};
|
||||
struct _Elm_Clock
|
||||
{
|
||||
Elm_Clock_Class_All;
|
||||
|
||||
Evas_Object *digit[6];
|
||||
Evas_Object *ampm;
|
||||
Ecore_Timer *ticker;
|
||||
struct {
|
||||
int hrs, min, sec;
|
||||
char ampm;
|
||||
char seconds;
|
||||
char am_pm;
|
||||
char edit;
|
||||
} cur;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Frame Object */
|
||||
#define Elm_Frame_Class_Methods \
|
||||
void (*text_set) (Elm_Frame *fr, const char *text)
|
||||
#define Elm_Frame_Class_All Elm_Widget_Class_All; Elm_Frame_Class_Methods; \
|
||||
const char *text; \
|
||||
int minw, minh
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Frame *elm_frame_new(Elm_Win *win);
|
||||
struct _Elm_Frame_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Frame_Class_Methods;
|
||||
};
|
||||
struct _Elm_Frame
|
||||
{
|
||||
Elm_Frame_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Pad Object */
|
||||
#define Elm_Pad_Class_Methods
|
||||
#define Elm_Pad_Class_All Elm_Widget_Class_All; Elm_Pad_Class_Methods; \
|
||||
int minw, minh
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Pad *elm_pad_new(Elm_Win *win);
|
||||
struct _Elm_Pad_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Pad_Class_Methods;
|
||||
};
|
||||
struct _Elm_Pad
|
||||
{
|
||||
Elm_Pad_Class_All;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
/* Contactlist Object */
|
||||
#define Elm_Contactlist_Class_Methods \
|
||||
void (*file_set) (Elm_Contactlist *cl, const char *file, const char *group);
|
||||
#define Elm_Contactlist_Class_All Elm_Widget_Class_All; Elm_Contactlist_Class_Methods; \
|
||||
const char *file; \
|
||||
const char *group
|
||||
|
||||
/* Object specific ones */
|
||||
EAPI Elm_Contactlist *elm_contactlist_new(Elm_Win *win);
|
||||
struct _Elm_Contactlist_Class
|
||||
{
|
||||
void *parent;
|
||||
Elm_Obj_Type type;
|
||||
Elm_Contactlist_Class_Methods;
|
||||
};
|
||||
struct _Elm_Contactlist
|
||||
{
|
||||
Elm_Contactlist_Class_All;
|
||||
|
||||
Elm_Box *box;
|
||||
Elm_Scroller *scroller;
|
||||
Elm_Button *button;
|
||||
Elm_Box *listbox;
|
||||
};
|
||||
EAPI Evas_Object *elm_clock_add(Evas_Object *parent);
|
||||
EAPI void elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec);
|
||||
EAPI void elm_clock_time_get(Evas_Object *obj, int *hrs, int *min, int *sec);
|
||||
EAPI void elm_clock_edit_set(Evas_Object *obj, Evas_Bool edit);
|
||||
EAPI void elm_clock_show_am_pm_set(Evas_Object *obj, Evas_Bool am_pm);
|
||||
EAPI void elm_clock_show_seconds_set(Evas_Object *obj, Evas_Bool seconds);
|
||||
/* smart callbacks elm_win objects will call:
|
||||
* "changed" - the user changed the time
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,23 +16,20 @@ include_HEADERS = Elementary.h
|
|||
libelementary_la_SOURCES = \
|
||||
elm_priv.h \
|
||||
elm_main.c \
|
||||
elm_obj.c \
|
||||
elm_callback.c \
|
||||
elm_win.c \
|
||||
elm_theme.c \
|
||||
\
|
||||
elm_win.c \
|
||||
elm_widget.c \
|
||||
elm_bg.c \
|
||||
elm_icon.c \
|
||||
elm_box.c \
|
||||
elm_button.c \
|
||||
elm_scroller.c \
|
||||
elm_label.c \
|
||||
elm_box.c \
|
||||
elm_table.c \
|
||||
elm_button.c \
|
||||
elm_icon.c \
|
||||
elm_toggle.c \
|
||||
elm_clock.c \
|
||||
elm_frame.c \
|
||||
elm_pad.c \
|
||||
elm_contactlist.c \
|
||||
elm_table.c \
|
||||
elm_clock.c \
|
||||
\
|
||||
els_pan.c \
|
||||
els_pan.h \
|
||||
|
@ -45,6 +42,9 @@ els_table.h \
|
|||
els_icon.c \
|
||||
els_icon.h
|
||||
|
||||
#... later
|
||||
#elm_contactlist.c
|
||||
|
||||
libelementary_la_CFLAGS =
|
||||
libelementary_la_LIBADD = @my_libs@ @ELEMENTARY_LIBS@
|
||||
libelementary_la_LDFLAGS = -version-info @version_info@
|
||||
|
|
|
@ -1,20 +1,28 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_bg_file_set(Elm_Bg *bg, const char *file, const char *group);
|
||||
static void _elm_bg_del(Elm_Bg *bg);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Bg_Class _elm_bg_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_BG,
|
||||
_elm_bg_file_set
|
||||
Evas_Object *img, *custom_img;
|
||||
const char *file, *group;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info);
|
||||
|
||||
static void
|
||||
_elm_bg_custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Elm_Bg *bg = data;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = data;
|
||||
int iw = 0, ih = 0;
|
||||
Evas_Coord x, y, w, h, ow = 0, oh = 0;
|
||||
|
||||
|
@ -34,66 +42,57 @@ _elm_bg_custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info)
|
|||
evas_object_image_fill_set(obj, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_bg_file_set(Elm_Bg *bg, const char *file, const char *group)
|
||||
EAPI Evas_Object *
|
||||
elm_bg_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_can_focus_set(obj, 0);
|
||||
|
||||
wd->img = edje_object_add(e);
|
||||
_elm_theme_set(wd->img, "bg", "bg");
|
||||
elm_widget_resize_object_set(obj, wd->img);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
const char *p;
|
||||
|
||||
if (bg->custom_bg)
|
||||
if (wd->custom_img)
|
||||
{
|
||||
evas_object_del(bg->custom_bg);
|
||||
bg->custom_bg = NULL;
|
||||
evas_object_del(wd->custom_img);
|
||||
wd->custom_img = NULL;
|
||||
}
|
||||
if (!file) return;
|
||||
if (bg->file) evas_stringshare_del(bg->file);
|
||||
if (file) bg->file = evas_stringshare_add(file);
|
||||
else bg->file = NULL;
|
||||
if (bg->group) evas_stringshare_del(bg->group);
|
||||
if (group) bg->group = evas_stringshare_add(group);
|
||||
else bg->group = NULL;
|
||||
if (wd->file) evas_stringshare_del(wd->file);
|
||||
if (file) wd->file = evas_stringshare_add(file);
|
||||
else wd->file = NULL;
|
||||
if (wd->group) evas_stringshare_del(wd->group);
|
||||
if (group) wd->group = evas_stringshare_add(group);
|
||||
else wd->group = NULL;
|
||||
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
|
||||
{
|
||||
bg->custom_bg = edje_object_add(evas_object_evas_get(bg->base));
|
||||
edje_object_file_set(bg->custom_bg, file, group);
|
||||
wd->custom_img = edje_object_add(evas_object_evas_get(wd->img));
|
||||
edje_object_file_set(wd->custom_img, file, group);
|
||||
}
|
||||
else
|
||||
{
|
||||
bg->custom_bg = evas_object_image_add(evas_object_evas_get(bg->base));
|
||||
evas_object_event_callback_add(bg->custom_bg, EVAS_CALLBACK_RESIZE, _elm_bg_custom_resize, bg);
|
||||
evas_object_image_file_set(bg->custom_bg, file, group);
|
||||
wd->custom_img = evas_object_image_add(evas_object_evas_get(wd->img));
|
||||
evas_object_event_callback_add(wd->custom_img, EVAS_CALLBACK_RESIZE, _custom_resize, wd);
|
||||
evas_object_image_file_set(wd->custom_img, file, group);
|
||||
}
|
||||
evas_object_repeat_events_set(bg->custom_bg, 1);
|
||||
edje_object_part_swallow(bg->base, "elm.swallow.background", bg->custom_bg);
|
||||
evas_object_show(bg->custom_bg);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_bg_del(Elm_Bg *bg)
|
||||
{
|
||||
if (bg->custom_bg) evas_object_del(bg->custom_bg);
|
||||
if (bg->group) evas_stringshare_del(bg->group);
|
||||
if (bg->file) evas_stringshare_del(bg->file);
|
||||
((Elm_Obj_Class *)(((Elm_Bg_Class *)(bg->clas))->parent))->del(ELM_OBJ(bg));
|
||||
}
|
||||
|
||||
EAPI Elm_Bg *
|
||||
elm_bg_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Bg *bg;
|
||||
|
||||
bg = ELM_NEW(Elm_Bg);
|
||||
|
||||
_elm_widget_init(bg);
|
||||
bg->clas = &_elm_bg_class;
|
||||
bg->type = ELM_OBJ_BG;
|
||||
|
||||
bg->del = _elm_bg_del;
|
||||
|
||||
bg->file_set = _elm_bg_file_set;
|
||||
|
||||
bg->base = edje_object_add(win->evas);
|
||||
_elm_theme_set(bg->base, "bg", "bg");
|
||||
_elm_widget_post_init(bg);
|
||||
win->child_add(win, bg);
|
||||
return bg;
|
||||
elm_widget_sub_object_add(obj, wd->custom_img);
|
||||
evas_object_repeat_events_set(wd->custom_img, 1);
|
||||
edje_object_part_swallow(wd->img, "elm.swallow.background", wd->custom_img);
|
||||
evas_object_show(wd->custom_img);
|
||||
}
|
||||
|
|
|
@ -1,136 +1,115 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_box_layout_update(Elm_Box *bx);
|
||||
static void _elm_box_pack_start(Elm_Box *bx, Elm_Widget *wid);
|
||||
static void _elm_box_pack_end(Elm_Box *bx, Elm_Widget *wid);
|
||||
static void _elm_box_pack_before(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before);
|
||||
static void _elm_box_pack_after(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Box_Class _elm_box_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_SCROLLER,
|
||||
_elm_box_layout_update,
|
||||
_elm_box_pack_start,
|
||||
_elm_box_pack_end,
|
||||
_elm_box_pack_before,
|
||||
_elm_box_pack_after
|
||||
Evas_Object *box;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
|
||||
static void
|
||||
_elm_box_layout_update(Elm_Box *bx)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
_els_smart_box_orientation_set(bx->base, bx->horizontal);
|
||||
_els_smart_box_homogenous_set(bx->base, bx->homogenous);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_pack_start(Elm_Box *bx, Elm_Widget *wid)
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
bx->child_add(bx, wid);
|
||||
_els_smart_box_pack_start(bx->base, wid->base);
|
||||
elm_widget_sizing_update(wid);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
Evas_Coord w, h;
|
||||
|
||||
evas_object_size_hint_min_get(wd->box, &minw, &minh);
|
||||
evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
if (w < minw) w = minw;
|
||||
if (h < minh) h = minh;
|
||||
if ((maxw >= 0) && (w > maxw)) w = maxw;
|
||||
if ((maxh >= 0) && (h > maxh)) h = maxh;
|
||||
evas_object_resize(obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_pack_end(Elm_Box *bx, Elm_Widget *wid)
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
bx->child_add(bx, wid);
|
||||
_els_smart_box_pack_end(bx->base, wid->base);
|
||||
elm_widget_sizing_update(wid);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_pack_before(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before)
|
||||
EAPI Evas_Object *
|
||||
elm_box_add(Evas_Object *parent)
|
||||
{
|
||||
bx->child_add(bx, wid);
|
||||
_els_smart_box_pack_before(bx->base, wid->base, wid_before->base);
|
||||
elm_widget_sizing_update(wid);
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->box = _els_smart_box_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->box);
|
||||
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
elm_widget_resize_object_set(obj, wd->box);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_pack_after(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after)
|
||||
EAPI void
|
||||
elm_box_horizontal_set(Evas_Object *obj, Evas_Bool horizontal)
|
||||
{
|
||||
bx->child_add(bx, wid);
|
||||
_els_smart_box_pack_after(bx->base, wid->base, wid_after->base);
|
||||
elm_widget_sizing_update(wid);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_orientation_set(wd->box, horizontal);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_size_alloc(Elm_Box *bx, int w, int h)
|
||||
EAPI void
|
||||
elm_box_homogenous_set(Evas_Object *obj, Evas_Bool homogenous)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
_els_smart_box_min_size_get(bx->base, &mw, &mh);
|
||||
if (w < mw) w = mw;
|
||||
if (h < mh) h = mh;
|
||||
printf("box %p size alloc to %ix%i\n", bx, w, h);
|
||||
bx->req.w = w;
|
||||
bx->req.h = h;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_homogenous_set(wd->box, homogenous);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_box_size_req(Elm_Box *bx, Elm_Widget *child, int w, int h)
|
||||
EAPI void
|
||||
elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (child)
|
||||
{
|
||||
Evas_Coord maxx, maxy;
|
||||
|
||||
child->size_alloc(child, 0, 0);
|
||||
maxx = child->req.w;
|
||||
maxy = child->req.h;
|
||||
if (child->expand_x) maxx = 32767;
|
||||
if (child->expand_y) maxy = 32767;
|
||||
_els_smart_box_pack_options_set(child->base,
|
||||
child->fill_x, child->fill_y,
|
||||
child->expand_x, child->expand_y,
|
||||
child->align_x, child->align_y,
|
||||
child->req.w, child->req.h,
|
||||
maxx, maxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle.
|
||||
}
|
||||
_els_smart_box_min_size_get(bx->base, &mw, &mh);
|
||||
((Elm_Widget *)(bx->parent))->size_req(bx->parent, bx, mw, mh);
|
||||
bx->geom_set(bx, bx->x, bx->y, mw, mh);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_pack_start(wd->box, subobj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
// FIXME: track new sub obj...
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Box *bx, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
EAPI void
|
||||
elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
_els_smart_box_unpack(((Elm_Widget *)(obj))->base);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_pack_end(wd->box, subobj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
// FIXME: track new sub obj...
|
||||
}
|
||||
|
||||
EAPI Elm_Box *
|
||||
elm_box_new(Elm_Win *win)
|
||||
EAPI void
|
||||
elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before)
|
||||
{
|
||||
Elm_Box *bx;
|
||||
|
||||
bx = ELM_NEW(Elm_Box);
|
||||
_elm_widget_init(bx);
|
||||
|
||||
bx->clas = &_elm_box_class;
|
||||
bx->type = ELM_OBJ_BOX;
|
||||
|
||||
bx->layout_update = _elm_box_layout_update;
|
||||
bx->pack_start = _elm_box_pack_start;
|
||||
bx->pack_end = _elm_box_pack_end;
|
||||
bx->pack_before = _elm_box_pack_before;
|
||||
bx->pack_after = _elm_box_pack_after;
|
||||
|
||||
bx->size_alloc = _elm_box_size_alloc;
|
||||
bx->size_req = _elm_box_size_req;
|
||||
|
||||
bx->base = _els_smart_box_add(win->evas);
|
||||
|
||||
bx->cb_add(bx, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(bx);
|
||||
win->child_add(win, bx);
|
||||
return bx;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_pack_before(wd->box, subobj, before);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
// FIXME: track new sub obj...
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_pack_after(wd->box, subobj, after);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
// FIXME: track new sub obj...
|
||||
}
|
||||
|
|
|
@ -1,170 +1,102 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_button_text_set(Elm_Button *bt, const char *text);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Button_Class _elm_button_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_BUTTON,
|
||||
_elm_button_text_set
|
||||
Evas_Object *btn;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
|
||||
static void
|
||||
_elm_button_text_set(Elm_Button *bt, const char *text)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
edje_object_size_min_calc(wd->btn, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", obj);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
evas_object_smart_callback_call(data, "clicked", NULL);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_button_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->btn = edje_object_add(e);
|
||||
_elm_theme_set(wd->btn, "button", "button");
|
||||
edje_object_signal_callback_add(wd->btn, "elm,action,click", "", _signal_clicked, obj);
|
||||
elm_widget_resize_object_set(obj, wd->btn);
|
||||
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_button_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (text)
|
||||
if (label)
|
||||
{
|
||||
edje_object_signal_emit(bt->base, "elm,state,text,visible", "elm");
|
||||
edje_object_message_signal_process(bt->base);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(bt->base, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(bt->base);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
}
|
||||
edje_object_part_text_set(bt->base, "elm.text", text);
|
||||
edje_object_size_min_calc(bt->base, &mw, &mh);
|
||||
if ((bt->minw != mw) || (bt->minh != mh))
|
||||
edje_object_part_text_set(wd->btn, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||
{
|
||||
bt->minw = mw;
|
||||
bt->minh = mh;
|
||||
((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, bt->minw, bt->minh);
|
||||
bt->geom_set(bt, bt->x, bt->y, bt->minw, bt->minh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_button_size_alloc(Elm_Button *bt, int w, int h)
|
||||
{
|
||||
if (w < bt->minw) w = bt->minw;
|
||||
if (h < bt->minh) h = bt->minh;
|
||||
bt->req.w = w;
|
||||
bt->req.h = h;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_button_size_req(Elm_Button *bt, Elm_Widget *child, int w, int h)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (child)
|
||||
{
|
||||
Evas_Coord maxx, maxy;
|
||||
|
||||
child->size_alloc(child, 0, 0);
|
||||
maxx = child->req.w;
|
||||
maxy = child->req.h;
|
||||
if (child->expand_x) maxx = 32767;
|
||||
if (child->expand_y) maxy = 32767;
|
||||
edje_extern_object_min_size_set(child->base,
|
||||
child->req.w,
|
||||
child->req.h);
|
||||
edje_object_part_swallow(bt->base , "elm.swallow.contents",
|
||||
child->base);
|
||||
edje_object_size_min_calc(bt->base, &mw, &mh);
|
||||
if ((bt->minw != mw) || (bt->minh != mh))
|
||||
{
|
||||
bt->minw = mw;
|
||||
bt->minh = mh;
|
||||
((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, mw, mh);
|
||||
bt->geom_set(bt, bt->x, bt->y, mw, mh);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Button *bt, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
edje_object_signal_emit(bt->base, "elm,state,icon,visible", "elm");
|
||||
edje_object_message_signal_process(bt->base);
|
||||
((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
|
||||
((Elm_Widget *)(obj))->geom_set(obj,
|
||||
((Elm_Widget *)(obj))->x,
|
||||
((Elm_Widget *)(obj))->y,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_object_part_swallow(bt->base , "elm.swallow.contents",
|
||||
((Elm_Widget *)(obj))->base);
|
||||
edje_object_size_min_calc(bt->base, &mw, &mh);
|
||||
if ((bt->minw != mw) || (bt->minh != mh))
|
||||
{
|
||||
bt->minw = mw;
|
||||
bt->minh = mh;
|
||||
((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, mw, mh);
|
||||
bt->geom_set(bt, bt->x, bt->y, mw, mh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Button *bt, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
// FIXME: allow for removal of child - size down
|
||||
edje_object_signal_emit(bt->base, "elm,state,icon,hidden", "elm");
|
||||
edje_object_message_signal_process(bt->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_button_activate(Elm_Button *bt)
|
||||
{
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(bt), ELM_CB_ACTIVATED, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Elm_Button *bt = data;
|
||||
|
||||
_elm_button_activate(bt);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_button_del(Elm_Button *bt)
|
||||
{
|
||||
if (bt->text) evas_stringshare_del(bt->text);
|
||||
((Elm_Obj_Class *)(((Elm_Button_Class *)(bt->clas))->parent))->del(ELM_OBJ(bt));
|
||||
}
|
||||
|
||||
EAPI Elm_Button *
|
||||
elm_button_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Button *bt;
|
||||
|
||||
bt = ELM_NEW(Elm_Button);
|
||||
|
||||
_elm_widget_init(bt);
|
||||
bt->clas = &_elm_button_class;
|
||||
bt->type = ELM_OBJ_BUTTON;
|
||||
|
||||
bt->del = _elm_button_del;
|
||||
|
||||
bt->size_alloc = _elm_button_size_alloc;
|
||||
bt->size_req = _elm_button_size_req;
|
||||
|
||||
bt->text_set = _elm_button_text_set;
|
||||
|
||||
bt->base = edje_object_add(win->evas);
|
||||
_elm_theme_set(bt->base, "button", "button");
|
||||
edje_object_signal_callback_add(bt->base, "elm,action,click", "",
|
||||
_elm_signal_clicked, bt);
|
||||
bt->cb_add(bt, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
bt->cb_add(bt, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(bt);
|
||||
win->child_add(win, bt);
|
||||
return bt;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
||||
elm_widget_sub_object_add(obj, icon);
|
||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
// FIXME: track new sub obj...
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
|
|
@ -1,198 +1,254 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_clock_time_update(Elm_Clock *ck);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Clock_Class _elm_clock_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_CLOCK,
|
||||
_elm_clock_time_update
|
||||
Evas_Object *clk;
|
||||
Evas_Bool seconds : 1;
|
||||
Evas_Bool am_pm : 1;
|
||||
Evas_Bool edit : 1;
|
||||
int hrs, min, sec;
|
||||
Evas_Object *digit[6];
|
||||
Evas_Object *ampm;
|
||||
Ecore_Timer *ticker;
|
||||
struct {
|
||||
int hrs, min, sec;
|
||||
char ampm;
|
||||
char seconds;
|
||||
char am_pm;
|
||||
char edit;
|
||||
} cur;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static int _ticker(void *data);
|
||||
static void _signal_clock_val_up(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_clock_val_down(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _time_update(Evas_Object *obj);
|
||||
|
||||
static void
|
||||
_elm_clock_val_up(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Elm_Clock *ck = data;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
int i;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (wd->digit[i]) evas_object_del(wd->digit[i]);
|
||||
}
|
||||
if (wd->ampm) evas_object_del(wd->ampm);
|
||||
if (wd->ticker) ecore_timer_del(wd->ticker);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
if (!ck->edit) return;
|
||||
if (obj == ck->digit[0])
|
||||
static int
|
||||
_ticker(void *data)
|
||||
{
|
||||
ck->hrs = ck->hrs + 10;
|
||||
if (ck->hrs >= 24) ck->hrs -= 24;
|
||||
}
|
||||
if (obj == ck->digit[1])
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
double t;
|
||||
struct timeval timev;
|
||||
struct tm *tm;
|
||||
time_t tt;
|
||||
|
||||
gettimeofday(&timev, NULL);
|
||||
t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
|
||||
wd->ticker = ecore_timer_add(t, _ticker, data);
|
||||
if (!wd->edit)
|
||||
{
|
||||
ck->hrs = ck->hrs + 1;
|
||||
if (ck->hrs >= 24) ck->hrs -= 24;
|
||||
}
|
||||
if (obj == ck->digit[2])
|
||||
tt = (time_t)(timev.tv_sec);
|
||||
tzset();
|
||||
tm = localtime(&tt);
|
||||
if (tm)
|
||||
{
|
||||
ck->min = ck->min + 10;
|
||||
if (ck->min >= 60) ck->min -= 60;
|
||||
wd->hrs = tm->tm_hour;
|
||||
wd->min = tm->tm_min;
|
||||
wd->sec = tm->tm_sec;
|
||||
_time_update(data);
|
||||
}
|
||||
if (obj == ck->digit[3])
|
||||
{
|
||||
ck->min = ck->min + 1;
|
||||
if (ck->min >= 60) ck->min -= 60;
|
||||
}
|
||||
if (obj == ck->digit[4])
|
||||
{
|
||||
ck->sec = ck->sec + 10;
|
||||
if (ck->sec >= 60) ck->sec -= 60;
|
||||
}
|
||||
if (obj == ck->digit[5])
|
||||
{
|
||||
ck->sec = ck->sec + 1;
|
||||
if (ck->sec >= 60) ck->sec -= 60;
|
||||
}
|
||||
if (obj == ck->ampm)
|
||||
{
|
||||
ck->hrs = ck->hrs + 12;
|
||||
if (ck->hrs > 23) ck->hrs -= 24;
|
||||
}
|
||||
ck->time_update(ck);
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(ck), ELM_CB_CHANGED, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_val_down(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
_signal_clock_val_up(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Elm_Clock *ck = data;
|
||||
if (!ck->edit) return;
|
||||
if (obj == ck->digit[0])
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
|
||||
if (!wd->edit) return;
|
||||
if (obj == wd->digit[0])
|
||||
{
|
||||
ck->hrs = ck->hrs - 10;
|
||||
if (ck->hrs < 0) ck->hrs += 24;
|
||||
wd->hrs = wd->hrs + 10;
|
||||
if (wd->hrs >= 24) wd->hrs -= 24;
|
||||
}
|
||||
if (obj == ck->digit[1])
|
||||
if (obj == wd->digit[1])
|
||||
{
|
||||
ck->hrs = ck->hrs - 1;
|
||||
if (ck->hrs < 0) ck->hrs += 24;
|
||||
wd->hrs = wd->hrs + 1;
|
||||
if (wd->hrs >= 24) wd->hrs -= 24;
|
||||
}
|
||||
if (obj == ck->digit[2])
|
||||
if (obj == wd->digit[2])
|
||||
{
|
||||
ck->min = ck->min - 10;
|
||||
if (ck->min < 0) ck->min += 60;
|
||||
wd->min = wd->min + 10;
|
||||
if (wd->min >= 60) wd->min -= 60;
|
||||
}
|
||||
if (obj == ck->digit[3])
|
||||
if (obj == wd->digit[3])
|
||||
{
|
||||
ck->min = ck->min - 1;
|
||||
if (ck->min < 0) ck->min += 60;
|
||||
wd->min = wd->min + 1;
|
||||
if (wd->min >= 60) wd->min -= 60;
|
||||
}
|
||||
if (obj == ck->digit[4])
|
||||
if (obj == wd->digit[4])
|
||||
{
|
||||
ck->sec = ck->sec - 10;
|
||||
if (ck->sec < 0) ck->sec += 60;
|
||||
wd->sec = wd->sec + 10;
|
||||
if (wd->sec >= 60) wd->sec -= 60;
|
||||
}
|
||||
if (obj == ck->digit[5])
|
||||
if (obj == wd->digit[5])
|
||||
{
|
||||
ck->sec = ck->sec - 1;
|
||||
if (ck->sec < 0) ck->sec += 60;
|
||||
wd->sec = wd->sec + 1;
|
||||
if (wd->sec >= 60) wd->sec -= 60;
|
||||
}
|
||||
if (obj == ck->ampm)
|
||||
if (obj == wd->ampm)
|
||||
{
|
||||
ck->hrs = ck->hrs - 12;
|
||||
if (ck->hrs < 0) ck->hrs += 24;
|
||||
wd->hrs = wd->hrs + 12;
|
||||
if (wd->hrs > 23) wd->hrs -= 24;
|
||||
}
|
||||
ck->time_update(ck);
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(ck), ELM_CB_CHANGED, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
_time_update(data);
|
||||
evas_object_smart_callback_call(data, "changed", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_time_update(Elm_Clock *ck)
|
||||
_signal_clock_val_down(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
|
||||
if (!wd->edit) return;
|
||||
if (obj == wd->digit[0])
|
||||
{
|
||||
wd->hrs = wd->hrs - 10;
|
||||
if (wd->hrs < 0) wd->hrs += 24;
|
||||
}
|
||||
if (obj == wd->digit[1])
|
||||
{
|
||||
wd->hrs = wd->hrs - 1;
|
||||
if (wd->hrs < 0) wd->hrs += 24;
|
||||
}
|
||||
if (obj == wd->digit[2])
|
||||
{
|
||||
wd->min = wd->min - 10;
|
||||
if (wd->min < 0) wd->min += 60;
|
||||
}
|
||||
if (obj == wd->digit[3])
|
||||
{
|
||||
wd->min = wd->min - 1;
|
||||
if (wd->min < 0) wd->min += 60;
|
||||
}
|
||||
if (obj == wd->digit[4])
|
||||
{
|
||||
wd->sec = wd->sec - 10;
|
||||
if (wd->sec < 0) wd->sec += 60;
|
||||
}
|
||||
if (obj == wd->digit[5])
|
||||
{
|
||||
wd->sec = wd->sec - 1;
|
||||
if (wd->sec < 0) wd->sec += 60;
|
||||
}
|
||||
if (obj == wd->ampm)
|
||||
{
|
||||
wd->hrs = wd->hrs - 12;
|
||||
if (wd->hrs < 0) wd->hrs += 24;
|
||||
}
|
||||
_time_update(data);
|
||||
evas_object_smart_callback_call(data, "changed", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_time_update(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Edje_Message_Int msg;
|
||||
int ampm = 0;
|
||||
|
||||
if ((ck->cur.seconds != ck->seconds) || (ck->cur.am_pm != ck->am_pm) ||
|
||||
(ck->cur.edit != ck->edit))
|
||||
if ((wd->cur.seconds != wd->seconds) || (wd->cur.am_pm != wd->am_pm) ||
|
||||
(wd->cur.edit != wd->edit))
|
||||
{
|
||||
int i;
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (ck->digit[i])
|
||||
if (wd->digit[i])
|
||||
{
|
||||
evas_object_del(ck->digit[i]);
|
||||
ck->digit[i] = NULL;
|
||||
evas_object_del(wd->digit[i]);
|
||||
wd->digit[i] = NULL;
|
||||
}
|
||||
}
|
||||
if (ck->ampm)
|
||||
if (wd->ampm)
|
||||
{
|
||||
evas_object_del(ck->ampm);
|
||||
ck->ampm = NULL;
|
||||
evas_object_del(wd->ampm);
|
||||
wd->ampm = NULL;
|
||||
}
|
||||
|
||||
if ((ck->seconds) && (ck->am_pm))
|
||||
_elm_theme_set(ck->base, "clock", "clock/all");
|
||||
else if (ck->seconds)
|
||||
_elm_theme_set(ck->base, "clock", "clock/seconds");
|
||||
else if (ck->am_pm)
|
||||
_elm_theme_set(ck->base, "clock", "clock/am_pm");
|
||||
if ((wd->seconds) && (wd->am_pm))
|
||||
_elm_theme_set(wd->clk, "clock", "clock/all");
|
||||
else if (wd->seconds)
|
||||
_elm_theme_set(wd->clk, "clock", "clock/seconds");
|
||||
else if (wd->am_pm)
|
||||
_elm_theme_set(wd->clk, "clock", "clock/am_pm");
|
||||
else
|
||||
_elm_theme_set(ck->base, "clock", "clock");
|
||||
_elm_theme_set(wd->clk, "clock", "clock");
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
if ((!ck->seconds) && (i >= 4)) break;
|
||||
ck->digit[i] = edje_object_add(evas_object_evas_get(ck->base));
|
||||
_elm_theme_set(ck->digit[i], "clock", "flipdigit");
|
||||
if (ck->edit)
|
||||
edje_object_signal_emit(ck->digit[i], "elm,state,edit,on", "elm");
|
||||
edje_object_signal_callback_add(ck->digit[i], "elm,action,up", "",
|
||||
_elm_clock_val_up, ck);
|
||||
edje_object_signal_callback_add(ck->digit[i], "elm,action,down", "",
|
||||
_elm_clock_val_down, ck);
|
||||
edje_object_size_min_calc(ck->digit[i], &mw, &mh);
|
||||
edje_extern_object_min_size_set(ck->digit[i], mw, mh);
|
||||
if ((!wd->seconds) && (i >= 4)) break;
|
||||
wd->digit[i] = edje_object_add(evas_object_evas_get(wd->clk));
|
||||
_elm_theme_set(wd->digit[i], "clock", "flipdigit");
|
||||
if (wd->edit)
|
||||
edje_object_signal_emit(wd->digit[i], "elm,state,edit,on", "elm");
|
||||
edje_object_signal_callback_add(wd->digit[i], "elm,action,up", "",
|
||||
_signal_clock_val_up, obj);
|
||||
edje_object_signal_callback_add(wd->digit[i], "elm,action,down", "",
|
||||
_signal_clock_val_down, obj);
|
||||
edje_object_size_min_calc(wd->digit[i], &mw, &mh);
|
||||
edje_extern_object_min_size_set(wd->digit[i], mw, mh);
|
||||
snprintf(buf, sizeof(buf), "d%i", i);
|
||||
edje_object_part_swallow(ck->base , buf, ck->digit[i]);
|
||||
evas_object_show(ck->digit[i]);
|
||||
edje_object_part_swallow(wd->clk , buf, wd->digit[i]);
|
||||
evas_object_show(wd->digit[i]);
|
||||
}
|
||||
if (ck->am_pm)
|
||||
if (wd->am_pm)
|
||||
{
|
||||
ck->ampm = edje_object_add(evas_object_evas_get(ck->base));
|
||||
_elm_theme_set(ck->ampm, "clock", "flipampm");
|
||||
if (ck->edit)
|
||||
edje_object_signal_emit(ck->ampm, "elm,state,edit,on", "elm");
|
||||
edje_object_signal_callback_add(ck->ampm, "elm,action,up", "",
|
||||
_elm_clock_val_up, ck);
|
||||
edje_object_signal_callback_add(ck->ampm, "elm,action,down", "",
|
||||
_elm_clock_val_down, ck);
|
||||
edje_object_size_min_calc(ck->ampm, &mw, &mh);
|
||||
edje_extern_object_min_size_set(ck->ampm, mw, mh);
|
||||
edje_object_part_swallow(ck->base , "ampm", ck->ampm);
|
||||
evas_object_show(ck->ampm);
|
||||
wd->ampm = edje_object_add(evas_object_evas_get(wd->clk));
|
||||
_elm_theme_set(wd->ampm, "clock", "flipampm");
|
||||
if (wd->edit)
|
||||
edje_object_signal_emit(wd->ampm, "elm,state,edit,on", "elm");
|
||||
edje_object_signal_callback_add(wd->ampm, "elm,action,up", "",
|
||||
_signal_clock_val_up, obj);
|
||||
edje_object_signal_callback_add(wd->ampm, "elm,action,down", "",
|
||||
_signal_clock_val_down, obj);
|
||||
edje_object_size_min_calc(wd->ampm, &mw, &mh);
|
||||
edje_extern_object_min_size_set(wd->ampm, mw, mh);
|
||||
edje_object_part_swallow(wd->clk , "ampm", wd->ampm);
|
||||
evas_object_show(wd->ampm);
|
||||
}
|
||||
|
||||
edje_object_size_min_calc(ck->base, &mw, &mh);
|
||||
ck->minw = mw;
|
||||
ck->minh = mh;
|
||||
edje_object_size_min_calc(wd->clk, &mw, &mh);
|
||||
evas_object_size_hint_min_set(obj, mw, mh);
|
||||
|
||||
ck->cur.hrs = 0;
|
||||
ck->cur.min = 0;
|
||||
ck->cur.sec = 0;
|
||||
ck->cur.ampm = -1;
|
||||
ck->cur.seconds = ck->seconds;
|
||||
ck->cur.am_pm = ck->am_pm;
|
||||
ck->cur.edit = ck->edit;
|
||||
wd->cur.hrs = 0;
|
||||
wd->cur.min = 0;
|
||||
wd->cur.sec = 0;
|
||||
wd->cur.ampm = -1;
|
||||
wd->cur.seconds = wd->seconds;
|
||||
wd->cur.am_pm = wd->am_pm;
|
||||
wd->cur.edit = wd->edit;
|
||||
}
|
||||
if (ck->hrs != ck->cur.hrs)
|
||||
if (wd->hrs != wd->cur.hrs)
|
||||
{
|
||||
int hrs;
|
||||
int d1, d2, dc1, dc2;
|
||||
|
||||
hrs = ck->hrs;
|
||||
if (ck->am_pm)
|
||||
hrs = wd->hrs;
|
||||
if (wd->am_pm)
|
||||
{
|
||||
if (hrs >= 12)
|
||||
{
|
||||
|
@ -203,191 +259,151 @@ _elm_clock_time_update(Elm_Clock *ck)
|
|||
}
|
||||
d1 = hrs / 10;
|
||||
d2 = hrs % 10;
|
||||
dc1 = ck->cur.hrs / 10;
|
||||
dc2 = ck->cur.hrs % 10;
|
||||
dc1 = wd->cur.hrs / 10;
|
||||
dc2 = wd->cur.hrs % 10;
|
||||
if (d1 != dc1)
|
||||
{
|
||||
msg.val = d1;
|
||||
edje_object_message_send(ck->digit[0], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[0], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
if (d2 != dc2)
|
||||
{
|
||||
msg.val = d2;
|
||||
edje_object_message_send(ck->digit[1], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[1], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
ck->cur.hrs = hrs;
|
||||
wd->cur.hrs = hrs;
|
||||
}
|
||||
if (ck->min != ck->cur.min)
|
||||
if (wd->min != wd->cur.min)
|
||||
{
|
||||
int d1, d2, dc1, dc2;
|
||||
|
||||
d1 = ck->min / 10;
|
||||
d2 = ck->min % 10;
|
||||
dc1 = ck->cur.min / 10;
|
||||
dc2 = ck->cur.min % 10;
|
||||
d1 = wd->min / 10;
|
||||
d2 = wd->min % 10;
|
||||
dc1 = wd->cur.min / 10;
|
||||
dc2 = wd->cur.min % 10;
|
||||
if (d1 != dc1)
|
||||
{
|
||||
msg.val = d1;
|
||||
edje_object_message_send(ck->digit[2], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[2], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
if (d2 != dc2)
|
||||
{
|
||||
msg.val = d2;
|
||||
edje_object_message_send(ck->digit[3], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[3], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
ck->cur.min = ck->min;
|
||||
wd->cur.min = wd->min;
|
||||
}
|
||||
if (ck->seconds)
|
||||
if (wd->seconds)
|
||||
{
|
||||
if (ck->sec != ck->cur.sec)
|
||||
if (wd->sec != wd->cur.sec)
|
||||
{
|
||||
int d1, d2, dc1, dc2;
|
||||
|
||||
d1 = ck->sec / 10;
|
||||
d2 = ck->sec % 10;
|
||||
dc1 = ck->cur.sec / 10;
|
||||
dc2 = ck->cur.sec % 10;
|
||||
d1 = wd->sec / 10;
|
||||
d2 = wd->sec % 10;
|
||||
dc1 = wd->cur.sec / 10;
|
||||
dc2 = wd->cur.sec % 10;
|
||||
if (d1 != dc1)
|
||||
{
|
||||
msg.val = d1;
|
||||
edje_object_message_send(ck->digit[4], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[4], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
if (d2 != dc2)
|
||||
{
|
||||
msg.val = d2;
|
||||
edje_object_message_send(ck->digit[5], EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->digit[5], EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
ck->cur.sec = ck->sec;
|
||||
wd->cur.sec = wd->sec;
|
||||
}
|
||||
}
|
||||
else
|
||||
ck->cur.sec = -1;
|
||||
wd->cur.sec = -1;
|
||||
|
||||
if (ck->am_pm)
|
||||
if (wd->am_pm)
|
||||
{
|
||||
if (ck->hrs >= 12) ampm = 1;
|
||||
if (ampm != ck->cur.ampm)
|
||||
if (wd->hrs >= 12) ampm = 1;
|
||||
if (ampm != wd->cur.ampm)
|
||||
{
|
||||
int d1, d2, dc1, dc2;
|
||||
|
||||
if (ck->cur.ampm != ampm)
|
||||
if (wd->cur.ampm != ampm)
|
||||
{
|
||||
msg.val = ampm;
|
||||
edje_object_message_send(ck->ampm, EDJE_MESSAGE_INT, 1, &msg);
|
||||
edje_object_message_send(wd->ampm, EDJE_MESSAGE_INT, 1, &msg);
|
||||
}
|
||||
ck->cur.ampm = ampm;
|
||||
wd->cur.ampm = ampm;
|
||||
}
|
||||
}
|
||||
else
|
||||
ck->cur.ampm = -1;
|
||||
wd->cur.ampm = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_size_alloc(Elm_Clock *ck, int w, int h)
|
||||
EAPI Evas_Object *
|
||||
elm_clock_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
if (w < ck->minw) w = ck->minw;
|
||||
if (h < ck->minh) h = ck->minh;
|
||||
ck->req.w = w;
|
||||
ck->req.h = h;
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->clk = edje_object_add(e);
|
||||
elm_widget_resize_object_set(obj, wd->clk);
|
||||
|
||||
wd->cur.ampm = -1;
|
||||
wd->cur.seconds = -1;
|
||||
wd->cur.am_pm = -1;
|
||||
wd->cur.edit = -1;
|
||||
|
||||
_time_update(obj);
|
||||
_ticker(obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_size_req(Elm_Clock *ck, Elm_Widget *child, int w, int h)
|
||||
EAPI void
|
||||
elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
|
||||
{
|
||||
if (child)
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->hrs = hrs;
|
||||
wd->min = min;
|
||||
wd->sec = sec;
|
||||
_time_update(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_clock_time_get(Evas_Object *obj, int *hrs, int *min, int *sec)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (hrs) *hrs = wd->hrs;
|
||||
if (min) *min = wd->min;
|
||||
if (sec) *sec = wd->sec;
|
||||
}
|
||||
else
|
||||
|
||||
EAPI void
|
||||
elm_clock_edit_set(Evas_Object *obj, Evas_Bool edit)
|
||||
{
|
||||
// FIXME: handle
|
||||
}
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->edit = edit;
|
||||
_time_update(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_activate(Elm_Clock *ck)
|
||||
EAPI void
|
||||
elm_clock_show_am_pm_set(Evas_Object *obj, Evas_Bool am_pm)
|
||||
{
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(ck), ELM_CB_ACTIVATED, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->am_pm = am_pm;
|
||||
_time_update(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_clock_del(Elm_Clock *ck)
|
||||
EAPI void
|
||||
elm_clock_show_seconds_set(Evas_Object *obj, Evas_Bool seconds)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (ck->digit[i]) evas_object_del(ck->digit[i]);
|
||||
}
|
||||
if (ck->ampm) evas_object_del(ck->ampm);
|
||||
if (ck->ticker) ecore_timer_del(ck->ticker);
|
||||
((Elm_Obj_Class *)(((Elm_Clock_Class *)(ck->clas))->parent))->del(ELM_OBJ(ck));
|
||||
}
|
||||
|
||||
static int
|
||||
_elm_clock_ticker(Elm_Clock *ck)
|
||||
{
|
||||
double t;
|
||||
struct timeval timev;
|
||||
struct tm *tm;
|
||||
time_t tt;
|
||||
|
||||
gettimeofday(&timev, NULL);
|
||||
t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
|
||||
ck->ticker = ecore_timer_add(t, _elm_clock_ticker, ck);
|
||||
if (!ck->edit)
|
||||
{
|
||||
tt = (time_t)(timev.tv_sec);
|
||||
tzset();
|
||||
tm = localtime(&tt);
|
||||
if (tm)
|
||||
{
|
||||
ck->hrs = tm->tm_hour;
|
||||
ck->min = tm->tm_min;
|
||||
ck->sec = tm->tm_sec;
|
||||
ck->time_update(ck);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Elm_Clock *
|
||||
elm_clock_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Clock *ck;
|
||||
|
||||
ck = ELM_NEW(Elm_Clock);
|
||||
|
||||
_elm_widget_init(ck);
|
||||
ck->clas = &_elm_clock_class;
|
||||
ck->type = ELM_OBJ_CLOCK;
|
||||
|
||||
ck->del = _elm_clock_del;
|
||||
|
||||
ck->size_alloc = _elm_clock_size_alloc;
|
||||
ck->size_req = _elm_clock_size_req;
|
||||
|
||||
ck->time_update = _elm_clock_time_update;
|
||||
|
||||
ck->seconds = 1;
|
||||
ck->am_pm = 1;
|
||||
|
||||
ck->cur.hrs = 0;
|
||||
ck->cur.min = 0;
|
||||
ck->cur.sec = 0;
|
||||
ck->cur.ampm = -1;
|
||||
ck->cur.seconds = -1;
|
||||
ck->cur.am_pm = -1;
|
||||
ck->cur.edit = -1;
|
||||
|
||||
ck->base = edje_object_add(win->evas);
|
||||
|
||||
_elm_clock_ticker(ck);
|
||||
|
||||
_elm_widget_post_init(ck);
|
||||
win->child_add(win, ck);
|
||||
return ck;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->seconds = seconds;
|
||||
_time_update(obj);
|
||||
}
|
||||
|
|
|
@ -1,122 +1,2 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_contactlist_del(Elm_Contactlist *cl);
|
||||
|
||||
Elm_Contactlist_Class _elm_contactlist_class =
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_CONTACTLIST
|
||||
};
|
||||
|
||||
static void
|
||||
_elm_contactlist_del(Elm_Contactlist *cl)
|
||||
{
|
||||
// custom here
|
||||
((Elm_Obj_Class *)(((Elm_Contactlist_Class *)(cl->clas))->parent))->del(ELM_OBJ(cl));
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_contactlist_geom_set(Elm_Contactlist *cl, int x, int y, int w, int h)
|
||||
{
|
||||
cl->box->geom_set(cl->box, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Contactlist *cl, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
Evas_Coord vw, vh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
// custom here (eg pack to box)
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Contactlist *cl, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
// dunno
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_contactlist_show(Elm_Contactlist *cl)
|
||||
{
|
||||
cl->box->show(cl->box);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_contactlist_hide(Elm_Contactlist *cl)
|
||||
{
|
||||
cl->box->hide(cl->box);
|
||||
}
|
||||
|
||||
static void
|
||||
on_button_activate(Elm_Contactlist *cl, Elm_Button *bt, Elm_Cb_Type type, void *info)
|
||||
{
|
||||
printf("Add contact\n");
|
||||
}
|
||||
|
||||
|
||||
EAPI Elm_Contactlist *
|
||||
elm_contactlist_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Contactlist *cl;
|
||||
|
||||
cl = ELM_NEW(Elm_Contactlist);
|
||||
_elm_widget_init(cl);
|
||||
|
||||
cl->clas = &_elm_contactlist_class;
|
||||
cl->type = ELM_OBJ_CONTACTLIST;
|
||||
|
||||
cl->del = _elm_contactlist_del;
|
||||
|
||||
cl->geom_set = _elm_contactlist_geom_set;
|
||||
cl->show = _elm_contactlist_show;
|
||||
cl->hide = _elm_contactlist_hide;
|
||||
|
||||
cl->box = elm_box_new(win);
|
||||
cl->child_add(cl, cl->box);
|
||||
|
||||
cl->listbox = elm_box_new(win);
|
||||
printf("--listbox = %p\n", cl->listbox);
|
||||
|
||||
cl->scroller = elm_scroller_new(win);
|
||||
cl->box->pack_end(cl->box, cl->scroller);
|
||||
|
||||
cl->button = elm_button_new(win);
|
||||
cl->button->text_set(cl->button, "Add Contact");
|
||||
cl->button->cb_add(cl->button, ELM_CB_ACTIVATED, on_button_activate, cl);
|
||||
cl->button->expand_y = 0;
|
||||
cl->box->pack_end(cl->box, cl->button);
|
||||
|
||||
cl->button->show(cl->button);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
Elm_Button *bt;
|
||||
|
||||
bt = elm_button_new(win);
|
||||
bt->text_set(bt, "Contact 1");
|
||||
bt->expand_y = 0;
|
||||
cl->listbox->pack_end(cl->listbox, bt);
|
||||
bt->show(bt);
|
||||
}
|
||||
|
||||
cl->scroller->child_add(cl->scroller, cl->listbox);
|
||||
elm_widget_sizing_update(cl->listbox);
|
||||
cl->scroller->show(cl->scroller);
|
||||
cl->listbox->show(cl->listbox);
|
||||
|
||||
elm_widget_sizing_update(cl->scroller);
|
||||
elm_widget_sizing_update(cl->button);
|
||||
elm_widget_sizing_update(cl->box);
|
||||
|
||||
cl->base = cl->box->base;
|
||||
|
||||
cl->cb_add(cl, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
cl->cb_add(cl, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(cl);
|
||||
win->child_add(win, cl);
|
||||
return cl;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,85 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
struct _Widget_Data
|
||||
{
|
||||
Evas_Object *frm;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
|
||||
static void
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
edje_object_size_min_calc(wd->frm, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
edje_object_part_swallow(wd->frm, "elm.swallow.content", obj);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_frame_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->frm = edje_object_add(e);
|
||||
_elm_theme_set(wd->frm, "frame", "frame");
|
||||
elm_widget_resize_object_set(obj, wd->frm);
|
||||
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_frame_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_text_set(wd->frm, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
|
||||
elm_widget_sub_object_add(obj, content);
|
||||
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
// FIXME: track new sub obj...
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
static void _elm_frame_text_set(Elm_Frame *fr, const char *text);
|
||||
|
||||
Elm_Frame_Class _elm_frame_class =
|
||||
|
@ -136,3 +215,4 @@ elm_frame_new(Elm_Win *win)
|
|||
win->child_add(win, fr);
|
||||
return fr;
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,103 +1,137 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_icon_file_set(Elm_Icon *icon, const char *file, const char *group);
|
||||
static void _elm_icon_layout_update(Elm_Icon *icon);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Icon_Class _elm_icon_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_ICON,
|
||||
_elm_icon_file_set,
|
||||
_elm_icon_layout_update
|
||||
Evas_Object *img;
|
||||
const char *file, *group;
|
||||
Evas_Bool scale_up : 1;
|
||||
Evas_Bool scale_down : 1;
|
||||
Evas_Bool smooth : 1;
|
||||
Evas_Bool fill_outside : 1;
|
||||
Evas_Bool no_scale : 1;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
|
||||
static void
|
||||
_elm_icon_file_set(Elm_Icon *icon, const char *file, const char *group)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
int w, h;
|
||||
|
||||
_els_smart_icon_size_get(wd->img, &w, &h);
|
||||
_els_smart_icon_scale_up_set(wd->img, wd->scale_up);
|
||||
_els_smart_icon_scale_down_set(wd->img, wd->scale_down);
|
||||
_els_smart_icon_smooth_scale_set(wd->img, wd->smooth);
|
||||
_els_smart_icon_fill_inside_set(wd->img, !(wd->fill_outside));
|
||||
if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
|
||||
else
|
||||
{
|
||||
_els_smart_icon_scale_set(wd->img, _elm_config->scale);
|
||||
w *= _elm_config->scale;
|
||||
h *= _elm_config->scale;
|
||||
}
|
||||
if (!wd->scale_down)
|
||||
{
|
||||
minw = w;
|
||||
minh = h;
|
||||
}
|
||||
if (!wd->scale_up)
|
||||
{
|
||||
maxw = w;
|
||||
maxh = h;
|
||||
}
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_icon_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_can_focus_set(obj, 0);
|
||||
|
||||
wd->img = _els_smart_icon_add(e);
|
||||
evas_object_repeat_events_set(wd->img, 1);
|
||||
elm_widget_resize_object_set(obj, wd->img);
|
||||
|
||||
wd->smooth = 1;
|
||||
wd->scale_up = 1;
|
||||
wd->scale_down = 1;
|
||||
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
const char *p;
|
||||
|
||||
if (!file) return;
|
||||
if (icon->file) evas_stringshare_del(icon->file);
|
||||
if (file) icon->file = evas_stringshare_add(file);
|
||||
else icon->file = NULL;
|
||||
if (icon->group) evas_stringshare_del(icon->group);
|
||||
if (group) icon->group = evas_stringshare_add(group);
|
||||
else icon->group = NULL;
|
||||
if (wd->file) evas_stringshare_del(wd->file);
|
||||
if (file) wd->file = evas_stringshare_add(file);
|
||||
else wd->file = NULL;
|
||||
if (wd->group) evas_stringshare_del(wd->group);
|
||||
if (group) wd->group = evas_stringshare_add(group);
|
||||
else wd->group = NULL;
|
||||
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
|
||||
_els_smart_icon_file_edje_set(icon->base, file, group);
|
||||
_els_smart_icon_file_edje_set(wd->img, file, group);
|
||||
else
|
||||
_els_smart_icon_file_key_set(icon->base, file, group);
|
||||
icon->layout_update(icon);
|
||||
_els_smart_icon_file_key_set(wd->img, file, group);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_icon_layout_update(Elm_Icon *icon)
|
||||
EAPI void
|
||||
elm_icon_smooth_set(Evas_Object *obj, Evas_Bool smooth)
|
||||
{
|
||||
_els_smart_icon_scale_up_set(icon->base, icon->scale_up);
|
||||
_els_smart_icon_scale_down_set(icon->base, icon->scale_down);
|
||||
_els_smart_icon_smooth_scale_set(icon->base, icon->smooth);
|
||||
_els_smart_icon_fill_inside_set(icon->base, !(icon->fill_outside));
|
||||
if (icon->no_scale) _els_smart_icon_scale_set(icon->base, 1.0);
|
||||
else _els_smart_icon_scale_set(icon->base, _elm_config->scale);
|
||||
if ((!icon->scale_down) || (!icon->scale_up))
|
||||
((Elm_Widget *)(icon->parent))->size_req(icon->parent, icon, 0, 0);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->smooth = smooth;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_icon_size_alloc(Elm_Icon *icon, int w, int h)
|
||||
EAPI void
|
||||
elm_icon_no_scale_set(Evas_Object *obj, Evas_Bool no_scale)
|
||||
{
|
||||
int tw, th;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->no_scale = no_scale;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
_els_smart_icon_size_get(icon->base, &tw, &th);
|
||||
if (!icon->scale_down)
|
||||
EAPI void
|
||||
elm_icon_scale_set(Evas_Object *obj, Evas_Bool scale_up, Evas_Bool scale_down)
|
||||
{
|
||||
if (w < tw) w = tw;
|
||||
if (h < th) h = th;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->scale_up = scale_up;
|
||||
wd->scale_down = scale_down;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
if (!icon->scale_up)
|
||||
|
||||
EAPI void
|
||||
elm_icon_fill_outside_set(Evas_Object *obj, Evas_Bool fill_outside)
|
||||
{
|
||||
if (w > tw) w = tw;
|
||||
if (h > th) h = th;
|
||||
}
|
||||
icon->req.w = w;
|
||||
icon->req.h = h;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_icon_del(Elm_Icon *icon)
|
||||
{
|
||||
if (icon->group) evas_stringshare_del(icon->group);
|
||||
if (icon->file) evas_stringshare_del(icon->file);
|
||||
((Elm_Obj_Class *)(((Elm_Icon_Class *)(icon->clas))->parent))->del(ELM_OBJ(icon));
|
||||
}
|
||||
|
||||
EAPI Elm_Icon *
|
||||
elm_icon_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Icon *icon;
|
||||
|
||||
icon = ELM_NEW(Elm_Icon);
|
||||
|
||||
_elm_widget_init(icon);
|
||||
icon->clas = &_elm_icon_class;
|
||||
icon->type = ELM_OBJ_ICON;
|
||||
|
||||
icon->del = _elm_icon_del;
|
||||
|
||||
icon->size_alloc = _elm_icon_size_alloc;
|
||||
|
||||
icon->file_set = _elm_icon_file_set;
|
||||
icon->layout_update = _elm_icon_layout_update;
|
||||
|
||||
icon->smooth = 1;
|
||||
icon->scale_up = 1;
|
||||
icon->scale_down = 1;
|
||||
|
||||
icon->base = _els_smart_icon_add(win->evas);
|
||||
evas_object_repeat_events_set(icon->base, 1);
|
||||
|
||||
_elm_widget_post_init(icon);
|
||||
win->child_add(win, icon);
|
||||
return icon;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->fill_outside = fill_outside;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
|
|
@ -1,68 +1,58 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_label_text_set(Elm_Label *lb, const char *text);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Label_Class _elm_label_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_LABEL,
|
||||
_elm_label_text_set
|
||||
Evas_Object *lbl;
|
||||
};
|
||||
|
||||
static void
|
||||
_elm_label_text_set(Elm_Label *lb, const char *text)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
|
||||
if (lb->text) evas_stringshare_del(lb->text);
|
||||
if (text) lb->text = evas_stringshare_add(text);
|
||||
else lb->text = NULL;
|
||||
edje_object_part_text_set(lb->base, "elm.text", text);
|
||||
edje_object_size_min_calc(lb->base, &mw, &mh);
|
||||
if ((lb->minw != mw) || (lb->minh != mh))
|
||||
static void
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
lb->minw = mw;
|
||||
lb->minh = mh;
|
||||
((Elm_Widget *)(lb->parent))->size_req(lb->parent, lb, lb->minw, lb->minh);
|
||||
lb->geom_set(lb, lb->x, lb->y, lb->minw, lb->minh);
|
||||
}
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_label_size_alloc(Elm_Label *lb, int w, int h)
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
lb->req.w = lb->minw;
|
||||
lb->req.h = lb->minh;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
edje_object_size_min_calc(wd->lbl, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_label_del(Elm_Label *lb)
|
||||
EAPI Evas_Object *
|
||||
elm_label_add(Evas_Object *parent)
|
||||
{
|
||||
if (lb->text) evas_stringshare_del(lb->text);
|
||||
((Elm_Obj_Class *)(((Elm_Label_Class *)(lb->clas))->parent))->del(ELM_OBJ(lb));
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_can_focus_set(obj, 0);
|
||||
|
||||
wd->lbl = edje_object_add(e);
|
||||
_elm_theme_set(wd->lbl, "label", "label");
|
||||
elm_widget_resize_object_set(obj, wd->lbl);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI Elm_Label *
|
||||
elm_label_new(Elm_Win *win)
|
||||
EAPI void
|
||||
elm_label_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Elm_Label *lb;
|
||||
|
||||
lb = ELM_NEW(Elm_Label);
|
||||
|
||||
_elm_widget_init(lb);
|
||||
lb->clas = &_elm_label_class;
|
||||
lb->type = ELM_OBJ_LABEL;
|
||||
|
||||
lb->del = _elm_label_del;
|
||||
|
||||
lb->size_alloc = _elm_label_size_alloc;
|
||||
|
||||
lb->text_set = _elm_label_text_set;
|
||||
|
||||
lb->base = edje_object_add(win->evas);
|
||||
_elm_theme_set(lb->base, "label", "label");
|
||||
_elm_widget_post_init(lb);
|
||||
win->child_add(win, lb);
|
||||
return lb;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_text_set(wd->lbl, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ elm_init(int argc, char **argv)
|
|||
EAPI void
|
||||
elm_shutdown(void)
|
||||
{
|
||||
_elm_win_shutdown();
|
||||
|
||||
free(_elm_config);
|
||||
free(_elm_appname);
|
||||
ecore_evas_shutdown();
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
Elm_Pad_Class _elm_pad_class =
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_PAD
|
||||
};
|
||||
|
||||
static void
|
||||
_elm_pad_size_alloc(Elm_Pad *pd, int w, int h)
|
||||
{
|
||||
if (w < pd->minw) w = pd->minw;
|
||||
if (h < pd->minh) h = pd->minh;
|
||||
pd->req.w = w;
|
||||
pd->req.h = h;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_pad_size_req(Elm_Pad *pd, Elm_Widget *child, int w, int h)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (child)
|
||||
{
|
||||
Evas_Coord maxx, maxy;
|
||||
|
||||
child->size_alloc(child, 0, 0);
|
||||
maxx = child->req.w;
|
||||
maxy = child->req.h;
|
||||
if (child->expand_x) maxx = 32767;
|
||||
if (child->expand_y) maxy = 32767;
|
||||
edje_extern_object_min_size_set(child->base,
|
||||
child->req.w,
|
||||
child->req.h);
|
||||
edje_object_part_swallow(pd->base , "elm.swallow.contents",
|
||||
child->base);
|
||||
edje_object_size_min_calc(pd->base, &mw, &mh);
|
||||
if ((pd->minw != mw) || (pd->minh != mh))
|
||||
{
|
||||
pd->minw = mw;
|
||||
pd->minh = mh;
|
||||
((Elm_Widget *)(pd->parent))->size_req(pd->parent, pd, mw, mh);
|
||||
pd->geom_set(pd, pd->x, pd->y, mw, mh);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Pad *pd, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
|
||||
((Elm_Widget *)(obj))->geom_set(obj,
|
||||
((Elm_Widget *)(obj))->x,
|
||||
((Elm_Widget *)(obj))->y,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_object_part_swallow(pd->base , "elm.swallow.content",
|
||||
((Elm_Widget *)(obj))->base);
|
||||
edje_object_size_min_calc(pd->base, &mw, &mh);
|
||||
if ((pd->minw != mw) || (pd->minh != mh))
|
||||
{
|
||||
pd->minw = mw;
|
||||
pd->minh = mh;
|
||||
((Elm_Widget *)(pd->parent))->size_req(pd->parent, pd, mw, mh);
|
||||
pd->geom_set(pd, pd->x, pd->y, mw, mh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Pad *pd, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
// FIXME: allow for removal of child - size down
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_pad_del(Elm_Pad *pd)
|
||||
{
|
||||
((Elm_Obj_Class *)(((Elm_Pad_Class *)(pd->clas))->parent))->del(ELM_OBJ(pd));
|
||||
}
|
||||
|
||||
EAPI Elm_Pad *
|
||||
elm_pad_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Pad *pd;
|
||||
|
||||
pd = ELM_NEW(Elm_Pad);
|
||||
|
||||
_elm_widget_init(pd);
|
||||
pd->clas = &_elm_pad_class;
|
||||
pd->type = ELM_OBJ_PAD;
|
||||
|
||||
pd->del = _elm_pad_del;
|
||||
|
||||
pd->size_alloc = _elm_pad_size_alloc;
|
||||
pd->size_req = _elm_pad_size_req;
|
||||
|
||||
pd->base = edje_object_add(win->evas);
|
||||
_elm_theme_set(pd->base, "pad", "pad");
|
||||
pd->cb_add(pd, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
pd->cb_add(pd, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(pd);
|
||||
win->child_add(win, pd);
|
||||
return pd;
|
||||
}
|
|
@ -32,6 +32,39 @@ struct _Elm_Config
|
|||
|
||||
#define ELM_NEW(t) calloc(1, sizeof(t))
|
||||
|
||||
void _elm_win_shutdown(void);
|
||||
|
||||
/* FIXME: should this be public? for now - private (but public symbols) */
|
||||
EAPI Evas_Object *elm_widget_add(Evas *evas);
|
||||
EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_data_set(Evas_Object *obj, void *data);
|
||||
EAPI void *elm_widget_data_get(Evas_Object *obj);
|
||||
EAPI void elm_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh);
|
||||
EAPI void elm_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
|
||||
EAPI void elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
|
||||
EAPI void elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
|
||||
EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);
|
||||
EAPI void elm_widget_can_focus_set(Evas_Object *obj, int can_focus);
|
||||
EAPI int elm_widget_can_focus_get(Evas_Object *obj);
|
||||
EAPI int elm_widget_focus_get(Evas_Object *obj);
|
||||
EAPI Evas_Object *elm_widget_focused_object_get(Evas_Object *obj);
|
||||
EAPI int elm_widget_focus_jump(Evas_Object *obj, int forward);
|
||||
EAPI void elm_widget_focus_set(Evas_Object *obj, int first);
|
||||
EAPI void elm_widget_focused_object_clear(Evas_Object *obj);
|
||||
EAPI Evas_Object *elm_widget_parent_get(Evas_Object *obj);
|
||||
EAPI void elm_widget_focus_steal(Evas_Object *obj);
|
||||
EAPI void elm_widget_activate(Evas_Object *obj);
|
||||
EAPI void elm_widget_change(Evas_Object *obj);
|
||||
EAPI void elm_widget_disabled_set(Evas_Object *obj, int disabled);
|
||||
EAPI int elm_widget_disabled_get(Evas_Object *obj);
|
||||
EAPI void elm_widget_min_size_resize(Evas_Object *obj);
|
||||
|
||||
/*
|
||||
void _elm_obj_init(Elm_Obj *obj);
|
||||
void _elm_obj_nest_push(void);
|
||||
void _elm_obj_nest_pop(void);
|
||||
|
@ -41,11 +74,13 @@ void _elm_cb_call(Elm_Obj *obj, Elm_Cb_Type, void *info);
|
|||
int _elm_theme_set(Evas_Object *o, const char *clas, const char *group);
|
||||
void _elm_widget_init(Elm_Widget *wid);
|
||||
void _elm_widget_post_init(Elm_Widget *wid);
|
||||
*/
|
||||
|
||||
extern char *_elm_appname;
|
||||
|
||||
extern Elm_Config *_elm_config;
|
||||
|
||||
/*
|
||||
extern Elm_Obj_Class _elm_obj_class;
|
||||
extern Elm_Win_Class _elm_win_class;
|
||||
extern Elm_Widget_Class _elm_widget_class;
|
||||
|
@ -61,5 +96,6 @@ extern Elm_Clock_Class _elm_clock_class;
|
|||
extern Elm_Frame_Class _elm_frame_class;
|
||||
extern Elm_Pad_Class _elm_pad_class;
|
||||
extern Elm_Contactlist_Class _elm_contactlist_class;
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,100 +1,96 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_scroller_del(Elm_Scroller *sc);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Scroller_Class _elm_scroller_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_SCROLLER
|
||||
Evas_Object *scr;
|
||||
Evas_Object *child;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
|
||||
static void
|
||||
_elm_scroller_del(Elm_Scroller *sc)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
evas_object_del(sc->scroller_pan);
|
||||
((Elm_Obj_Class *)(((Elm_Scroller_Class *)(sc->clas))->parent))->del(ELM_OBJ(sc));
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_scroller_geom_set(Elm_Scroller *sc, int x, int y, int w, int h)
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Evas_Coord vw, vh;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord vw, vh, minw, minh, maxw, maxh;
|
||||
double xw, xy;
|
||||
|
||||
printf("sc geom set %ix%i (am %ix%i)\n", w, h, sc->w, sc->h);
|
||||
if ((sc->w != w) || (sc->h != h) || (sc->x != x) || (sc->y != y))
|
||||
evas_object_size_hint_min_get(wd->child, &minw, &minh);
|
||||
evas_object_size_hint_max_get(wd->child, &maxw, &maxh);
|
||||
evas_object_size_hint_weight_get(wd->child, &xw, &xy);
|
||||
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
|
||||
if (xw > 0.0)
|
||||
{
|
||||
Evas_List *l;
|
||||
int tries = 0;
|
||||
|
||||
((Elm_Widget_Class *)(((Elm_Scroller_Class *)(sc->clas))->parent))->geom_set(sc, x, y, w, h);
|
||||
again:
|
||||
tries++;
|
||||
elm_smart_scroller_child_viewport_size_get(sc->base, &vw, &vh);
|
||||
for (l = sc->children; l; l = l->next)
|
||||
if ((minw > 0) && (vw < minw)) vw = minw;
|
||||
else if ((maxw > 0) && (vw > maxw)) vw = maxw;
|
||||
}
|
||||
else if (minw > 0) vw = minw;
|
||||
if (xy > 0.0)
|
||||
{
|
||||
if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
|
||||
{
|
||||
((Elm_Widget *)(l->data))->size_alloc(l->data, vw, vh);
|
||||
((Elm_Widget *)(l->data))->geom_set(l->data,
|
||||
((Elm_Widget *)(l->data))->x,
|
||||
((Elm_Widget *)(l->data))->y,
|
||||
((Elm_Widget *)(l->data))->req.w,
|
||||
((Elm_Widget *)(l->data))->req.h);
|
||||
// FIXME: if scrollbars affect viewport size then we get an on/off effect of
|
||||
// resizing child up and down. we need to find a way to avoid this. this tries
|
||||
// this is a hack - but works.
|
||||
if ((tries == 1) &&
|
||||
(((vw == ((Elm_Widget *)(l->data))->req.w) ||
|
||||
(vh == ((Elm_Widget *)(l->data))->req.h)))) goto again;
|
||||
}
|
||||
}
|
||||
if ((minh > 0) && (vh < minh)) vh = minh;
|
||||
else if ((maxh > 0) && (vh > maxh)) vh = maxh;
|
||||
}
|
||||
else if (minh > 0) vh = minh;
|
||||
evas_object_resize(wd->child, vw, vh);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Scroller *sc, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Coord vw, vh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
elm_smart_scroller_child_set(sc->base, ((Elm_Widget *)(obj))->base);
|
||||
elm_smart_scroller_child_viewport_size_get(sc->base, &vw, &vh);
|
||||
((Elm_Widget *)(obj))->size_alloc(obj, vw, vh);
|
||||
((Elm_Widget *)(obj))->geom_set(obj,
|
||||
((Elm_Widget *)(obj))->x,
|
||||
((Elm_Widget *)(obj))->y,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Scroller *sc, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
elm_smart_scroller_child_set(sc->base, NULL);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
EAPI Elm_Scroller *
|
||||
elm_scroller_new(Elm_Win *win)
|
||||
EAPI Evas_Object *
|
||||
elm_scroller_add(Evas_Object *parent)
|
||||
{
|
||||
Elm_Scroller *sc;
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
Evas_Coord vw, vh, minw, minh;
|
||||
|
||||
sc = ELM_NEW(Elm_Scroller);
|
||||
_elm_widget_init(sc);
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
sc->clas = &_elm_scroller_class;
|
||||
sc->type = ELM_OBJ_SCROLLER;
|
||||
wd->scr = elm_smart_scroller_add(e);
|
||||
elm_widget_resize_object_set(obj, wd->scr);
|
||||
|
||||
sc->del = _elm_scroller_del;
|
||||
edje_object_size_min_calc(wd->scr, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
|
||||
|
||||
sc->geom_set = _elm_scroller_geom_set;
|
||||
|
||||
sc->base = elm_smart_scroller_add(win->evas);
|
||||
|
||||
sc->cb_add(sc, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
sc->cb_add(sc, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(sc);
|
||||
win->child_add(win, sc);
|
||||
return sc;
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_scroller_child_set(Evas_Object *obj, Evas_Object *child)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
wd->child = child;
|
||||
elm_smart_scroller_child_set(wd->scr, child);
|
||||
evas_object_event_callback_add(child, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
elm_widget_sub_object_add(obj, child);
|
||||
// FIXME: track new sub obj...
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
|
|
@ -1,105 +1,81 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_table_layout_update(Elm_Table *tb);
|
||||
static void _elm_table_pack(Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Table_Class _elm_table_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_TABLE,
|
||||
_elm_table_layout_update,
|
||||
_elm_table_pack,
|
||||
Evas_Object *tbl;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
|
||||
static void
|
||||
_elm_table_layout_update(Elm_Table *tb)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
_els_smart_table_homogenous_set(tb->base, tb->homogenous);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_table_pack(Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h)
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
tb->child_add(tb, wid);
|
||||
_els_smart_table_pack(tb->base, wid->base, x, y, w, h);
|
||||
elm_widget_sizing_update(wid);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
Evas_Coord w, h;
|
||||
|
||||
evas_object_size_hint_min_get(wd->tbl, &minw, &minh);
|
||||
evas_object_size_hint_max_get(wd->tbl, &maxw, &maxh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
if (w < minw) w = minw;
|
||||
if (h < minh) h = minh;
|
||||
if ((maxw >= 0) && (w > maxw)) w = maxw;
|
||||
if ((maxh >= 0) && (h > maxh)) h = maxh;
|
||||
evas_object_resize(obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_table_size_alloc(Elm_Table *tb, int w, int h)
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
_els_smart_table_min_size_get(tb->base, &mw, &mh);
|
||||
if (w < mw) w = mw;
|
||||
if (h < mh) h = mh;
|
||||
tb->req.w = w;
|
||||
tb->req.h = h;
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_table_size_req(Elm_Table *tb, Elm_Widget *child, int w, int h)
|
||||
EAPI Evas_Object *
|
||||
elm_table_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
if (child)
|
||||
{
|
||||
Evas_Coord maxx, maxy;
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
child->size_alloc(child, 0, 0);
|
||||
maxx = child->req.w;
|
||||
maxy = child->req.h;
|
||||
if (child->expand_x) maxx = 32767;
|
||||
if (child->expand_y) maxy = 32767;
|
||||
_els_smart_table_pack_options_set(child->base,
|
||||
child->fill_x, child->fill_y,
|
||||
child->expand_x, child->expand_y,
|
||||
child->align_x, child->align_y,
|
||||
child->req.w, child->req.h,
|
||||
maxx, maxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle.
|
||||
}
|
||||
_els_smart_table_min_size_get(tb->base, &mw, &mh);
|
||||
((Elm_Widget *)(tb->parent))->size_req(tb->parent, tb, mw, mh);
|
||||
tb->geom_set(tb, tb->x, tb->y, mw, mh);
|
||||
wd->tbl = _els_smart_table_add(e);
|
||||
elm_widget_sub_object_add(obj, wd->tbl);
|
||||
evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
elm_widget_resize_object_set(obj, wd->tbl);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Table *tb, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
EAPI void
|
||||
elm_table_homogenous_set(Evas_Object *obj, Evas_Bool homogenous)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
_els_smart_table_unpack(((Elm_Widget *)(obj))->base);
|
||||
((Elm_Widget *)(tb->parent))->size_req(tb->parent, tb, mw, mh);
|
||||
tb->geom_set(tb, tb->x, tb->y, mw, mh);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_table_homogenous_set(wd->tbl, homogenous);
|
||||
}
|
||||
|
||||
EAPI Elm_Table *
|
||||
elm_table_new(Elm_Win *win)
|
||||
EAPI void
|
||||
elm_table_pack(Evas_Object *obj, Evas_Object *subobj, int x, int y, int w, int h)
|
||||
{
|
||||
Elm_Table *tb;
|
||||
|
||||
tb = ELM_NEW(Elm_Table);
|
||||
|
||||
_elm_widget_init(tb);
|
||||
tb->clas = &_elm_table_class;
|
||||
tb->type = ELM_OBJ_TABLE;
|
||||
|
||||
tb->layout_update = _elm_table_layout_update;
|
||||
tb->pack = _elm_table_pack;
|
||||
|
||||
tb->size_alloc = _elm_table_size_alloc;
|
||||
tb->size_req = _elm_table_size_req;
|
||||
|
||||
tb->base = _els_smart_table_add(win->evas);
|
||||
|
||||
tb->cb_add(tb, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(tb);
|
||||
win->child_add(win, tb);
|
||||
return tb;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_table_pack(wd->tbl, subobj, x, y, w, h);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
// FIXME: track new sub obj...
|
||||
}
|
||||
|
|
|
@ -1,210 +1,160 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_toggle_text_set(Elm_Toggle *tg, const char *text);
|
||||
static void _elm_toggle_layout_update(Elm_Toggle *tg);
|
||||
static void _elm_toggle_states_text_set(Elm_Toggle *tg, const char *ontext, const char *offtext);
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
Elm_Toggle_Class _elm_toggle_class =
|
||||
struct _Widget_Data
|
||||
{
|
||||
&_elm_widget_class,
|
||||
ELM_OBJ_TOGGLE,
|
||||
_elm_toggle_text_set,
|
||||
_elm_toggle_layout_update,
|
||||
_elm_toggle_states_text_set
|
||||
Evas_Object *tgl;
|
||||
Evas_Bool state;
|
||||
Evas_Bool *statep;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
|
||||
static void
|
||||
_elm_toggle_text_set(Elm_Toggle *tg, const char *text)
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
edje_object_size_min_calc(wd->tgl, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
edje_object_part_swallow(wd->tgl, "elm.swallow.content", obj);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
wd->state = 0;
|
||||
if (wd->statep) *wd->statep = wd->state;
|
||||
evas_object_smart_callback_call(data, "changed", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
wd->state = 1;
|
||||
if (wd->statep) *wd->statep = wd->state;
|
||||
evas_object_smart_callback_call(data, "changed", NULL);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_toggle_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->tgl = edje_object_add(e);
|
||||
_elm_theme_set(wd->tgl, "toggle", "toggle");
|
||||
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,on", "", _signal_toggle_on, obj);
|
||||
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,off", "", _signal_toggle_off, obj);
|
||||
elm_widget_resize_object_set(obj, wd->tgl);
|
||||
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_toggle_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (text)
|
||||
if (label)
|
||||
{
|
||||
edje_object_signal_emit(tg->base, "elm,state,text,visible", "elm");
|
||||
edje_object_message_signal_process(tg->base);
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,text,visible", "elm");
|
||||
edje_object_message_signal_process(wd->tgl);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(tg->base, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(tg->base);
|
||||
}
|
||||
edje_object_part_text_set(tg->base, "elm.text", text);
|
||||
edje_object_size_min_calc(tg->base, &mw, &mh);
|
||||
if ((tg->minw != mw) || (tg->minh != mh))
|
||||
{
|
||||
tg->minw = mw;
|
||||
tg->minh = mh;
|
||||
((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, tg->minw, tg->minh);
|
||||
tg->geom_set(tg, tg->x, tg->y, tg->minw, tg->minh);
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(wd->tgl);
|
||||
}
|
||||
edje_object_part_text_set(wd->tgl, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_states_text_set(Elm_Toggle *tg, const char *ontext, const char *offtext)
|
||||
EAPI void
|
||||
elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||
{
|
||||
edje_object_part_text_set(tg->base, "elm.ontext", ontext);
|
||||
edje_object_part_text_set(tg->base, "elm.offtext", offtext);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_swallow(wd->tgl, "elm.swallow.content", icon);
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,icon,visible", "elm");
|
||||
elm_widget_sub_object_add(obj, icon);
|
||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
// FIXME: track new sub obj...
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_layout_update(Elm_Toggle *tg)
|
||||
EAPI void
|
||||
elm_toggle_states_labels_set(Evas_Object *obj, const char *onlabel, const char *offlabel)
|
||||
{
|
||||
if (tg->state_ptr) tg->state = *(tg->state_ptr);
|
||||
if (tg->state)
|
||||
edje_object_signal_emit(tg->base, "elm,state,toggle,on", "elm");
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_text_set(wd->tgl, "elm.ontext", onlabel);
|
||||
edje_object_part_text_set(wd->tgl, "elm.offtext", offlabel);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_toggle_state_set(Evas_Object *obj, Evas_Bool state)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (state != wd->state)
|
||||
{
|
||||
wd->state = state;
|
||||
if (wd->statep) *wd->statep = wd->state;
|
||||
if (wd->state)
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,toggle,on", "elm");
|
||||
else
|
||||
edje_object_signal_emit(tg->base, "elm,state,toggle,off", "elm");
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_size_alloc(Elm_Toggle *tg, int w, int h)
|
||||
{
|
||||
if (w < tg->minw) w = tg->minw;
|
||||
if (h < tg->minh) h = tg->minh;
|
||||
tg->req.w = w;
|
||||
tg->req.h = h;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_size_req(Elm_Toggle *tg, Elm_Widget *child, int w, int h)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (child)
|
||||
{
|
||||
Evas_Coord maxx, maxy;
|
||||
|
||||
child->size_alloc(child, 0, 0);
|
||||
maxx = child->req.w;
|
||||
maxy = child->req.h;
|
||||
if (child->expand_x) maxx = 32767;
|
||||
if (child->expand_y) maxy = 32767;
|
||||
edje_extern_object_min_size_set(child->base,
|
||||
child->req.w,
|
||||
child->req.h);
|
||||
edje_object_part_swallow(tg->base , "elm.swallow.contents",
|
||||
child->base);
|
||||
edje_object_size_min_calc(tg->base, &mw, &mh);
|
||||
if ((tg->minw != mw) || (tg->minh != mh))
|
||||
{
|
||||
tg->minw = mw;
|
||||
tg->minh = mh;
|
||||
((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, mw, mh);
|
||||
tg->geom_set(tg, tg->x, tg->y, mw, mh);
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,toggle,off", "elm");
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_toggle_state_pointer_set(Evas_Object *obj, Evas_Bool *statep)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
if (statep)
|
||||
{
|
||||
wd->statep = statep;
|
||||
if (*wd->statep != wd->state)
|
||||
{
|
||||
wd->state = *wd->statep;
|
||||
if (wd->state)
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,toggle,on", "elm");
|
||||
else
|
||||
{
|
||||
// FIXME: handle
|
||||
edje_object_signal_emit(wd->tgl, "elm,state,toggle,off", "elm");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Toggle *tg, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
edje_object_signal_emit(tg->base, "elm,state,icon,visible", "elm");
|
||||
edje_object_message_signal_process(tg->base);
|
||||
((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
|
||||
((Elm_Widget *)(obj))->geom_set(obj,
|
||||
((Elm_Widget *)(obj))->x,
|
||||
((Elm_Widget *)(obj))->y,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
|
||||
((Elm_Widget *)(obj))->req.w,
|
||||
((Elm_Widget *)(obj))->req.h);
|
||||
edje_object_part_swallow(tg->base , "elm.swallow.contents",
|
||||
((Elm_Widget *)(obj))->base);
|
||||
edje_object_size_min_calc(tg->base, &mw, &mh);
|
||||
if ((tg->minw != mw) || (tg->minh != mh))
|
||||
{
|
||||
tg->minw = mw;
|
||||
tg->minh = mh;
|
||||
((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, mw, mh);
|
||||
tg->geom_set(tg, tg->x, tg->y, mw, mh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Toggle *tg, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
// FIXME: allow for removal of child - size down
|
||||
edje_object_signal_emit(tg->base, "elm,state,icon,hidden", "elm");
|
||||
edje_object_message_signal_process(tg->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_activate(Elm_Toggle *tg)
|
||||
{
|
||||
if (tg->state_ptr) *(tg->state_ptr) = tg->state;
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(tg), ELM_CB_CHANGED, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Elm_Toggle *tg = data;
|
||||
|
||||
if (tg->state) return;
|
||||
tg->state = 1;
|
||||
_elm_toggle_activate(tg);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Elm_Toggle *tg = data;
|
||||
|
||||
if (!tg->state) return;
|
||||
tg->state = 0;
|
||||
_elm_toggle_activate(tg);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_toggle_del(Elm_Toggle *tg)
|
||||
{
|
||||
if (tg->text) evas_stringshare_del(tg->text);
|
||||
((Elm_Obj_Class *)(((Elm_Toggle_Class *)(tg->clas))->parent))->del(ELM_OBJ(tg));
|
||||
}
|
||||
|
||||
EAPI Elm_Toggle *
|
||||
elm_toggle_new(Elm_Win *win)
|
||||
{
|
||||
Elm_Toggle *tg;
|
||||
|
||||
tg = ELM_NEW(Elm_Toggle);
|
||||
|
||||
_elm_widget_init(tg);
|
||||
tg->clas = &_elm_toggle_class;
|
||||
tg->type = ELM_OBJ_TOGGLE;
|
||||
|
||||
tg->del = _elm_toggle_del;
|
||||
|
||||
tg->size_alloc = _elm_toggle_size_alloc;
|
||||
tg->size_req = _elm_toggle_size_req;
|
||||
|
||||
tg->text_set = _elm_toggle_text_set;
|
||||
tg->layout_update = _elm_toggle_layout_update;
|
||||
tg->states_text_set = _elm_toggle_states_text_set;
|
||||
|
||||
tg->base = edje_object_add(win->evas);
|
||||
_elm_theme_set(tg->base, "toggle", "toggle");
|
||||
edje_object_part_text_set(tg->base, "elm.ontext", "ON");
|
||||
edje_object_part_text_set(tg->base, "elm.offtext", "OFF");
|
||||
edje_object_signal_callback_add(tg->base, "elm,action,toggle,on", "",
|
||||
_elm_signal_toggle_on, tg);
|
||||
edje_object_signal_callback_add(tg->base, "elm,action,toggle,off", "",
|
||||
_elm_signal_toggle_off, tg);
|
||||
tg->cb_add(tg, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
tg->cb_add(tg, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_widget_post_init(tg);
|
||||
win->child_add(win, tg);
|
||||
return tg;
|
||||
}
|
||||
|
|
|
@ -1,137 +1,576 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_widget_geom_set(Elm_Widget *wid, int x, int y, int w, int h);
|
||||
static void _elm_widget_show(Elm_Widget *wid);
|
||||
static void _elm_widget_hide(Elm_Widget *wid);
|
||||
static void _elm_widget_size_alloc(Elm_Widget *wid, int w, int h);
|
||||
static void _elm_widget_size_req(Elm_Widget *wid, Elm_Widget *child, int w, int h);
|
||||
static void _elm_widget_del(Elm_Widget *wid);
|
||||
static void _elm_widget_above(Elm_Widget *wid, Elm_Widget *above);
|
||||
static void _elm_widget_below(Elm_Widget *wid, Elm_Widget *below);
|
||||
#define SMART_NAME "e_widget"
|
||||
#define API_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
|
||||
#define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
|
||||
typedef struct _Smart_Data Smart_Data;
|
||||
|
||||
Elm_Widget_Class _elm_widget_class =
|
||||
struct _Smart_Data
|
||||
{
|
||||
&_elm_obj_class, /* parent */
|
||||
ELM_OBJ_WIDGET,
|
||||
_elm_widget_geom_set,
|
||||
_elm_widget_show,
|
||||
_elm_widget_hide,
|
||||
_elm_widget_size_alloc,
|
||||
_elm_widget_size_req,
|
||||
_elm_widget_above,
|
||||
_elm_widget_below
|
||||
Evas_Object *parent_obj;
|
||||
Evas_Coord x, y, w, h;
|
||||
Evas_Coord minw, minh;
|
||||
Evas_List *subobjs;
|
||||
Evas_Object *resize_obj;
|
||||
void (*del_func) (Evas_Object *obj);
|
||||
void (*focus_func) (Evas_Object *obj);
|
||||
void (*activate_func) (Evas_Object *obj);
|
||||
void (*disable_func) (Evas_Object *obj);
|
||||
void (*on_focus_func) (void *data, Evas_Object *obj);
|
||||
void *on_focus_data;
|
||||
void (*on_change_func) (void *data, Evas_Object *obj);
|
||||
void *on_change_data;
|
||||
void *data;
|
||||
unsigned char can_focus : 1;
|
||||
unsigned char child_can_focus : 1;
|
||||
unsigned char focused : 1;
|
||||
unsigned char disabled : 1;
|
||||
};
|
||||
|
||||
static void
|
||||
_elm_widget_geom_set(Elm_Widget *wid, int x, int y, int w, int h)
|
||||
/* local subsystem functions */
|
||||
static void _smart_reconfigure(Smart_Data *sd);
|
||||
static void _smart_add(Evas_Object *obj);
|
||||
static void _smart_del(Evas_Object *obj);
|
||||
static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
||||
static void _smart_show(Evas_Object *obj);
|
||||
static void _smart_hide(Evas_Object *obj);
|
||||
static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
|
||||
static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
|
||||
static void _smart_clip_unset(Evas_Object *obj);
|
||||
static void _smart_init(void);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Evas_Smart *_e_smart = NULL;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI Evas_Object *
|
||||
elm_widget_add(Evas *evas)
|
||||
{
|
||||
if ((wid->x != x) || (wid->y != y))
|
||||
{
|
||||
wid->x = x;
|
||||
wid->y = y;
|
||||
evas_object_move(wid->base, wid->x, wid->y);
|
||||
}
|
||||
if ((wid->w != w) || (wid->h != h))
|
||||
{
|
||||
wid->w = w;
|
||||
wid->h = h;
|
||||
evas_object_resize(wid->base, wid->w, wid->h);
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(wid), ELM_CB_RESIZE, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_show(Elm_Widget *wid)
|
||||
{
|
||||
evas_object_show(wid->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_hide(Elm_Widget *wid)
|
||||
{
|
||||
evas_object_hide(wid->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_size_alloc(Elm_Widget *wid, int w, int h)
|
||||
{
|
||||
// FIXME: widget gets to implement min/max etc. size here (indicating
|
||||
// given the input w, h - what size it is willing to accept, then the
|
||||
// parent checks and geometry_set()'s the child
|
||||
wid->req.w = w;
|
||||
wid->req.h = h;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_size_req(Elm_Widget *wid, Elm_Widget *child, int w, int h)
|
||||
{
|
||||
// FIXME: a child will ask its parent for a requested size if something
|
||||
// with its sizing setup. this is the call in the parent that will be
|
||||
// called
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_above(Elm_Widget *wid, Elm_Widget *above)
|
||||
{
|
||||
if (above) evas_object_stack_above(wid->base, above->base);
|
||||
else evas_object_raise(wid->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_below(Elm_Widget *wid, Elm_Widget *below)
|
||||
{
|
||||
if (below) evas_object_stack_below(wid->base, below->base);
|
||||
else evas_object_lower(wid->base);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_widget_del(Elm_Widget *wid)
|
||||
{
|
||||
if (_elm_obj_del_defer(ELM_OBJ(wid))) return;
|
||||
|
||||
evas_object_del(wid->base);
|
||||
|
||||
((Elm_Obj_Class *)(((Elm_Widget_Class *)(wid->clas))->parent))->del(ELM_OBJ(wid));
|
||||
}
|
||||
|
||||
void
|
||||
_elm_widget_init(Elm_Widget *wid)
|
||||
{
|
||||
_elm_obj_init(ELM_OBJ(wid));
|
||||
wid->clas = &_elm_widget_class;
|
||||
wid->type = ELM_OBJ_WIDGET;
|
||||
|
||||
wid->del = _elm_widget_del;
|
||||
|
||||
wid->geom_set = _elm_widget_geom_set;
|
||||
wid->show = _elm_widget_show;
|
||||
wid->hide = _elm_widget_hide;
|
||||
wid->size_alloc = _elm_widget_size_alloc;
|
||||
wid->size_req = _elm_widget_size_req;
|
||||
wid->above = _elm_widget_above;
|
||||
wid->below = _elm_widget_below;
|
||||
|
||||
wid->align_x = 0.5;
|
||||
wid->align_y = 0.5;
|
||||
wid->expand_x = 1;
|
||||
wid->expand_y = 1;
|
||||
wid->fill_x = 1;
|
||||
wid->fill_y = 1;
|
||||
}
|
||||
|
||||
void
|
||||
_elm_widget_post_init(Elm_Widget *wid)
|
||||
{
|
||||
if (wid->base) evas_object_data_set(wid->base, "__Elm", wid);
|
||||
_smart_init();
|
||||
return evas_object_smart_add(evas, _e_smart);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_sizing_update(Elm_Widget *wid)
|
||||
elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
||||
{
|
||||
wid->size_alloc(wid, 0, 0);
|
||||
if (!wid->parent) return;
|
||||
((Elm_Widget *)(wid->parent))->size_req(wid->parent, wid, wid->w, wid->h);
|
||||
API_ENTRY return;
|
||||
sd->del_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->focus_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->activate_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->disable_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->on_focus_func = func;
|
||||
sd->on_focus_data = data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->on_change_func = func;
|
||||
sd->on_change_data = data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_data_set(Evas_Object *obj, void *data)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->data = data;
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
elm_widget_data_get(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return NULL;
|
||||
return sd->data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (minw >= 0)
|
||||
sd->minw = minw;
|
||||
if (minh >= 0)
|
||||
sd->minh = minh;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (minw) *minw = sd->minw;
|
||||
if (minh) *minh = sd->minh;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->subobjs = evas_list_append(sd->subobjs, sobj);
|
||||
if (!sd->child_can_focus)
|
||||
{
|
||||
if (elm_widget_can_focus_get(sobj)) sd->child_can_focus = 1;
|
||||
}
|
||||
if (!strcmp(evas_object_type_get(sobj), SMART_NAME))
|
||||
{
|
||||
sd = evas_object_smart_data_get(sobj);
|
||||
if (sd)
|
||||
{
|
||||
if (sd->parent_obj) elm_widget_sub_object_del(sd->parent_obj, sobj);
|
||||
sd->parent_obj = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->subobjs = evas_list_remove(sd->subobjs, sobj);
|
||||
if (!sd->child_can_focus)
|
||||
{
|
||||
if (elm_widget_can_focus_get(sobj)) sd->child_can_focus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (sd->resize_obj) evas_object_smart_member_del(sd->resize_obj);
|
||||
sd->resize_obj = sobj;
|
||||
evas_object_smart_member_add(sobj, obj);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_can_focus_set(Evas_Object *obj, int can_focus)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->can_focus = can_focus;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_widget_can_focus_get(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return 0;
|
||||
if (sd->can_focus) return 1;
|
||||
if (sd->child_can_focus) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_widget_focus_get(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return 0;
|
||||
return sd->focused;
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_widget_focused_object_get(Evas_Object *obj)
|
||||
{
|
||||
Evas_List *l;
|
||||
API_ENTRY return NULL;
|
||||
if (!sd->focused) return NULL;
|
||||
for (l = sd->subobjs; l; l = l->next)
|
||||
{
|
||||
Evas_Object *fobj;
|
||||
|
||||
fobj = elm_widget_focused_object_get(l->data);
|
||||
if (fobj) return fobj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_widget_focus_jump(Evas_Object *obj, int forward)
|
||||
{
|
||||
API_ENTRY return 0;
|
||||
if (!elm_widget_can_focus_get(obj)) return 0;
|
||||
|
||||
/* if it has a focus func its an end-point widget like a button */
|
||||
if (sd->focus_func)
|
||||
{
|
||||
if (!sd->focused) sd->focused = 1;
|
||||
else sd->focused = 0;
|
||||
sd->focus_func(obj);
|
||||
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
||||
return sd->focused;
|
||||
}
|
||||
/* its some container */
|
||||
else
|
||||
{
|
||||
Evas_List *l;
|
||||
int focus_next;
|
||||
|
||||
focus_next = 0;
|
||||
if (!sd->focused)
|
||||
{
|
||||
elm_widget_focus_set(obj, forward);
|
||||
sd->focused = 1;
|
||||
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (forward)
|
||||
{
|
||||
for (l = sd->subobjs; l; l = l->next)
|
||||
{
|
||||
if (elm_widget_can_focus_get(l->data))
|
||||
{
|
||||
if ((focus_next) &&
|
||||
(!elm_widget_disabled_get(l->data)))
|
||||
{
|
||||
/* the previous focused item was unfocused - so focus
|
||||
* the next one (that can be focused) */
|
||||
if (elm_widget_focus_jump(l->data, forward)) return 1;
|
||||
else break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elm_widget_focus_get(l->data))
|
||||
{
|
||||
/* jump to the next focused item or focus this item */
|
||||
if (elm_widget_focus_jump(l->data, forward)) return 1;
|
||||
/* it returned 0 - it got to the last item and is past it */
|
||||
focus_next = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = evas_list_last(sd->subobjs); l; l = l->prev)
|
||||
{
|
||||
if (elm_widget_can_focus_get(l->data))
|
||||
{
|
||||
if ((focus_next) &&
|
||||
(!elm_widget_disabled_get(l->data)))
|
||||
{
|
||||
/* the previous focused item was unfocused - so focus
|
||||
* the next one (that can be focused) */
|
||||
if (elm_widget_focus_jump(l->data, forward)) return 1;
|
||||
else break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elm_widget_focus_get(l->data))
|
||||
{
|
||||
/* jump to the next focused item or focus this item */
|
||||
if (elm_widget_focus_jump(l->data, forward)) return 1;
|
||||
/* it returned 0 - it got to the last item and is past it */
|
||||
focus_next = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* no next item can be focused */
|
||||
sd->focused = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_focus_set(Evas_Object *obj, int first)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (!sd->focused)
|
||||
{
|
||||
sd->focused = 1;
|
||||
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
||||
}
|
||||
if (sd->focus_func)
|
||||
{
|
||||
sd->focus_func(obj);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
if (first)
|
||||
{
|
||||
for (l = sd->subobjs; l; l = l->next)
|
||||
{
|
||||
if ((elm_widget_can_focus_get(l->data)) &&
|
||||
(!elm_widget_disabled_get(l->data)))
|
||||
{
|
||||
elm_widget_focus_set(l->data, first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = evas_list_last(sd->subobjs); l; l = l->prev)
|
||||
{
|
||||
if ((elm_widget_can_focus_get(l->data)) &&
|
||||
(!elm_widget_disabled_get(l->data)))
|
||||
{
|
||||
elm_widget_focus_set(l->data, first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_widget_parent_get(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return NULL;
|
||||
return sd->parent_obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_focused_object_clear(Evas_Object *obj)
|
||||
{
|
||||
Evas_List *l;
|
||||
API_ENTRY return;
|
||||
if (!sd->focused) return;
|
||||
sd->focused = 0;
|
||||
for (l = sd->subobjs; l; l = l->next)
|
||||
{
|
||||
if (elm_widget_focus_get(l->data))
|
||||
{
|
||||
elm_widget_focused_object_clear(l->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sd->focus_func) sd->focus_func(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_focus_steal(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object *parent, *o;
|
||||
API_ENTRY return;
|
||||
if (sd->focused) return;
|
||||
if (sd->disabled) return;
|
||||
parent = obj;
|
||||
for (;;)
|
||||
{
|
||||
o = elm_widget_parent_get(parent);
|
||||
if (!o) break;
|
||||
parent = o;
|
||||
}
|
||||
elm_widget_focused_object_clear(parent);
|
||||
parent = obj;
|
||||
for (;;)
|
||||
{
|
||||
sd = evas_object_smart_data_get(parent);
|
||||
sd->focused = 1;
|
||||
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, parent);
|
||||
o = elm_widget_parent_get(parent);
|
||||
if (!o) break;
|
||||
parent = o;
|
||||
}
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (sd->focus_func) sd->focus_func(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_activate(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
elm_widget_change(obj);
|
||||
if (sd->activate_func) sd->activate_func(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_change(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
elm_widget_change(elm_widget_parent_get(obj));
|
||||
if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_disabled_set(Evas_Object *obj, int disabled)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (((sd->disabled) && (disabled)) ||
|
||||
((!sd->disabled) && (!disabled))) return;
|
||||
sd->disabled = disabled;
|
||||
if (sd->focused)
|
||||
{
|
||||
Evas_Object *o, *parent;
|
||||
|
||||
parent = obj;
|
||||
for (;;)
|
||||
{
|
||||
o = elm_widget_parent_get(parent);
|
||||
if (!o) break;
|
||||
parent = o;
|
||||
}
|
||||
elm_widget_focus_jump(parent, 1);
|
||||
}
|
||||
if (sd->disable_func) sd->disable_func(obj);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_widget_disabled_get(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return 0;
|
||||
return sd->disabled;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_min_size_resize(Evas_Object *obj)
|
||||
{
|
||||
API_ENTRY return;
|
||||
evas_object_resize(obj, sd->minw, sd->minh);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
{
|
||||
if (sd->resize_obj)
|
||||
{
|
||||
evas_object_move(sd->resize_obj, sd->x, sd->y);
|
||||
evas_object_resize(sd->resize_obj, sd->w, sd->h);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_add(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = calloc(1, sizeof(Smart_Data));
|
||||
if (!sd) return;
|
||||
sd->x = 0;
|
||||
sd->y = 0;
|
||||
sd->w = 0;
|
||||
sd->h = 0;
|
||||
sd->can_focus = 1;
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_del(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object *sobj;
|
||||
|
||||
INTERNAL_ENTRY;
|
||||
if (sd->del_func) sd->del_func(obj);
|
||||
while (sd->subobjs)
|
||||
{
|
||||
sobj = sd->subobjs->data;
|
||||
sd->subobjs = evas_list_remove_list(sd->subobjs, sd->subobjs);
|
||||
evas_object_del(sobj);
|
||||
}
|
||||
free(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
sd->x = x;
|
||||
sd->y = y;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
sd->w = w;
|
||||
sd->h = h;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_show(Evas_Object *obj)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
evas_object_show(sd->resize_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_hide(Evas_Object *obj)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
evas_object_hide(sd->resize_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
evas_object_color_set(sd->resize_obj, r, g, b, a);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
evas_object_clip_set(sd->resize_obj, clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_clip_unset(Evas_Object *obj)
|
||||
{
|
||||
INTERNAL_ENTRY;
|
||||
evas_object_clip_unset(sd->resize_obj);
|
||||
}
|
||||
|
||||
/* never need to touch this */
|
||||
|
||||
static void
|
||||
_smart_init(void)
|
||||
{
|
||||
if (_e_smart) return;
|
||||
{
|
||||
static const Evas_Smart_Class sc =
|
||||
{
|
||||
SMART_NAME,
|
||||
EVAS_SMART_CLASS_VERSION,
|
||||
_smart_add,
|
||||
_smart_del,
|
||||
_smart_move,
|
||||
_smart_resize,
|
||||
_smart_show,
|
||||
_smart_hide,
|
||||
_smart_color_set,
|
||||
_smart_clip_set,
|
||||
_smart_clip_unset,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
_e_smart = evas_smart_class_new(&sc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,254 +1,328 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static void _elm_win_name_set(Elm_Win *win, const char *name);
|
||||
static void _elm_win_title_set(Elm_Win *win, const char *title);
|
||||
static void _elm_win_show(Elm_Win *win);
|
||||
static void _elm_win_hide(Elm_Win *win);
|
||||
static void _elm_win_del(Elm_Win *win);
|
||||
typedef struct _Elm_Win Elm_Win;
|
||||
|
||||
Elm_Win_Class _elm_win_class =
|
||||
struct _Elm_Win
|
||||
{
|
||||
&_elm_obj_class, /* parent */
|
||||
ELM_OBJ_WIN,
|
||||
_elm_win_name_set,
|
||||
_elm_win_title_set
|
||||
Ecore_Evas *ee;
|
||||
Evas *evas;
|
||||
Evas_Object *parent;
|
||||
Evas_Object *win_obj;
|
||||
Evas_List *subobjs;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_Job *deferred_resize_job;
|
||||
Ecore_Job *deferred_child_eval_job;
|
||||
Elm_Win_Type type;
|
||||
Evas_Bool autodel : 1;
|
||||
};
|
||||
|
||||
static void _elm_win_resize(Ecore_Evas *ee);
|
||||
static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
|
||||
static void _elm_win_obj_intercept_hide(void *data, Evas_Object *obj);
|
||||
static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _elm_win_obj_intercept_resize(void *data, Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
||||
static void _elm_win_obj_intercept_raise(void *data, Evas_Object *obj);
|
||||
static void _elm_win_obj_intercept_lower(void *data, Evas_Object *obj);
|
||||
static void _elm_win_obj_intercept_stack_above(void *data, Evas_Object *obj, Evas_Object *above);
|
||||
static void _elm_win_obj_intercept_stack_below(void *data, Evas_Object *obj, Evas_Object *below);
|
||||
static void _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj, int l);
|
||||
static void _elm_win_obj_intercept_color_set(void *data, Evas_Object *obj, int r, int g, int b, int a);
|
||||
static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _elm_win_obj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _elm_win_delete_request(Ecore_Evas *ee);
|
||||
static void _elm_win_resize_job(void *data);
|
||||
static void _elm_win_xwin_update(Elm_Win *win);
|
||||
static void _elm_win_eval_subobjs(Evas_Object *obj);
|
||||
static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
|
||||
static Evas_List *_elm_win_list = NULL;
|
||||
|
||||
static void
|
||||
_elm_child_eval_job(Elm_Win *win)
|
||||
_elm_win_resize(Ecore_Evas *ee)
|
||||
{
|
||||
Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
|
||||
if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
|
||||
win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_show(void *data, Evas_Object *obj)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
ecore_evas_show(win->ee);
|
||||
evas_object_show(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_hide(void *data, Evas_Object *obj)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
ecore_evas_hide(win->ee);
|
||||
evas_object_hide(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
// FIXME: account for frame
|
||||
ecore_evas_move(win->ee, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_resize(void *data, Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
ecore_evas_resize(win->ee, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_raise(void *data, Evas_Object *obj)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
ecore_evas_raise(win->ee);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_lower(void *data, Evas_Object *obj)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
ecore_evas_lower(win->ee);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_stack_above(void *data, Evas_Object *obj, Evas_Object *above)
|
||||
{
|
||||
if (above)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(above, "__Elm");
|
||||
if (!win) evas_object_raise(obj);
|
||||
// FIXME: find window id of win and stack abive
|
||||
return;
|
||||
}
|
||||
evas_object_raise(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_stack_below(void *data, Evas_Object *obj, Evas_Object *below)
|
||||
{
|
||||
if (below)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(below, "__Elm");
|
||||
if (!win) evas_object_raise(obj);
|
||||
// FIXME: find window id of win and stack below
|
||||
return;
|
||||
}
|
||||
evas_object_lower(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj, int l)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
// FIXME: use netwm above/below hints
|
||||
ecore_evas_layer_set(win->ee, l);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_intercept_color_set(void *data, Evas_Object *obj, int r, int g, int b, int a)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
|
||||
_elm_win_list = evas_list_remove(_elm_win_list, win->win_obj);
|
||||
while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
|
||||
evas_object_intercept_show_callback_del(win->win_obj, _elm_win_obj_intercept_show);
|
||||
evas_object_intercept_hide_callback_del(win->win_obj, _elm_win_obj_intercept_hide);
|
||||
evas_object_intercept_move_callback_del(win->win_obj, _elm_win_obj_intercept_move);
|
||||
evas_object_intercept_resize_callback_del(win->win_obj, _elm_win_obj_intercept_resize);
|
||||
evas_object_intercept_raise_callback_del(win->win_obj, _elm_win_obj_intercept_raise);
|
||||
evas_object_intercept_lower_callback_del(win->win_obj, _elm_win_obj_intercept_lower);
|
||||
evas_object_intercept_stack_above_callback_del(win->win_obj, _elm_win_obj_intercept_stack_above);
|
||||
evas_object_intercept_stack_below_callback_del(win->win_obj, _elm_win_obj_intercept_stack_below);
|
||||
evas_object_intercept_layer_set_callback_del(win->win_obj, _elm_win_obj_intercept_layer_set);
|
||||
evas_object_intercept_color_set_callback_del(win->win_obj, _elm_win_obj_intercept_color_set);
|
||||
evas_object_event_callback_del(win->win_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_del);
|
||||
evas_object_event_callback_del(win->win_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _elm_win_obj_callback_changed_size_hints);
|
||||
ecore_evas_free(win->ee);
|
||||
if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
|
||||
if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
|
||||
free(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_obj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
Evas_Coord w, h;
|
||||
|
||||
evas_object_size_hint_min_get(obj, &w, &h);
|
||||
ecore_evas_size_min_set(win->ee, w, h);
|
||||
evas_object_size_hint_max_get(obj, &w, &h);
|
||||
if (w < 1) w = -1;
|
||||
if (h < 1) h = -1;
|
||||
ecore_evas_size_max_set(win->ee, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_delete_request(Ecore_Evas *ee)
|
||||
{
|
||||
Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
|
||||
evas_object_smart_callback_call(win->win_obj, "delete-request", NULL);
|
||||
if (win->autodel) evas_object_del(win->win_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_resize_job(void *data)
|
||||
{
|
||||
Elm_Win *win = data;
|
||||
Evas_List *l;
|
||||
int w, h;
|
||||
int expand_x, expand_y;
|
||||
|
||||
win->deferred_child_eval_job = NULL;
|
||||
_elm_obj_nest_push();
|
||||
w = h = 0;
|
||||
expand_x = expand_y = 0;
|
||||
for (l = win->children; l; l = l->next)
|
||||
win->deferred_resize_job = NULL;
|
||||
ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
|
||||
evas_object_intercept_resize_callback_del(win->win_obj, _elm_win_obj_intercept_resize);
|
||||
evas_object_resize(win->win_obj, w, h);
|
||||
evas_object_intercept_resize_callback_add(win->win_obj, _elm_win_obj_intercept_resize, win);
|
||||
for (l = win->subobjs; l; l = l->next)
|
||||
{
|
||||
if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
|
||||
{
|
||||
if (((Elm_Widget *)(l->data))->w > w) w = ((Elm_Widget *)(l->data))->w;
|
||||
if (((Elm_Widget *)(l->data))->h > h) h = ((Elm_Widget *)(l->data))->h;
|
||||
if (((Elm_Widget *)(l->data))->expand_x) expand_x = 1;
|
||||
if (((Elm_Widget *)(l->data))->expand_y) expand_y = 1;
|
||||
evas_object_move(l->data, 0, 0);
|
||||
evas_object_resize(l->data, w, h);
|
||||
}
|
||||
}
|
||||
ecore_evas_size_min_set(win->ee, w, h);
|
||||
if ((!expand_x) && (!expand_y)) ecore_evas_size_max_set(win->ee, w, h);
|
||||
else if (!expand_x) ecore_evas_size_max_set(win->ee, w, 32727);
|
||||
else if (!expand_y) ecore_evas_size_max_set(win->ee, 32767, h);
|
||||
else ecore_evas_size_max_set(win->ee, 0, 0);
|
||||
if (w < win->w) w = win->w;
|
||||
if (h < win->h) h = win->h;
|
||||
if ((w > win->w) || (h > win->h)) ecore_evas_resize(win->ee, w, h);
|
||||
if (win->showme)
|
||||
{
|
||||
win->showme = 0;
|
||||
ecore_evas_show(win->ee);
|
||||
}
|
||||
_elm_obj_nest_pop();
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_add(void *data, Elm_Win *win, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
_elm_win_xwin_update(Elm_Win *win)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
|
||||
win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
|
||||
win->xwin = 0;
|
||||
switch (_elm_config->engine)
|
||||
{
|
||||
case ELM_SOFTWARE_X11:
|
||||
if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
|
||||
break;
|
||||
case ELM_SOFTWARE_FB:
|
||||
break;
|
||||
case ELM_SOFTWARE_16_X11:
|
||||
if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
|
||||
break;
|
||||
case ELM_XRENDER_X11:
|
||||
if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
|
||||
break;
|
||||
case ELM_OPENGL_X11:
|
||||
if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (win->parent)
|
||||
{
|
||||
Elm_Win *win2;
|
||||
|
||||
win2 = evas_object_data_get(win->parent, "__Elm");
|
||||
if (win2)
|
||||
{
|
||||
if (win->xwin)
|
||||
ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_on_child_del(void *data, Elm_Win *win, Elm_Cb_Type type, Elm_Obj *obj)
|
||||
if (win->type == ELM_WIN_BASIC)
|
||||
{
|
||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
||||
if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
|
||||
win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_name_set(Elm_Win *win, const char *name)
|
||||
{
|
||||
if (win->name) evas_stringshare_del(win->name);
|
||||
win->name = evas_stringshare_add(name);
|
||||
if (win->ee) ecore_evas_name_class_set(win->ee, win->name, _elm_appname);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_title_set(Elm_Win *win, const char *title)
|
||||
{
|
||||
if (win->title) evas_stringshare_del(win->title);
|
||||
win->title = evas_stringshare_add(title);
|
||||
if (win->ee) ecore_evas_title_set(win->ee, win->title);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_show(Elm_Win *win)
|
||||
{
|
||||
if (win->deferred_child_eval_job)
|
||||
win->showme = 1;
|
||||
else
|
||||
ecore_evas_show(win->ee);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_hide(Elm_Win *win)
|
||||
{
|
||||
win->showme = 0;
|
||||
ecore_evas_hide(win->ee);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_type_set(Elm_Win *win, Elm_Win_Type type)
|
||||
{
|
||||
if (win->win_type == type) return;
|
||||
win->win_type = type;
|
||||
switch (win->win_type)
|
||||
switch (win->type)
|
||||
{
|
||||
case ELM_WIN_BASIC:
|
||||
if (win->xwin) ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
|
||||
// FIXME: if child object is a scroll region, then put its child back
|
||||
if (win->xwin)
|
||||
ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
|
||||
break;
|
||||
case ELM_WIN_DIALOG_BASIC:
|
||||
if (win->xwin) ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
|
||||
// FIXME: if child object is a scroll region, then put its child back
|
||||
if (win->xwin)
|
||||
ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_geom_set(Elm_Win *win, int x, int y, int w, int h)
|
||||
{
|
||||
if ((win->w != w) || (win->h != h) || (win->x != x) || (win->y != y))
|
||||
{
|
||||
win->x = x;
|
||||
win->y = y;
|
||||
win->w = w;
|
||||
win->h = h;
|
||||
ecore_evas_move_resize(win->ee, win->x, win->y, win->w, win->h);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_size_alloc(Elm_Win *win, int w, int h)
|
||||
{
|
||||
/* this should never be called */
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_size_req(Elm_Win *win, Elm_Widget *child, int w, int h)
|
||||
{
|
||||
if (child)
|
||||
{
|
||||
if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
|
||||
win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((w == win->w) && (h == win->h)) return;
|
||||
ecore_evas_resize(win->ee, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_above(Elm_Win *win, Elm_Widget *above)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_below(Elm_Win *win, Elm_Widget *below)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_del(Elm_Win *win)
|
||||
{
|
||||
if (_elm_obj_del_defer(ELM_OBJ(win))) return;
|
||||
if (win->ee)
|
||||
{
|
||||
ecore_evas_free(win->ee);
|
||||
evas_stringshare_del(win->title);
|
||||
evas_stringshare_del(win->name);
|
||||
}
|
||||
if (win->deferred_resize_job)
|
||||
ecore_job_del(win->deferred_resize_job);
|
||||
if (win->deferred_child_eval_job)
|
||||
ecore_job_del(win->deferred_child_eval_job);
|
||||
((Elm_Obj_Class *)(((Elm_Win_Class *)(win->clas))->parent))->del(ELM_OBJ(win));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_elm_win_delete_request(Ecore_Evas *ee)
|
||||
{
|
||||
Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
|
||||
if (!win) return;
|
||||
_elm_obj_nest_push();
|
||||
_elm_cb_call(ELM_OBJ(win), ELM_CB_DEL_REQ, NULL);
|
||||
if (win->autodel) win->del(ELM_OBJ(win));
|
||||
_elm_obj_nest_pop();
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_resize_job(Elm_Win *win)
|
||||
_elm_win_eval_subobjs(Evas_Object *obj)
|
||||
{
|
||||
Evas_List *l;
|
||||
int w, h;
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
int xx = 1, xy = 1;
|
||||
double wx, wy;
|
||||
|
||||
win->deferred_resize_job = NULL;
|
||||
ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
|
||||
if ((win->w == w) && (win->h == h)) return;
|
||||
win->w = w;
|
||||
win->h = h;
|
||||
/* resize all immediate children if they are widgets or sub-classes */
|
||||
_elm_obj_nest_push();
|
||||
for (l = win->children; l; l = l->next)
|
||||
for (l = win->subobjs; l; l = l->next)
|
||||
{
|
||||
if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
|
||||
((Elm_Widget *)(l->data))->geom_set(l->data, 0, 0, win->w, win->h);
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
if (wx == 0.0) xx = 0;
|
||||
if (wy == 0.0) xy = 0;
|
||||
|
||||
evas_object_size_hint_min_get(l->data, &w, &h);
|
||||
if (w < 1) w = -1;
|
||||
if (h < 1) h = -1;
|
||||
if (w > minw) minw = w;
|
||||
if (h > minh) minh = h;
|
||||
|
||||
evas_object_size_hint_max_get(l->data, &w, &h);
|
||||
if (w < 1) w = -1;
|
||||
if (h < 1) h = -1;
|
||||
if (maxw == -1) maxw = w;
|
||||
else if (w < maxw) maxw = w;
|
||||
if (maxh == -1) maxh = h;
|
||||
else if (h < maxh) maxh = h;
|
||||
}
|
||||
_elm_cb_call(ELM_OBJ(win), ELM_CB_RESIZE, NULL);
|
||||
_elm_obj_nest_pop();
|
||||
if ((maxw >= 0) && (maxw < minw)) maxw = minw;
|
||||
if ((maxh >= 0) && (maxh < minh)) maxh = minh;
|
||||
if (!xx) maxw = minw;
|
||||
else maxw = 32767;
|
||||
if (!xy) maxh = minh;
|
||||
else maxh = 32767;
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
if (w < minw) w = minw;
|
||||
if (h < minh) h = minh;
|
||||
if ((maxw >= 0) && (w > maxw)) w = maxw;
|
||||
if ((maxh >= 0) && (h > maxh)) h = maxh;
|
||||
evas_object_resize(obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_win_resize(Ecore_Evas *ee)
|
||||
_elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
|
||||
if (!win) return;
|
||||
if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
|
||||
win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
|
||||
elm_win_resize_object_del(data, obj);
|
||||
}
|
||||
|
||||
EAPI Elm_Win *
|
||||
elm_win_new(void)
|
||||
static void
|
||||
_elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
_elm_win_eval_subobjs(data);
|
||||
}
|
||||
|
||||
void
|
||||
_elm_win_shutdown(void)
|
||||
{
|
||||
while (_elm_win_list) evas_object_del(_elm_win_list->data);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
|
||||
{
|
||||
Elm_Win *win;
|
||||
|
||||
win = ELM_NEW(Elm_Win);
|
||||
|
||||
_elm_obj_init(ELM_OBJ(win));
|
||||
win->clas = &_elm_win_class;
|
||||
win->type = ELM_OBJ_WIN;
|
||||
|
||||
win->del = _elm_win_del;
|
||||
|
||||
win->geom_set = _elm_win_geom_set;
|
||||
win->show = _elm_win_show;
|
||||
win->hide = _elm_win_hide;
|
||||
win->size_alloc = _elm_win_size_alloc;
|
||||
win->size_req = _elm_win_size_req;
|
||||
win->above = _elm_win_above;
|
||||
win->below = _elm_win_below;
|
||||
|
||||
win->name_set = _elm_win_name_set;
|
||||
win->title_set = _elm_win_title_set;
|
||||
|
||||
switch (_elm_config->engine)
|
||||
{
|
||||
case ELM_SOFTWARE_X11:
|
||||
|
@ -277,16 +351,36 @@ elm_win_new(void)
|
|||
if (!win->ee)
|
||||
{
|
||||
printf("ELEMENTARY: Error. Cannot create window.\n");
|
||||
win->del(ELM_OBJ(win));
|
||||
free(win);
|
||||
return NULL;
|
||||
}
|
||||
win->type = ELM_WIN_BASIC;
|
||||
win->name = evas_stringshare_add("default");
|
||||
win->title = evas_stringshare_add("Elementary Window");
|
||||
|
||||
win->type = type;
|
||||
win->parent = parent;
|
||||
|
||||
win->evas = ecore_evas_get(win->ee);
|
||||
ecore_evas_title_set(win->ee, win->title);
|
||||
ecore_evas_name_class_set(win->ee, win->name, _elm_appname);
|
||||
win->win_obj = elm_widget_add(win->evas);
|
||||
evas_object_color_set(win->win_obj, 0, 0, 0, 0);
|
||||
evas_object_move(win->win_obj, 0, 0);
|
||||
evas_object_resize(win->win_obj, 1, 1);
|
||||
evas_object_layer_set(win->win_obj, 50);
|
||||
evas_object_pass_events_set(win->win_obj, 1);
|
||||
evas_object_data_set(win->win_obj, "__Elm", win);
|
||||
|
||||
evas_object_intercept_show_callback_add(win->win_obj, _elm_win_obj_intercept_show, win);
|
||||
evas_object_intercept_hide_callback_add(win->win_obj, _elm_win_obj_intercept_hide, win);
|
||||
evas_object_intercept_move_callback_add(win->win_obj, _elm_win_obj_intercept_move, win);
|
||||
evas_object_intercept_resize_callback_add(win->win_obj, _elm_win_obj_intercept_resize, win);
|
||||
evas_object_intercept_raise_callback_add(win->win_obj, _elm_win_obj_intercept_raise, win);
|
||||
evas_object_intercept_lower_callback_add(win->win_obj, _elm_win_obj_intercept_lower, win);
|
||||
evas_object_intercept_stack_above_callback_add(win->win_obj, _elm_win_obj_intercept_stack_above, win);
|
||||
evas_object_intercept_stack_below_callback_add(win->win_obj, _elm_win_obj_intercept_stack_below, win);
|
||||
evas_object_intercept_layer_set_callback_add(win->win_obj, _elm_win_obj_intercept_layer_set, win);
|
||||
evas_object_intercept_color_set_callback_add(win->win_obj, _elm_win_obj_intercept_color_set, win);
|
||||
evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_del, win);
|
||||
evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _elm_win_obj_callback_changed_size_hints, win);
|
||||
|
||||
ecore_evas_name_class_set(win->ee, name, _elm_appname);
|
||||
ecore_evas_data_set(win->ee, "__Elm", win);
|
||||
ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
|
||||
ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
|
||||
|
@ -300,8 +394,106 @@ elm_win_new(void)
|
|||
edje_frametime_set(1.0 / 30.0);
|
||||
edje_scale_set(_elm_config->scale);
|
||||
|
||||
win->cb_add(win, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
||||
win->cb_add(win, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
||||
_elm_win_xwin_update(win);
|
||||
|
||||
return win;
|
||||
_elm_win_list = evas_list_append(_elm_win_list, win->win_obj);
|
||||
|
||||
return win->win_obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
win->subobjs = evas_list_append(win->subobjs, subobj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL, _elm_win_subobj_callback_del, obj);
|
||||
evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _elm_win_subobj_callback_changed_size_hints, obj);
|
||||
_elm_win_eval_subobjs(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
evas_object_event_callback_del(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _elm_win_subobj_callback_changed_size_hints);
|
||||
evas_object_event_callback_del(subobj, EVAS_CALLBACK_DEL, _elm_win_subobj_callback_del);
|
||||
win->subobjs = evas_list_remove(win->subobjs, subobj);
|
||||
elm_widget_sub_object_del(obj, subobj);
|
||||
_elm_win_eval_subobjs(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_title_set(Evas_Object *obj, const char *title)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
ecore_evas_title_set(win->ee, title);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_autodel_set(Evas_Object *obj, Evas_Bool autodel)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
win->autodel = autodel;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_activate(Evas_Object *obj)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
ecore_evas_activate(win->ee);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_borderless_set(Evas_Object *obj, Evas_Bool borderless)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
ecore_evas_borderless_set(win->ee, borderless);
|
||||
_elm_win_xwin_update(win);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_shaped_set(Evas_Object *obj, Evas_Bool shaped)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
ecore_evas_shaped_set(win->ee, shaped);
|
||||
_elm_win_xwin_update(win);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_alpha_set(Evas_Object *obj, Evas_Bool alpha)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
if (win->xwin)
|
||||
{
|
||||
if (alpha)
|
||||
{
|
||||
if (!ecore_x_screen_is_composited(0))
|
||||
elm_win_shaped_set(obj, alpha);
|
||||
else
|
||||
ecore_evas_alpha_set(win->ee, alpha);
|
||||
}
|
||||
else
|
||||
ecore_evas_alpha_set(win->ee, alpha);
|
||||
_elm_win_xwin_update(win);
|
||||
}
|
||||
else
|
||||
ecore_evas_alpha_set(win->ee, alpha);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_override_set(Evas_Object *obj, Evas_Bool override)
|
||||
{
|
||||
Elm_Win *win = evas_object_data_get(obj, "__Elm");
|
||||
if (!win) return;
|
||||
ecore_evas_override_set(win->ee, override);
|
||||
_elm_win_xwin_update(win);
|
||||
}
|
||||
|
|
|
@ -9,39 +9,17 @@ struct _Smart_Data
|
|||
Evas_Coord x, y, w, h;
|
||||
Evas_Object *obj;
|
||||
Evas_Object *clip;
|
||||
int frozen;
|
||||
unsigned char changed : 1;
|
||||
unsigned char horizontal : 1;
|
||||
unsigned char homogenous : 1;
|
||||
Evas_List *items;
|
||||
struct {
|
||||
Evas_Coord w, h;
|
||||
} min, max;
|
||||
struct {
|
||||
double x, y;
|
||||
} align;
|
||||
};
|
||||
|
||||
struct _Box_Item
|
||||
{
|
||||
Smart_Data *sd;
|
||||
unsigned char fill_w : 1;
|
||||
unsigned char fill_h : 1;
|
||||
unsigned char expand_w : 1;
|
||||
unsigned char expand_h : 1;
|
||||
struct {
|
||||
Evas_Coord w, h;
|
||||
} min, max;
|
||||
struct {
|
||||
double x, y;
|
||||
} align;
|
||||
Evas_Object *obj;
|
||||
};
|
||||
|
||||
/* local subsystem functions */
|
||||
static Box_Item *_smart_adopt(Smart_Data *sd, Evas_Object *obj);
|
||||
static void _smart_adopt(Smart_Data *sd, Evas_Object *obj);
|
||||
static void _smart_disown(Evas_Object *obj);
|
||||
static void _smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_reconfigure(Smart_Data *sd);
|
||||
static void _smart_extents_calculate(Smart_Data *sd);
|
||||
|
||||
|
@ -67,29 +45,6 @@ _els_smart_box_add(Evas *evas)
|
|||
return evas_object_smart_add(evas, _e_smart);
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_freeze(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
sd->frozen++;
|
||||
return sd->frozen;
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_thaw(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
sd->frozen--;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
return sd->frozen;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_orientation_set(Evas_Object *obj, int horizontal)
|
||||
{
|
||||
|
@ -99,8 +54,7 @@ _els_smart_box_orientation_set(Evas_Object *obj, int horizontal)
|
|||
if (!sd) return;
|
||||
if (sd->horizontal == horizontal) return;
|
||||
sd->horizontal = horizontal;
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -122,8 +76,7 @@ _els_smart_box_homogenous_set(Evas_Object *obj, int homogenous)
|
|||
if (!sd) return;
|
||||
if (sd->homogenous == homogenous) return;
|
||||
sd->homogenous = homogenous;
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -136,8 +89,7 @@ _els_smart_box_pack_start(Evas_Object *obj, Evas_Object *child)
|
|||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = evas_list_prepend(sd->items, child);
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -151,8 +103,7 @@ _els_smart_box_pack_end(Evas_Object *obj, Evas_Object *child)
|
|||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = evas_list_append(sd->items, child);
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
return evas_list_count(sd->items) - 1;
|
||||
}
|
||||
|
||||
|
@ -172,8 +123,7 @@ _els_smart_box_pack_before(Evas_Object *obj, Evas_Object *child, Evas_Object *be
|
|||
{
|
||||
if (l->data == child) break;
|
||||
}
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -193,125 +143,56 @@ _els_smart_box_pack_after(Evas_Object *obj, Evas_Object *child, Evas_Object *aft
|
|||
{
|
||||
if (l->data == child) break;
|
||||
}
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_els_smart_box_pack_options_set(Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h)
|
||||
{
|
||||
Box_Item *bi;
|
||||
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (!bi) return;
|
||||
bi->fill_w = fill_w;
|
||||
bi->fill_h = fill_h;
|
||||
bi->expand_w = expand_w;
|
||||
bi->expand_h = expand_h;
|
||||
bi->align.x = align_x;
|
||||
bi->align.y = align_y;
|
||||
bi->min.w = min_w;
|
||||
bi->min.h = min_h;
|
||||
bi->max.w = max_w;
|
||||
bi->max.h = max_h;
|
||||
bi->sd->changed = 1;
|
||||
if (bi->sd->frozen <= 0) _smart_reconfigure(bi->sd);
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_unpack(Evas_Object *obj)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!obj) return;
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (!bi) return;
|
||||
sd = bi->sd;
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
if (!sd) return;
|
||||
sd->items = evas_list_remove(sd->items, obj);
|
||||
_smart_disown(obj);
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->changed) _smart_extents_calculate(sd);
|
||||
if (minw) *minw = sd->min.w;
|
||||
if (minh) *minh = sd->min.h;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->changed) _smart_extents_calculate(sd);
|
||||
if (maxw) *maxw = sd->max.w;
|
||||
if (maxh) *maxh = sd->max.h;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static Box_Item *
|
||||
static void
|
||||
_smart_adopt(Smart_Data *sd, Evas_Object *obj)
|
||||
{
|
||||
Box_Item *bi;
|
||||
|
||||
bi = calloc(1, sizeof(Box_Item));
|
||||
if (!bi) return NULL;
|
||||
bi->sd = sd;
|
||||
bi->obj = obj;
|
||||
/* defaults */
|
||||
bi->fill_w = 0;
|
||||
bi->fill_h = 0;
|
||||
bi->expand_w = 0;
|
||||
bi->expand_h = 0;
|
||||
bi->align.x = 0.5;
|
||||
bi->align.y = 0.5;
|
||||
bi->min.w = 0;
|
||||
bi->min.h = 0;
|
||||
bi->max.w = 0;
|
||||
bi->max.h = 0;
|
||||
evas_object_clip_set(obj, sd->clip);
|
||||
evas_object_smart_member_add(obj, bi->sd->obj);
|
||||
evas_object_data_set(obj, "e_box_data", bi);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
|
||||
evas_object_smart_member_add(obj, sd->obj);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook, NULL);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook, NULL);
|
||||
if ((!evas_object_visible_get(sd->clip)) &&
|
||||
(evas_object_visible_get(sd->obj)))
|
||||
evas_object_show(sd->clip);
|
||||
return bi;
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_disown(Evas_Object *obj)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Smart_Data *sd;
|
||||
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (!bi) return;
|
||||
if (!bi->sd->items)
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
if (!sd) return;
|
||||
if (sd->items)
|
||||
{
|
||||
if (evas_object_visible_get(bi->sd->clip))
|
||||
evas_object_hide(bi->sd->clip);
|
||||
if (evas_object_visible_get(sd->clip))
|
||||
evas_object_hide(sd->clip);
|
||||
}
|
||||
evas_object_event_callback_del(obj,
|
||||
EVAS_CALLBACK_FREE,
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook);
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook);
|
||||
evas_object_smart_member_del(obj);
|
||||
evas_object_clip_unset(obj);
|
||||
evas_object_data_del(obj, "e_box_data");
|
||||
free(bi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -320,65 +201,68 @@ _smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
_els_smart_box_unpack(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
{
|
||||
Evas_Coord x, y, w, h, xx, yy;
|
||||
Evas_List *l;
|
||||
int minw, minh, wdif, hdif;
|
||||
int count, expand;
|
||||
Evas_Coord minw, minh, wdif, hdif, mnw, mnh, mxw, mxh;
|
||||
int count, expand, fw, fh, xw, xh;
|
||||
double ax, ay, wx, wy;
|
||||
|
||||
if (!sd->changed) return;
|
||||
_smart_extents_calculate(sd);
|
||||
|
||||
x = sd->x;
|
||||
y = sd->y;
|
||||
w = sd->w;
|
||||
h = sd->h;
|
||||
|
||||
_smart_extents_calculate(sd);
|
||||
minw = sd->min.w;
|
||||
minh = sd->min.h;
|
||||
evas_object_size_hint_min_get(sd->obj, &minw, &minh);
|
||||
evas_object_size_hint_align_get(sd->obj, &ax, &ay);
|
||||
count = evas_list_count(sd->items);
|
||||
expand = 0;
|
||||
if (w < minw)
|
||||
{
|
||||
x = x + ((w - minw) * (1.0 - sd->align.x));
|
||||
x = x + ((w - minw) * (1.0 - ax));
|
||||
w = minw;
|
||||
}
|
||||
if (h < minh)
|
||||
{
|
||||
y = y + ((h - minh) * (1.0 - sd->align.y));
|
||||
y = y + ((h - minh) * (1.0 - ay));
|
||||
h = minh;
|
||||
}
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Evas_Object *obj;
|
||||
|
||||
obj = l->data;
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (bi)
|
||||
{
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
if (sd->horizontal)
|
||||
{
|
||||
if (bi->expand_w) expand++;
|
||||
if (wx > 0.0) expand++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bi->expand_h) expand++;
|
||||
}
|
||||
if (wy > 0.0) expand++;
|
||||
}
|
||||
}
|
||||
if (expand == 0)
|
||||
{
|
||||
evas_object_size_hint_align_get(sd->obj, &ax, &ay);
|
||||
if (sd->horizontal)
|
||||
{
|
||||
x += (double)(w - minw) * sd->align.x;
|
||||
x += (double)(w - minw) * ax;
|
||||
w = minw;
|
||||
}
|
||||
else
|
||||
{
|
||||
y += (double)(h - minh) * sd->align.y;
|
||||
y += (double)(h - minh) * ay;
|
||||
h = minh;
|
||||
}
|
||||
}
|
||||
|
@ -388,13 +272,19 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
yy = y;
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Evas_Object *obj;
|
||||
|
||||
obj = l->data;
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (bi)
|
||||
{
|
||||
evas_object_size_hint_align_get(l->data, &ax, &ay);
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
|
||||
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
|
||||
fw = fh = 0;
|
||||
xw = xh = 0;
|
||||
if (ax == -1.0) {fw = 1; ax = 0.5;}
|
||||
if (ay == -1.0) {fh = 1; ay = 0.5;}
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
if (sd->horizontal)
|
||||
{
|
||||
if (sd->homogenous)
|
||||
|
@ -403,17 +293,17 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
|
||||
ww = (w / (Evas_Coord)count);
|
||||
hh = h;
|
||||
ow = bi->min.w;
|
||||
if (bi->fill_w) ow = ww;
|
||||
if ((bi->max.w >= 0) && (bi->max.w < ow))
|
||||
ow = bi->max.w;
|
||||
oh = bi->min.h;
|
||||
if (bi->fill_h) oh = hh;
|
||||
if ((bi->max.h >= 0) && (bi->max.h < oh))
|
||||
oh = bi->max.h;
|
||||
ow = mnw;
|
||||
if (fw) ow = ww;
|
||||
if ((mxw >= 0) && (mxw < ow))
|
||||
ow = mxw;
|
||||
oh = mnh;
|
||||
if (fh) oh = hh;
|
||||
if ((mxh >= 0) && (mxh < oh))
|
||||
oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
xx += ww;
|
||||
}
|
||||
|
@ -421,8 +311,8 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
{
|
||||
Evas_Coord ww, hh, ow, oh;
|
||||
|
||||
ww = bi->min.w;
|
||||
if ((expand > 0) && (bi->expand_w))
|
||||
ww = mnw;
|
||||
if ((expand > 0) && (xw))
|
||||
{
|
||||
if (expand == 1) ow = wdif;
|
||||
else ow = (w - minw) / expand;
|
||||
|
@ -430,15 +320,15 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
ww += ow;
|
||||
}
|
||||
hh = h;
|
||||
ow = bi->min.w;
|
||||
if (bi->fill_w) ow = ww;
|
||||
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
|
||||
oh = bi->min.h;
|
||||
if (bi->fill_h) oh = hh;
|
||||
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
|
||||
ow = mnw;
|
||||
if (fw) ow = ww;
|
||||
if ((mxw >= 0) && (mxw < ow)) ow = mxw;
|
||||
oh = mnh;
|
||||
if (fh) oh = hh;
|
||||
if ((mxh >= 0) && (mxh < oh)) oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
xx += ww;
|
||||
}
|
||||
|
@ -451,15 +341,15 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
|
||||
ww = w;
|
||||
hh = (h / (Evas_Coord)count);
|
||||
ow = bi->min.w;
|
||||
if (bi->fill_w) ow = ww;
|
||||
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
|
||||
oh = bi->min.h;
|
||||
if (bi->fill_h) oh = hh;
|
||||
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
|
||||
ow = mnw;
|
||||
if (fw) ow = ww;
|
||||
if ((mxw >= 0) && (mxw < ow)) ow = mxw;
|
||||
oh = mnh;
|
||||
if (fh) oh = hh;
|
||||
if ((mxh >= 0) && (mxh < oh)) oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
yy += hh;
|
||||
}
|
||||
|
@ -468,58 +358,48 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
Evas_Coord ww, hh, ow, oh;
|
||||
|
||||
ww = w;
|
||||
hh = bi->min.h;
|
||||
if ((expand > 0) && (bi->expand_h))
|
||||
hh = mnh;
|
||||
if ((expand > 0) && (xh))
|
||||
{
|
||||
if (expand == 1) oh = hdif;
|
||||
else oh = (h - minh) / expand;
|
||||
hdif -= oh;
|
||||
hh += oh;
|
||||
}
|
||||
ow = bi->min.w;
|
||||
if (bi->fill_w) ow = ww;
|
||||
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
|
||||
oh = bi->min.h;
|
||||
if (bi->fill_h) oh = hh;
|
||||
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
|
||||
ow = mnw;
|
||||
if (fw) ow = ww;
|
||||
if ((mxw >= 0) && (mxw < ow)) ow = mxw;
|
||||
oh = mnh;
|
||||
if (fh) oh = hh;
|
||||
if ((mxh >= 0) && (mxh < oh)) oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
yy += hh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sd->changed = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_extents_calculate(Smart_Data *sd)
|
||||
{
|
||||
Evas_List *l;
|
||||
int minw, minh;
|
||||
Evas_Coord minw, minh, maxw, maxh, mnw, mnh;
|
||||
|
||||
/* FIXME: need to calc max */
|
||||
sd->max.w = -1; /* max < 0 == unlimited */
|
||||
sd->max.h = -1;
|
||||
|
||||
minw = 0;
|
||||
minh = 0;
|
||||
maxw = -1;
|
||||
maxh = -1;
|
||||
if (sd->homogenous)
|
||||
{
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Evas_Object *obj;
|
||||
|
||||
obj = l->data;
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (bi)
|
||||
{
|
||||
if (minh < bi->min.h) minh = bi->min.h;
|
||||
if (minw < bi->min.w) minw = bi->min.w;
|
||||
}
|
||||
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
|
||||
if (minh < mnh) minh = mnh;
|
||||
if (minw < mnw) minw = mnw;
|
||||
}
|
||||
if (sd->horizontal)
|
||||
minw *= evas_list_count(sd->items);
|
||||
|
@ -530,28 +410,20 @@ _smart_extents_calculate(Smart_Data *sd)
|
|||
{
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Box_Item *bi;
|
||||
Evas_Object *obj;
|
||||
|
||||
obj = l->data;
|
||||
bi = evas_object_data_get(obj, "e_box_data");
|
||||
if (bi)
|
||||
{
|
||||
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
|
||||
if (sd->horizontal)
|
||||
{
|
||||
if (minh < bi->min.h) minh = bi->min.h;
|
||||
minw += bi->min.w;
|
||||
if (minh < mnh) minh = mnh;
|
||||
minw += mnw;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (minw < bi->min.w) minw = bi->min.w;
|
||||
minh += bi->min.h;
|
||||
if (minw < mnw) minw = mnw;
|
||||
minh += mnh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sd->min.w = minw;
|
||||
sd->min.h = minh;
|
||||
evas_object_size_hint_min_set(sd->obj, minw, minh);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -587,12 +459,6 @@ _smart_add(Evas_Object *obj)
|
|||
sd = calloc(1, sizeof(Smart_Data));
|
||||
if (!sd) return;
|
||||
sd->obj = obj;
|
||||
sd->x = 0;
|
||||
sd->y = 0;
|
||||
sd->w = 0;
|
||||
sd->h = 0;
|
||||
sd->align.x = 0.5;
|
||||
sd->align.y = 0.5;
|
||||
sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
|
||||
evas_object_smart_member_add(sd->clip, obj);
|
||||
evas_object_move(sd->clip, -100004, -100004);
|
||||
|
@ -608,7 +474,6 @@ _smart_del(Evas_Object *obj)
|
|||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
_els_smart_box_freeze(obj);
|
||||
while (sd->items)
|
||||
{
|
||||
Evas_Object *child;
|
||||
|
@ -616,7 +481,6 @@ _smart_del(Evas_Object *obj)
|
|||
child = sd->items->data;
|
||||
_els_smart_box_unpack(child);
|
||||
}
|
||||
_els_smart_box_thaw(obj);
|
||||
evas_object_del(sd->clip);
|
||||
free(sd);
|
||||
}
|
||||
|
@ -625,14 +489,11 @@ static void
|
|||
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((x == sd->x) && (y == sd->y)) return;
|
||||
{
|
||||
Evas_List *l;
|
||||
Evas_Coord dx, dy;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
dx = x - sd->x;
|
||||
dy = y - sd->y;
|
||||
for (l = sd->items; l; l = l->next)
|
||||
|
@ -642,7 +503,6 @@ _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|||
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
|
||||
evas_object_move(l->data, ox + dx, oy + dy);
|
||||
}
|
||||
}
|
||||
sd->x = x;
|
||||
sd->y = y;
|
||||
}
|
||||
|
@ -654,10 +514,8 @@ _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((w == sd->w) && (h == sd->h)) return;
|
||||
sd->w = w;
|
||||
sd->h = h;
|
||||
sd->changed = 1;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
Evas_Object *_els_smart_box_add (Evas *evas);
|
||||
int _els_smart_box_freeze (Evas_Object *obj);
|
||||
int _els_smart_box_thaw (Evas_Object *obj);
|
||||
void _els_smart_box_orientation_set (Evas_Object *obj, int horizontal);
|
||||
int _els_smart_box_orientation_get (Evas_Object *obj);
|
||||
void _els_smart_box_homogenous_set (Evas_Object *obj, int homogenous);
|
||||
|
@ -8,7 +6,6 @@ int _els_smart_box_pack_start (Evas_Object *obj, Evas_Object *ch
|
|||
int _els_smart_box_pack_end (Evas_Object *obj, Evas_Object *child);
|
||||
int _els_smart_box_pack_before (Evas_Object *obj, Evas_Object *child, Evas_Object *before);
|
||||
int _els_smart_box_pack_after (Evas_Object *obj, Evas_Object *child, Evas_Object *after);
|
||||
void _els_smart_box_pack_options_set (Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h);
|
||||
void _els_smart_box_unpack (Evas_Object *obj);
|
||||
void _els_smart_box_min_size_get (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
|
||||
void _els_smart_box_max_size_get (Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh);
|
||||
|
|
|
@ -9,16 +9,8 @@ struct _Smart_Data
|
|||
Evas_Coord x, y, w, h;
|
||||
Evas_Object *obj;
|
||||
Evas_Object *clip;
|
||||
int frozen;
|
||||
unsigned char changed : 1;
|
||||
unsigned char homogenous : 1;
|
||||
Evas_List *items;
|
||||
struct {
|
||||
Evas_Coord w, h;
|
||||
} min, max;
|
||||
struct {
|
||||
double x, y;
|
||||
} align;
|
||||
struct {
|
||||
int cols, rows;
|
||||
} size;
|
||||
|
@ -28,16 +20,6 @@ struct _Table_Item
|
|||
{
|
||||
Smart_Data *sd;
|
||||
int col, row, colspan, rowspan;
|
||||
unsigned char fill_w : 1;
|
||||
unsigned char fill_h : 1;
|
||||
unsigned char expand_w : 1;
|
||||
unsigned char expand_h : 1;
|
||||
struct {
|
||||
Evas_Coord w, h;
|
||||
} min, max;
|
||||
struct {
|
||||
double x, y;
|
||||
} align;
|
||||
Evas_Object *obj;
|
||||
};
|
||||
|
||||
|
@ -45,6 +27,7 @@ struct _Table_Item
|
|||
static Table_Item *_smart_adopt(Smart_Data *sd, Evas_Object *obj);
|
||||
static void _smart_disown(Evas_Object *obj);
|
||||
static void _smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_reconfigure(Smart_Data *sd);
|
||||
static void _smart_extents_calcuate(Smart_Data *sd);
|
||||
|
||||
|
@ -70,27 +53,6 @@ _els_smart_table_add(Evas *evas)
|
|||
return evas_object_smart_add(evas, _e_smart);
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_table_freeze(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
sd->frozen++;
|
||||
return sd->frozen;
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_table_thaw(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
sd->frozen--;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
return sd->frozen;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_table_homogenous_set(Evas_Object *obj, int homogenous)
|
||||
{
|
||||
|
@ -99,8 +61,7 @@ _els_smart_table_homogenous_set(Evas_Object *obj, int homogenous)
|
|||
sd = evas_object_smart_data_get(obj);
|
||||
if (sd->homogenous == homogenous) return;
|
||||
sd->homogenous = homogenous;
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -122,29 +83,7 @@ _els_smart_table_pack(Evas_Object *obj, Evas_Object *child, int col, int row, in
|
|||
if (sd->size.cols < (col + colspan)) sd->size.cols = col + colspan;
|
||||
if (sd->size.rows < (row + rowspan)) sd->size.rows = row + rowspan;
|
||||
}
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_table_pack_options_set(Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h)
|
||||
{
|
||||
Table_Item *ti;
|
||||
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
if (!ti) return;
|
||||
ti->fill_w = fill_w;
|
||||
ti->fill_h = fill_h;
|
||||
ti->expand_w = expand_w;
|
||||
ti->expand_h = expand_h;
|
||||
ti->align.x = align_x;
|
||||
ti->align.y = align_y;
|
||||
ti->min.w = min_w;
|
||||
ti->min.h = min_h;
|
||||
ti->max.w = max_w;
|
||||
ti->max.h = max_h;
|
||||
ti->sd->changed = 1;
|
||||
if (ti->sd->frozen <= 0) _smart_reconfigure(ti->sd);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -158,8 +97,7 @@ _els_smart_table_unpack(Evas_Object *obj)
|
|||
sd = ti->sd;
|
||||
sd->items = evas_list_remove(sd->items, obj);
|
||||
_smart_disown(obj);
|
||||
sd->changed = 1;
|
||||
if (sd->frozen <= 0) _smart_reconfigure(sd);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -168,33 +106,10 @@ _els_smart_table_col_row_size_get(Evas_Object *obj, int *cols, int *rows)
|
|||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (sd->changed) _smart_extents_calcuate(sd);
|
||||
if (cols) *cols = sd->size.cols;
|
||||
if (rows) *rows = sd->size.rows;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_table_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (sd->changed) _smart_extents_calcuate(sd);
|
||||
if (minw) *minw = sd->min.w;
|
||||
if (minh) *minh = sd->min.h;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_table_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (sd->changed) _smart_extents_calcuate(sd);
|
||||
if (maxw) *maxw = sd->max.w;
|
||||
if (maxh) *maxh = sd->max.h;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static Table_Item *
|
||||
_smart_adopt(Smart_Data *sd, Evas_Object *obj)
|
||||
|
@ -210,22 +125,14 @@ _smart_adopt(Smart_Data *sd, Evas_Object *obj)
|
|||
ti->row = 0;
|
||||
ti->colspan = 1;
|
||||
ti->rowspan = 1;
|
||||
ti->fill_w = 0;
|
||||
ti->fill_h = 0;
|
||||
ti->expand_w = 0;
|
||||
ti->expand_h = 0;
|
||||
ti->align.x = 0.5;
|
||||
ti->align.y = 0.5;
|
||||
ti->min.w = 0;
|
||||
ti->min.h = 0;
|
||||
ti->max.w = 0;
|
||||
ti->max.h = 0;
|
||||
evas_object_clip_set(obj, sd->clip);
|
||||
evas_object_stack_above(obj, sd->obj);
|
||||
evas_object_smart_member_add(obj, ti->sd->obj);
|
||||
evas_object_data_set(obj, "e_table_data", ti);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook, NULL);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook, NULL);
|
||||
evas_object_stack_below(obj, sd->obj);
|
||||
if ((!evas_object_visible_get(sd->clip)) &&
|
||||
(evas_object_visible_get(sd->obj)))
|
||||
|
@ -245,9 +152,10 @@ _smart_disown(Evas_Object *obj)
|
|||
if (evas_object_visible_get(ti->sd->clip))
|
||||
evas_object_hide(ti->sd->clip);
|
||||
}
|
||||
evas_object_event_callback_del(obj,
|
||||
EVAS_CALLBACK_FREE,
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook);
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook);
|
||||
evas_object_smart_member_del(obj);
|
||||
evas_object_data_del(obj, "e_table_data");
|
||||
free(ti);
|
||||
|
@ -259,45 +167,61 @@ _smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
_els_smart_table_unpack(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
{
|
||||
Evas_Coord x, y, w, h, xx, yy;
|
||||
Evas_List *l;
|
||||
int minw, minh, expandw, expandh;
|
||||
Evas_Coord minw, minh;
|
||||
int expandw, expandh;
|
||||
double ax, ay;
|
||||
|
||||
if (!sd->changed) return;
|
||||
_smart_extents_calcuate(sd);
|
||||
|
||||
x = sd->x;
|
||||
y = sd->y;
|
||||
w = sd->w;
|
||||
h = sd->h;
|
||||
|
||||
_smart_extents_calcuate(sd);
|
||||
|
||||
minw = sd->min.w;
|
||||
minh = sd->min.h;
|
||||
evas_object_size_hint_min_get(sd->obj, &minw, &minh);
|
||||
evas_object_size_hint_align_get(sd->obj, &ax, &ay);
|
||||
expandw = 0;
|
||||
expandh = 0;
|
||||
if (w < minw)
|
||||
{
|
||||
x = x + ((w - minw) * (1.0 - sd->align.x));
|
||||
x = x + ((w - minw) * (1.0 - ax));
|
||||
w = minw;
|
||||
}
|
||||
if (h < minh)
|
||||
{
|
||||
y = y + ((h - minh) * (1.0 - sd->align.y));
|
||||
y = y + ((h - minh) * (1.0 - ay));
|
||||
h = minh;
|
||||
}
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
int xw, xh;
|
||||
double wx, wy;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
if (ti->expand_w) expandw++;
|
||||
if (ti->expand_h) expandh++;
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
xw = 0;
|
||||
xh = 0;
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
if (xw) expandw++;
|
||||
if (xh) expandh++;
|
||||
}
|
||||
if (expandw == 0)
|
||||
{
|
||||
|
@ -318,6 +242,9 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
Evas_Coord ww, hh, ow, oh;
|
||||
Evas_Coord mxw, mxh;
|
||||
int xw, xh;
|
||||
double wx, wy;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
|
@ -326,15 +253,21 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
yy = y + ((ti->row) * (h / (Evas_Coord)sd->size.rows));
|
||||
ww = ((w / (Evas_Coord)sd->size.cols) * (ti->colspan));
|
||||
hh = ((h / (Evas_Coord)sd->size.rows) * (ti->rowspan));
|
||||
ow = ti->min.w;
|
||||
if (ti->expand_w) ow = ww;
|
||||
if ((ti->max.w >= 0) && (ti->max.w < ow)) ow = ti->max.w;
|
||||
oh = ti->min.h;
|
||||
if (ti->expand_h) oh = hh;
|
||||
if ((ti->max.h >= 0) && (ti->max.h < oh)) oh = ti->max.h;
|
||||
evas_object_size_hint_min_get(l->data, &ow, &oh);
|
||||
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
evas_object_size_hint_align_get(l->data, &ax, &ay);
|
||||
xw = 0;
|
||||
xh = 0;
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
if (xw) ow = ww;
|
||||
if ((mxw >= 0) && (mxw < ow)) ow = mxw;
|
||||
if (xh) oh = hh;
|
||||
if ((mxh >= 0) && (mxh < oh)) oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ti->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ti->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
}
|
||||
}
|
||||
|
@ -366,23 +299,42 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
{
|
||||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
int xw, xh;
|
||||
double wx, wy;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
xw = 0;
|
||||
xh = 0;
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
for (i = ti->col; i < (ti->col + ti->colspan); i++)
|
||||
colsx[i] |= ti->expand_w;
|
||||
colsx[i] |= xw;
|
||||
for (i = ti->row; i < (ti->row + ti->rowspan); i++)
|
||||
rowsx[i] |= ti->expand_h;
|
||||
rowsx[i] |= xh;
|
||||
}
|
||||
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
Evas_Coord mnw, mnh, mxw, mxh;
|
||||
int xw, xh;
|
||||
double wx, wy;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
|
||||
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
|
||||
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
evas_object_size_hint_align_get(l->data, &ax, &ay);
|
||||
xw = 0;
|
||||
xh = 0;
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
|
||||
/* handle horizontal */
|
||||
ex = 0;
|
||||
tot = 0;
|
||||
|
@ -392,7 +344,7 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
if (colsx[i]) ex++;
|
||||
tot += cols[i];
|
||||
}
|
||||
need = ti->min.w;
|
||||
need = mnw;
|
||||
if (tot < need)
|
||||
{
|
||||
dif = need - tot;
|
||||
|
@ -447,7 +399,7 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
if (rowsx[i]) ex++;
|
||||
tot += rows[i];
|
||||
}
|
||||
need = ti->min.h;
|
||||
need = mnh;
|
||||
if (tot < need)
|
||||
{
|
||||
dif = need - tot;
|
||||
|
@ -561,9 +513,13 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
Evas_Coord ww, hh, ow, oh, i;
|
||||
Evas_Coord mxw, mxh;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
evas_object_size_hint_min_get(l->data, &ow, &oh);
|
||||
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
|
||||
evas_object_size_hint_align_get(l->data, &ax, &ay);
|
||||
|
||||
xx = x;
|
||||
for (i = 0; i < ti->col; i++) xx += cols[i];
|
||||
|
@ -574,15 +530,13 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
hh = 0;
|
||||
for (i = ti->row; i < (ti->row + ti->rowspan); i++) hh += rows[i];
|
||||
|
||||
ow = ti->min.w;
|
||||
if (ti->fill_w) ow = ww;
|
||||
if ((ti->max.w >= 0) && (ti->max.w < ow)) ow = ti->max.w;
|
||||
oh = ti->min.h;
|
||||
if (ti->fill_h) oh = hh;
|
||||
if ((ti->max.h >= 0) && (ti->max.h < oh)) oh = ti->max.h;
|
||||
if (ax == -1.0) {ow = ww; ax = 0.0;}
|
||||
if ((mxw >= 0) && (mxw < ow)) ow = mxw;
|
||||
if (ay == -1.0) {oh = hh; ay = 0.0;}
|
||||
if ((mxh >= 0) && (mxh < oh)) oh = mxh;
|
||||
evas_object_move(obj,
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ti->align.x),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ti->align.y));
|
||||
xx + (Evas_Coord)(((double)(ww - ow)) * ax),
|
||||
yy + (Evas_Coord)(((double)(hh - oh)) * ay));
|
||||
evas_object_resize(obj, ow, oh);
|
||||
}
|
||||
free(rows);
|
||||
|
@ -591,22 +545,20 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
free(colsx);
|
||||
}
|
||||
}
|
||||
sd->changed = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_extents_calcuate(Smart_Data *sd)
|
||||
{
|
||||
Evas_List *l;
|
||||
int minw, minh;
|
||||
|
||||
sd->max.w = -1; /* max < 0 == unlimited */
|
||||
sd->max.h = -1;
|
||||
sd->size.cols = 0;
|
||||
sd->size.rows = 0;
|
||||
Evas_Coord minw, minh, maxw, maxh;
|
||||
|
||||
minw = 0;
|
||||
minh = 0;
|
||||
maxw = -1; /* max < 0 == unlimited */
|
||||
maxh = -1;
|
||||
sd->size.cols = 0;
|
||||
sd->size.rows = 0;
|
||||
if (sd->homogenous)
|
||||
{
|
||||
for (l = sd->items; l; l = l->next)
|
||||
|
@ -614,6 +566,7 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
int mw, mh;
|
||||
Evas_Coord w, h;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
|
@ -621,8 +574,9 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
sd->size.cols = ti->col + ti->colspan;
|
||||
if (sd->size.rows < (ti->row + ti->rowspan))
|
||||
sd->size.rows = ti->row + ti->rowspan;
|
||||
mw = (ti->min.w + (ti->colspan - 1)) / ti->colspan;
|
||||
mh = (ti->min.h + (ti->rowspan - 1)) / ti->rowspan;
|
||||
evas_object_size_hint_min_get(l->data, &w, &h);
|
||||
mw = (w + (ti->colspan - 1)) / ti->colspan;
|
||||
mh = (h + (ti->rowspan - 1)) / ti->rowspan;
|
||||
if (minw < mw) minw = mw;
|
||||
if (minh < mh) minh = mh;
|
||||
}
|
||||
|
@ -657,22 +611,31 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
{
|
||||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
int xw, xh;
|
||||
double wx, wy;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
evas_object_size_hint_weight_get(l->data, &wx, &wy);
|
||||
xw = 0;
|
||||
xh = 0;
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
for (i = ti->col; i < (ti->col + ti->colspan); i++)
|
||||
colsx[i] |= ti->expand_w;
|
||||
colsx[i] |= xw;
|
||||
for (i = ti->row; i < (ti->row + ti->rowspan); i++)
|
||||
rowsx[i] |= ti->expand_h;
|
||||
rowsx[i] |= xh;
|
||||
}
|
||||
|
||||
for (l = sd->items; l; l = l->next)
|
||||
{
|
||||
Table_Item *ti;
|
||||
Evas_Object *obj;
|
||||
Evas_Coord w, h;
|
||||
|
||||
obj = l->data;
|
||||
ti = evas_object_data_get(obj, "e_table_data");
|
||||
evas_object_size_hint_min_get(l->data, &w, &h);
|
||||
|
||||
/* handle horizontal */
|
||||
ex = 0;
|
||||
|
@ -683,7 +646,7 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
if (colsx[i]) ex++;
|
||||
tot += cols[i];
|
||||
}
|
||||
need = ti->min.w;
|
||||
need = w;
|
||||
if (tot < need)
|
||||
{
|
||||
dif = need - tot;
|
||||
|
@ -738,7 +701,7 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
if (rowsx[i]) ex++;
|
||||
tot += rows[i];
|
||||
}
|
||||
need = ti->min.h;
|
||||
need = h;
|
||||
if (tot < need)
|
||||
{
|
||||
dif = need - tot;
|
||||
|
@ -792,8 +755,7 @@ _smart_extents_calcuate(Smart_Data *sd)
|
|||
free(colsx);
|
||||
}
|
||||
}
|
||||
sd->min.w = minw;
|
||||
sd->min.h = minh;
|
||||
evas_object_size_hint_min_set(sd->obj, minw, minh);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -848,7 +810,6 @@ _smart_del(Evas_Object *obj)
|
|||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
_els_smart_table_freeze(obj);
|
||||
while (sd->items)
|
||||
{
|
||||
Evas_Object *child;
|
||||
|
@ -856,7 +817,6 @@ _smart_del(Evas_Object *obj)
|
|||
child = sd->items->data;
|
||||
_els_smart_table_unpack(child);
|
||||
}
|
||||
_els_smart_table_thaw(obj);
|
||||
evas_object_del(sd->clip);
|
||||
free(sd);
|
||||
}
|
||||
|
@ -865,15 +825,11 @@ static void
|
|||
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((x == sd->x) && (y == sd->y)) return;
|
||||
if ((x == sd->x) && (y == sd->y)) return;
|
||||
{
|
||||
Evas_List *l;
|
||||
Evas_Coord dx, dy;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
dx = x - sd->x;
|
||||
dy = y - sd->y;
|
||||
for (l = sd->items; l; l = l->next)
|
||||
|
@ -883,7 +839,6 @@ _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|||
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
|
||||
evas_object_move(l->data, ox + dx, oy + dy);
|
||||
}
|
||||
}
|
||||
sd->x = x;
|
||||
sd->y = y;
|
||||
}
|
||||
|
@ -895,10 +850,8 @@ _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((w == sd->w) && (h == sd->h)) return;
|
||||
sd->w = w;
|
||||
sd->h = h;
|
||||
sd->changed = 1;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
Evas_Object *_els_smart_table_add (Evas *evas);
|
||||
int _els_smart_table_freeze (Evas_Object *obj);
|
||||
int _els_smart_table_thaw (Evas_Object *obj);
|
||||
void _els_smart_table_homogenous_set (Evas_Object *obj, int homogenous);
|
||||
void _els_smart_table_pack (Evas_Object *obj, Evas_Object *child, int col, int row, int colspan, int rowspan);
|
||||
void _els_smart_table_pack_options_set (Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h);
|
||||
void _els_smart_table_unpack (Evas_Object *obj);
|
||||
void _els_smart_table_col_row_size_get (Evas_Object *obj, int *cols, int *rows);
|
||||
void _els_smart_table_min_size_get (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
|
||||
void _els_smart_table_max_size_get (Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh);
|
||||
|
|
Loading…
Reference in New Issue