[elm] Popup now a layout.

SVN revision: 75897
This commit is contained in:
Gustavo Lima Chaves 2012-08-30 16:46:34 +00:00
parent 8827185824
commit c440726506
9 changed files with 89270 additions and 86524 deletions

View File

@ -135,6 +135,7 @@ WGT_TREE = \
photocam \
player \
plug \
popup \
progressbar \
radio \
route \

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 KiB

After

Width:  |  Height:  |  Size: 372 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -89,6 +89,7 @@ elm_widget_photo.h \
elm_widget_photocam.h \
elm_widget_player.h \
elm_widget_plug.h \
elm_widget_popup.h \
elm_widget_progressbar.h \
elm_widget_radio.h \
elm_widget_route.h \

File diff suppressed because it is too large Load Diff

View File

@ -2,94 +2,95 @@
* @defgroup Popup Popup
* @ingroup Elementary
*
* This widget is an enhancement of @ref Notify.
* In addition to Content area, there are two optional sections namely Title
* area and Action area.
* @image html popup_inheritance_tree.png
* @image latex popup_inheritance_tree.eps
*
* Popup Widget displays its content with a particular orientation in the parent
* area. This orientation can be one among top, center, bottom, left, top-left,
* top-right, bottom-left and bottom-right.
* Content part of Popup can be an Evas Object set by application or it can be
* Text set by application or set of items containing an icon and/or text.
* The content/item-list can be removed using elm_object_content_set with second
* parameter passed as NULL.
* This widget is an enhancement of @ref Notify. In addition to
* content area, there are two optional sections, namely title area and
* action area.
*
* Following figures shows the textual layouts of popup in which Title Area and
* Action area area are optional ones.
* Action area can have up to 3 buttons handled using elm_object common APIs
* mentioned below. If user wants to have more than 3 buttons then these buttons
* can be put inside the items of a list as content.
* User needs to handle the clicked signal of these action buttons if required.
* No event is processed by the widget automatically when clicked on these
* action buttons.
* The popup widget displays its content with a particular orientation in
* the parent area. This orientation can be one among top, center,
* bottom, left, top-left, top-right, bottom-left and bottom-right.
* Content part of Popup can be an Evas Object set by application or
* it can be Text set by application or set of items containing an
* icon and/or text. The content/item-list can be removed using
* elm_object_content_set with second parameter passed as NULL.
*
* The following figures show the textual layouts of popup in which Title
* Area and Action area area are optional ones. Action area can have
* up to 3 buttons handled using elm_object common APIs mentioned
* below. If user wants to have more than 3 buttons then these buttons
* can be put inside the items of a list as content. User needs to
* handle the clicked signal of these action buttons if required. No
* event is processed by the widget automatically when clicked on
* these action buttons.
*
* <pre>
*
* |---------------------| |---------------------| |---------------------|
* | Title Area | | Title Area | | Title Area |
* |Icon| Text | |Icon| Text | |Icon| Text |
* |---------------------| |---------------------| |---------------------|
* | Item 1 | | | | |
* |---------------------| | | | |
* | Item 2 | | | | Description |
* |---------------------| | Content | | |
* | Item 3 | | | | |
* |---------------------| | | | |
* | . | |---------------------| |---------------------|
* | . | | Action Area | | Action Area |
* | . | | Btn1 |Btn2|. |Btn3 | | Btn1 |Btn2| |Btn3 |
* |---------------------| |---------------------| |---------------------|
* | Item N | Content Based Layout Description based Layout
* |---------------------|
* | Action Area |
* | Btn1 |Btn2|. |Btn3 |
* |---------------------|
* Item Based Layout
*|---------------------| |---------------------| |---------------------|
*| Title Area | | Title Area | | Title Area |
*|Icon| Text | |Icon| Text | |Icon| Text |
*|---------------------| |---------------------| |---------------------|
*| Item 1 | | | | |
*|---------------------| | | | |
*| Item 2 | | | | Description |
*|---------------------| | Content | | |
*| Item 3 | | | | |
*|---------------------| | | | |
*| . | |---------------------| |---------------------|
*| . | | Action Area | | Action Area |
*| . | | Btn1 |Btn2|. |Btn3 | | Btn1 |Btn2| |Btn3 |
*|---------------------| |---------------------| |---------------------|
*| Item N | Content Based Layout Description based Layout
*|---------------------|
*| Action Area |
*| Btn1 |Btn2|. |Btn3 |
*|---------------------|
* Item Based Layout
*
* </pre>
*
* Timeout can be set on expiry of which popup instance hides and sends a smart
* signal "timeout" to the user.
* The visible region of popup is surrounded by a translucent region called
* Blocked Event area.
* By clicking on Blocked Event area, the signal "block,clicked" is sent to
* the application. This block event area can be avoided by using
* API elm_popup_allow_events_set.
* When gets hidden, popup does not get destroyed automatically, application
* should destroy the popup instance after use.
* To control the maximum height of the internal scroller for item, we use the
* height of the action area which is passed by theme based on the number of
* Timeout can be set on expiry of which popup instance hides and
* sends a smart signal "timeout" to the user. The visible region of
* popup is surrounded by a translucent region called Blocked Event
* area. By clicking on Blocked Event area, the signal
* "block,clicked" is sent to the application. This block event area
* can be avoided by using API elm_popup_allow_events_set. When gets
* hidden, popup does not get destroyed automatically, application
* should destroy the popup instance after use. To control the
* maximum height of the internal scroller for item, we use the height
* of the action area which is passed by theme based on the number of
* buttons currently set to popup.
*
* Signals that you can add callbacks for are:
* @li "timeout" - whenever popup is closed as a result of timeout.
* @li "block,clicked" - whenever user taps on Blocked Event area.
* This widget inherits from the @ref Layout one, so that all the
* functions acting on it also work for popup objects.
*
* This widget emits the following signals, besides the ones sent from
* @ref Layout:
* @li @c "timeout" - whenever popup is closed as a result of timeout.
* @li @c "block,clicked" - whenever user taps on Blocked Event area.
*
* Styles available for Popup
* @li "default"
*
* Default contents parts of the popup widget that you can use for are:
* Default contents parts of the popup widget that you can use are:
* @li "default" - The content of the popup
* @li "title,icon" - Title area's icon
* @li "button1" - 1st button of the action area
* @li "button2" - 2nd button of the action area
* @li "button3" - 3rd button of the action area
*
* Default text parts of the popup widget that you can use for are:
* Default text parts of the popup widget that you can use are:
* @li "title,text" - This operates on Title area's label
* @li "default" - content-text set in the content area of the widget
*
* Default contents parts of the popup items that you can use for are:
* Default contents parts of the popup items that you can use are:
* @li "default" -Item's icon
*
* Default text parts of the popup items that you can use for are:
* Default text parts of the popup items that you can use are:
* @li "default" - Item's label
*
* Supported elm_object common APIs.
* @li @ref elm_object_part_content_set
* @li @ref elm_object_part_content_get
* @li @ref elm_object_part_content_unset
*
* Supported elm_object_item common APIs.
* @li @ref elm_object_item_disabled_set
* @li @ref elm_object_item_disabled_get

View File

@ -0,0 +1,213 @@
#ifndef ELM_WIDGET_POPUP_H
#define ELM_WIDGET_POPUP_H
#include "elm_widget_layout.h"
/**
* @addtogroup Widget
* @{
*
* @section elm-popup-class The Elementary Popup Class
*
* Elementary, besides having the @ref Popup widget, exposes its
* foundation -- the Elementary Popup Class -- in order to create other
* widgets which are a popup with some more logic on top.
*/
/**
* @def ELM_POPUP_CLASS
*
* Use this macro to cast whichever subclass of
* #Elm_Popup_Smart_Class into it, so to access its fields.
*
* @ingroup Widget
*/
#define ELM_POPUP_CLASS(x) ((Elm_Popup_Smart_Class *)x)
/**
* @def ELM_POPUP_DATA
*
* Use this macro to cast whichever subdata of
* #Elm_Popup_Smart_Data into it, so to access its fields.
*
* @ingroup Widget
*/
#define ELM_POPUP_DATA(x) ((Elm_Popup_Smart_Data *)x)
/**
* @def ELM_POPUP_SMART_CLASS_VERSION
*
* Current version for Elementary popup @b base smart class, a value
* which goes to _Elm_Popup_Smart_Class::version.
*
* @ingroup Widget
*/
#define ELM_POPUP_SMART_CLASS_VERSION 1
/**
* @def ELM_POPUP_SMART_CLASS_INIT
*
* Initializer for a whole #Elm_Popup_Smart_Class structure, with
* @c NULL values on its specific fields.
*
* @param smart_class_init initializer to use for the "base" field
* (#Evas_Smart_Class).
*
* @see EVAS_SMART_CLASS_INIT_NULL
* @see EVAS_SMART_CLASS_INIT_NAME_VERSION
* @see ELM_POPUP_SMART_CLASS_INIT_NULL
* @see ELM_POPUP_SMART_CLASS_INIT_NAME_VERSION
*
* @ingroup Widget
*/
#define ELM_POPUP_SMART_CLASS_INIT(smart_class_init) \
{smart_class_init, ELM_POPUP_SMART_CLASS_VERSION}
/**
* @def ELM_POPUP_SMART_CLASS_INIT_NULL
*
* Initializer to zero out a whole #Elm_Popup_Smart_Class structure.
*
* @see ELM_POPUP_SMART_CLASS_INIT_NAME_VERSION
* @see ELM_POPUP_SMART_CLASS_INIT
*
* @ingroup Widget
*/
#define ELM_POPUP_SMART_CLASS_INIT_NULL \
ELM_POPUP_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
/**
* @def ELM_POPUP_SMART_CLASS_INIT_NAME_VERSION
*
* Initializer to zero out a whole #Elm_Popup_Smart_Class structure and
* set its name and version.
*
* This is similar to #ELM_POPUP_SMART_CLASS_INIT_NULL, but it will
* also set the version field of #Elm_Popup_Smart_Class (base field)
* to the latest #ELM_POPUP_SMART_CLASS_VERSION and name it to the
* specific value.
*
* It will keep a reference to the name field as a <c>"const char *"</c>,
* i.e., the name must be available while the structure is
* used (hint: static or global variable!) and must not be modified.
*
* @see ELM_POPUP_SMART_CLASS_INIT_NULL
* @see ELM_POPUP_SMART_CLASS_INIT
*
* @ingroup Widget
*/
#define ELM_POPUP_SMART_CLASS_INIT_NAME_VERSION(name) \
ELM_POPUP_SMART_CLASS_INIT \
(ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
/**
* Elementary popup base smart class. This inherits directly from
* #Elm_Layout_Smart_Class and is meant to build widgets extending the
* behavior of a popup.
*
* All of the functions listed on @ref Popup namespace will work for
* objects deriving from #Elm_Popup_Smart_Class.
*/
typedef struct _Elm_Popup_Smart_Class
{
Elm_Layout_Smart_Class base;
int version; /**< Version of this smart class definition */
} Elm_Popup_Smart_Class;
#define ELM_POPUP_ACTION_BUTTON_MAX 3
typedef struct _Action_Area_Data Action_Area_Data;
/**
* Base layout smart data extended with popup instance data.
*/
typedef struct _Elm_Popup_Smart_Data Elm_Popup_Smart_Data;
struct _Elm_Popup_Smart_Data
{
Elm_Layout_Smart_Data base;
Evas_Object *notify;
Evas_Object *title_icon;
Evas_Object *title_access_obj;
Evas_Object *content_area;
Evas_Object *text_content_obj;
Evas_Object *action_area;
Evas_Object *box;
Evas_Object *tbl;
Evas_Object *spacer;
Evas_Object *scr;
Evas_Object *content;
Eina_List *items;
const char *title_text;
Action_Area_Data *buttons[ELM_POPUP_ACTION_BUTTON_MAX];
Elm_Wrap_Type content_text_wrap_type;
unsigned int button_count;
Evas_Coord max_sc_w;
Evas_Coord max_sc_h;
Eina_Bool visible : 1;
Eina_Bool no_shift : 1;
Eina_Bool scr_size_recalc : 1;
};
typedef struct _Elm_Popup_Item Elm_Popup_Item;
struct _Elm_Popup_Item
{
Elm_Widget_Item base;
const char *label;
Evas_Object *icon;
Evas_Smart_Cb func;
Eina_Bool disabled : 1;
};
struct _Action_Area_Data
{
Evas_Object *obj;
Evas_Object *btn;
Eina_Bool delete_me;
};
/**
* @}
*/
EAPI extern const char ELM_POPUP_SMART_NAME[];
EAPI const Elm_Popup_Smart_Class *elm_popup_smart_class_get(void);
#define ELM_POPUP_DATA_GET(o, sd) \
Elm_Popup_Smart_Data * sd = evas_object_smart_data_get(o)
#define ELM_POPUP_DATA_GET_OR_RETURN(o, ptr) \
ELM_POPUP_DATA_GET(o, ptr); \
if (!ptr) \
{ \
CRITICAL("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return; \
}
#define ELM_POPUP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
ELM_POPUP_DATA_GET(o, ptr); \
if (!ptr) \
{ \
CRITICAL("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return val; \
}
#define ELM_POPUP_CHECK(obj) \
if (!obj || !elm_widget_type_check \
((obj), ELM_POPUP_SMART_NAME, __func__)) \
return
#define ELM_POPUP_ITEM_CHECK(it) \
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
ELM_POPUP_CHECK(it->base.widget);
#define ELM_POPUP_ITEM_CHECK_OR_RETURN(it, ...) \
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
ELM_POPUP_CHECK(it->base.widget) __VA_ARGS__;
#endif