forked from enlightenment/efl
Example for button and moving docs around
SVN revision: 60738
This commit is contained in:
parent
9954d925a4
commit
89ae35c22a
|
@ -801,6 +801,81 @@
|
||||||
* @example theme_example_02.c
|
* @example theme_example_02.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @page button_example_01 Button - Complete example
|
||||||
|
*
|
||||||
|
* @dontinclude button_example_01.c
|
||||||
|
*
|
||||||
|
* A button is simple, you click on it and something happens. That said,
|
||||||
|
* we'll go through an example to show in detail the button API less
|
||||||
|
* commonly used.
|
||||||
|
*
|
||||||
|
* In the end, we'll be presented with something that looks like this:
|
||||||
|
* @image html screenshots/button_01.png
|
||||||
|
* @image latex screenshots/button_01.eps
|
||||||
|
*
|
||||||
|
* The full code of the example is @ref button_example_01.c "here" and we
|
||||||
|
* will follow here with a rundown of it.
|
||||||
|
*
|
||||||
|
* @skip Elementary.h
|
||||||
|
* @until Elementary.h
|
||||||
|
* @skip struct
|
||||||
|
* @until App_Data
|
||||||
|
*
|
||||||
|
* We have several buttons to set different times for the autorepeat timeouts
|
||||||
|
* of the buttons that use it and a few more that we keep track of in our
|
||||||
|
* data struct. The mid button doesn't do much, just moves around according
|
||||||
|
* to what other buttons the user presses. Then four more buttons to move the
|
||||||
|
* central one, and we're also keeping track of the icon set in the middle
|
||||||
|
* button, since when this one moves, we change the icon, and when movement
|
||||||
|
* is finished (by releasing one of the four arrow buttons), we set back the
|
||||||
|
* normal icon.
|
||||||
|
* @skip static void
|
||||||
|
* @until }
|
||||||
|
*
|
||||||
|
* Keeping any of those four buttons pressed will trigger their autorepeat
|
||||||
|
* callback, where we move the button doing some size hint magic. To
|
||||||
|
* understand how that works better, refer to the @ref Box documentation.
|
||||||
|
* Also, the first time the function is called, we change the icon in the
|
||||||
|
* middle button, using elm_button_icon_unset() first to keep the reference
|
||||||
|
* to the previous one, so we don't need to recreate it when we are done
|
||||||
|
* moving it.
|
||||||
|
* @skip static void
|
||||||
|
* @until }
|
||||||
|
* @until size_hint_align_set
|
||||||
|
* @until }
|
||||||
|
*
|
||||||
|
* One more callback for the option buttons, that just sets the timeouts for
|
||||||
|
* the different autorepeat options.
|
||||||
|
*
|
||||||
|
* @skip static void
|
||||||
|
* @until }
|
||||||
|
* @until }
|
||||||
|
* @until }
|
||||||
|
*
|
||||||
|
* And the main function, which does some setting up of the buttons in boxes
|
||||||
|
* to make things work. Here we'll go through some snippets only.
|
||||||
|
*
|
||||||
|
* For the option buttons, it's just the button with its label and callback.
|
||||||
|
* @skip elm_button_add
|
||||||
|
* @until smart_callback_add
|
||||||
|
*
|
||||||
|
* For the ones that move the central button, we have no labels. There are
|
||||||
|
* icons instead, and the autorepeat option is toggled.
|
||||||
|
* @skip Gap: 1.0
|
||||||
|
* @skip elm_button_add
|
||||||
|
* @until data.cursors.up
|
||||||
|
*
|
||||||
|
* And just to show the mid button, which doesn't have anything special.
|
||||||
|
* @skip data.cursors.left
|
||||||
|
* @skip elm_button_add
|
||||||
|
* @until data.mid
|
||||||
|
*
|
||||||
|
* And we are done.
|
||||||
|
*
|
||||||
|
* @example button_example_01.c
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @page bg_example_01_c bg_example_01.c
|
* @page bg_example_01_c bg_example_01.c
|
||||||
* @include bg_example_01.c
|
* @include bg_example_01.c
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -30,6 +30,7 @@ SRCS = \
|
||||||
actionslider_example_01.c \
|
actionslider_example_01.c \
|
||||||
anchorblock_example_01.c \
|
anchorblock_example_01.c \
|
||||||
animator_example_01.c \
|
animator_example_01.c \
|
||||||
|
button_example_01.c \
|
||||||
transit_example_01.c \
|
transit_example_01.c \
|
||||||
transit_example_02.c \
|
transit_example_02.c \
|
||||||
transit_example_03.c \
|
transit_example_03.c \
|
||||||
|
@ -62,6 +63,7 @@ pkglib_PROGRAMS += \
|
||||||
actionslider_example_01 \
|
actionslider_example_01 \
|
||||||
anchorblock_example_01 \
|
anchorblock_example_01 \
|
||||||
animator_example_01 \
|
animator_example_01 \
|
||||||
|
button_example_01 \
|
||||||
transit_example_01 \
|
transit_example_01 \
|
||||||
transit_example_02 \
|
transit_example_02 \
|
||||||
transit_example_03 \
|
transit_example_03 \
|
||||||
|
@ -80,6 +82,7 @@ pkglib_PROGRAMS += \
|
||||||
SCREENSHOTS = \
|
SCREENSHOTS = \
|
||||||
actionslider_example_01:actionslider_01.png:0.0 \
|
actionslider_example_01:actionslider_01.png:0.0 \
|
||||||
bg_example_02:bg_01.png:0.0 \
|
bg_example_02:bg_01.png:0.0 \
|
||||||
|
button_example_01:button_01.png:0.0 \
|
||||||
animator_example_01:animator_example_01.png:0.2 \
|
animator_example_01:animator_example_01.png:0.2 \
|
||||||
animator_example_01:animator_example_02.png:0.5 \
|
animator_example_01:animator_example_02.png:0.5 \
|
||||||
animator_example_01:animator_example_03.png:0.9 \
|
animator_example_01:animator_example_03.png:0.9 \
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
/*
|
||||||
|
* gcc -o button_example_01 button_example_01.c `pkg-config --cflags --libs elementary`
|
||||||
|
*/
|
||||||
|
#include <Elementary.h>
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "elementary_config.h"
|
||||||
|
#else
|
||||||
|
# define __UNUSED__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Evas_Object *mid;
|
||||||
|
Evas_Object *icon_still;
|
||||||
|
struct {
|
||||||
|
Evas_Object *up;
|
||||||
|
Evas_Object *down;
|
||||||
|
Evas_Object *left;
|
||||||
|
Evas_Object *right;
|
||||||
|
} cursors;
|
||||||
|
} App_Data;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_btn_cursors_release_cb(void *data, Evas_Object *btn __UNUSED__, void *ev __UNUSED__)
|
||||||
|
{
|
||||||
|
App_Data *app = data;
|
||||||
|
elm_button_icon_set(app->mid, app->icon_still);
|
||||||
|
app->icon_still = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_btn_cursors_move_cb(void *data, Evas_Object *btn, void *ev __UNUSED__)
|
||||||
|
{
|
||||||
|
App_Data *app = data;
|
||||||
|
double ax, ay;
|
||||||
|
|
||||||
|
if (!app->icon_still)
|
||||||
|
{
|
||||||
|
Evas_Object *icon;
|
||||||
|
app->icon_still = elm_button_icon_unset(app->mid);
|
||||||
|
icon = elm_icon_add(app->mid);
|
||||||
|
elm_icon_standard_set(icon, "chat");
|
||||||
|
elm_button_icon_set(app->mid, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
evas_object_size_hint_align_get(app->mid, &ax, &ay);
|
||||||
|
if (btn == app->cursors.up)
|
||||||
|
{
|
||||||
|
ay -= 0.05;
|
||||||
|
if (ay < 0.0)
|
||||||
|
ay = 0.0;
|
||||||
|
}
|
||||||
|
else if (btn == app->cursors.down)
|
||||||
|
{
|
||||||
|
ay += 0.05;
|
||||||
|
if (ay > 1.0)
|
||||||
|
ay = 1.0;
|
||||||
|
}
|
||||||
|
else if (btn == app->cursors.left)
|
||||||
|
{
|
||||||
|
ax -= 0.05;
|
||||||
|
if (ax < 0.0)
|
||||||
|
ax = 0.0;
|
||||||
|
}
|
||||||
|
else if (btn == app->cursors.right)
|
||||||
|
{
|
||||||
|
ax += 0.05;
|
||||||
|
if (ax > 1.0)
|
||||||
|
ax = 1.0;
|
||||||
|
}
|
||||||
|
evas_object_size_hint_align_set(app->mid, ax, ay);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_btn_options_cb(void *data, Evas_Object *btn, void *ev __UNUSED__)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
double t;
|
||||||
|
App_Data *app = data;
|
||||||
|
const char *lbl = elm_button_label_get(btn);
|
||||||
|
|
||||||
|
ptr = strchr(lbl, ':');
|
||||||
|
ptr += 2;
|
||||||
|
t = strtod(ptr, NULL);
|
||||||
|
|
||||||
|
if (!strncmp(lbl, "Initial", 7))
|
||||||
|
{
|
||||||
|
elm_button_autorepeat_initial_timeout_set(app->cursors.up, t);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(app->cursors.down, t);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(app->cursors.left, t);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(app->cursors.right, t);
|
||||||
|
}
|
||||||
|
else if (!strncmp(lbl, "Gap", 3))
|
||||||
|
{
|
||||||
|
elm_button_autorepeat_gap_timeout_set(app->cursors.up, t);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(app->cursors.down, t);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(app->cursors.left, t);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(app->cursors.right, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
|
||||||
|
{
|
||||||
|
Evas_Object *win, *bg, *box, *box2, *btn, *icon;
|
||||||
|
static App_Data data;
|
||||||
|
|
||||||
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||||
|
|
||||||
|
win = elm_win_add(NULL, "Button example", ELM_WIN_BASIC);
|
||||||
|
elm_win_title_set(win, "Button example");
|
||||||
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
evas_object_resize(win, 300, 320);
|
||||||
|
evas_object_show(win);
|
||||||
|
|
||||||
|
bg = elm_bg_add(win);
|
||||||
|
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_win_resize_object_add(win, bg);
|
||||||
|
evas_object_show(bg);
|
||||||
|
|
||||||
|
box = elm_box_add(win);
|
||||||
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_win_resize_object_add(win, box);
|
||||||
|
evas_object_show(box);
|
||||||
|
|
||||||
|
box2 = elm_box_add(win);
|
||||||
|
elm_box_horizontal_set(box2, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, 0.0);
|
||||||
|
elm_box_pack_end(box, box2);
|
||||||
|
evas_object_show(box2);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Initial: 0.0");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Initial: 1.0");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Initial: 5.0");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
box2 = elm_box_add(win);
|
||||||
|
elm_box_horizontal_set(box2, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, 0.0);
|
||||||
|
elm_box_pack_end(box, box2);
|
||||||
|
evas_object_show(box2);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Gap: 0.1");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Gap: 0.5");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_label_set(btn, "Gap: 1.0");
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _btn_options_cb, &data);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_autorepeat_set(btn, EINA_TRUE);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(btn, 1.0);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(btn, 0.5);
|
||||||
|
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
|
||||||
|
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.0);
|
||||||
|
elm_box_pack_end(box, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "repeated", _btn_cursors_move_cb, &data);
|
||||||
|
evas_object_smart_callback_add(btn, "unpressed", _btn_cursors_release_cb,
|
||||||
|
&data);
|
||||||
|
|
||||||
|
icon = elm_icon_add(win);
|
||||||
|
elm_icon_standard_set(icon, "arrow_up");
|
||||||
|
elm_button_icon_set(btn, icon);
|
||||||
|
|
||||||
|
data.cursors.up = btn;
|
||||||
|
|
||||||
|
box2 = elm_box_add(win);
|
||||||
|
elm_box_horizontal_set(box2, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_box_pack_end(box, box2);
|
||||||
|
evas_object_show(box2);
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_autorepeat_set(btn, EINA_TRUE);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(btn, 1.0);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(btn, 0.5);
|
||||||
|
evas_object_size_hint_weight_set(btn, 0.0, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "repeated", _btn_cursors_move_cb, &data);
|
||||||
|
evas_object_smart_callback_add(btn, "unpressed", _btn_cursors_release_cb,
|
||||||
|
&data);
|
||||||
|
|
||||||
|
icon = elm_icon_add(win);
|
||||||
|
elm_icon_standard_set(icon, "arrow_left");
|
||||||
|
elm_button_icon_set(btn, icon);
|
||||||
|
|
||||||
|
data.cursors.left = btn;
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
|
||||||
|
icon = elm_icon_add(win);
|
||||||
|
elm_icon_standard_set(icon, "close");
|
||||||
|
elm_button_icon_set(btn, icon);
|
||||||
|
|
||||||
|
data.mid = btn;
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_autorepeat_set(btn, EINA_TRUE);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(btn, 1.0);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(btn, 0.5);
|
||||||
|
evas_object_size_hint_weight_set(btn, 0.0, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
|
||||||
|
elm_box_pack_end(box2, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "repeated", _btn_cursors_move_cb, &data);
|
||||||
|
evas_object_smart_callback_add(btn, "unpressed", _btn_cursors_release_cb,
|
||||||
|
&data);
|
||||||
|
|
||||||
|
icon = elm_icon_add(win);
|
||||||
|
elm_icon_standard_set(icon, "arrow_right");
|
||||||
|
elm_button_icon_set(btn, icon);
|
||||||
|
|
||||||
|
data.cursors.right = btn;
|
||||||
|
|
||||||
|
btn = elm_button_add(win);
|
||||||
|
elm_button_autorepeat_set(btn, EINA_TRUE);
|
||||||
|
elm_button_autorepeat_initial_timeout_set(btn, 1.0);
|
||||||
|
elm_button_autorepeat_gap_timeout_set(btn, 0.5);
|
||||||
|
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
|
||||||
|
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.0);
|
||||||
|
elm_box_pack_end(box, btn);
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "repeated", _btn_cursors_move_cb, &data);
|
||||||
|
evas_object_smart_callback_add(btn, "unpressed", _btn_cursors_release_cb,
|
||||||
|
&data);
|
||||||
|
|
||||||
|
icon = elm_icon_add(win);
|
||||||
|
elm_icon_standard_set(icon, "arrow_down");
|
||||||
|
elm_button_icon_set(btn, icon);
|
||||||
|
|
||||||
|
data.cursors.down = btn;
|
||||||
|
|
||||||
|
elm_run();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ELM_MAIN();
|
|
@ -1958,19 +1958,147 @@ extern "C" {
|
||||||
* @li hoversel_vertical: Internally used by @ref Hoversel to give a
|
* @li hoversel_vertical: Internally used by @ref Hoversel to give a
|
||||||
* continuous look across its options.
|
* continuous look across its options.
|
||||||
* @li hoversel_vertical_entry: Another internal for @ref Hoversel.
|
* @li hoversel_vertical_entry: Another internal for @ref Hoversel.
|
||||||
|
*
|
||||||
|
* Follow through a complete example @ref button_example_01 "here".
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Add a new button to the parent's canvas
|
||||||
|
*
|
||||||
|
* @param parent The parent object
|
||||||
|
* @return The new object or NULL if it cannot be created
|
||||||
*/
|
*/
|
||||||
EAPI Evas_Object *elm_button_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
|
EAPI Evas_Object *elm_button_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Set the label used in the button
|
||||||
|
*
|
||||||
|
* The passed @p label can be NULL to clean any existing text in it and
|
||||||
|
* leave the button as an icon only object.
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @param label The text will be written on the button
|
||||||
|
*/
|
||||||
EAPI void elm_button_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1);
|
EAPI void elm_button_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Get the label set for the button
|
||||||
|
*
|
||||||
|
* The string returned is an internal pointer and should not be freed or
|
||||||
|
* altered. It will also become invalid when the button is destroyed.
|
||||||
|
* The string returned, if not NULL, is a stringshare, so if you need to
|
||||||
|
* keep it around even after the button is destroyed, you can use
|
||||||
|
* eina_stringshare_ref().
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return The text set to the label, or NULL if nothing is set
|
||||||
|
*/
|
||||||
EAPI const char *elm_button_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI const char *elm_button_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Set the icon used for the button
|
||||||
|
*
|
||||||
|
* Setting a new icon will delete any other that was previously set, making
|
||||||
|
* any reference to them invalid. If you need to maintain the previous
|
||||||
|
* object alive, unset it first with elm_button_icon_unset().
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @param icon The icon object for the button
|
||||||
|
*/
|
||||||
EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
|
EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Get the icon used for the button
|
||||||
|
*
|
||||||
|
* Return the icon object which is set for this widget. If the button is
|
||||||
|
* destroyed or another icon is set, the returned object will be deleted
|
||||||
|
* and any reference to it will be invalid.
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return The icon object that is being used
|
||||||
|
*
|
||||||
|
* @see elm_button_icon_unset()
|
||||||
|
*/
|
||||||
EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Remove the icon set without deleting it and return the object
|
||||||
|
*
|
||||||
|
* This function drops the reference the button holds of the icon object
|
||||||
|
* and returns this last object. It is used in case you want to remove any
|
||||||
|
* icon, or set another one, without deleting the actual object. The button
|
||||||
|
* will be left without an icon set.
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return The icon object that was being used
|
||||||
|
*/
|
||||||
EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Turn on/off the autorepeat event generated when the button is kept pressed
|
||||||
|
*
|
||||||
|
* When off, no autorepeat is performed and buttons emit a normal @c clicked
|
||||||
|
* signal when they are clicked.
|
||||||
|
*
|
||||||
|
* When on, keeping a button pressed will continuously emit a @c repeated
|
||||||
|
* signal until the button is released. The time it takes until it starts
|
||||||
|
* emitting the signal is given by
|
||||||
|
* elm_button_autorepeat_initial_timeout_set(), and the time between each
|
||||||
|
* new emission by elm_button_autorepeat_gap_timeout_set().
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @param on A bool to turn on/off the event
|
||||||
|
*/
|
||||||
EAPI void elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on) EINA_ARG_NONNULL(1);
|
EAPI void elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Get whether the autorepeat feature is enabled
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return EINA_TRUE if autorepeat is on, EINA_FALSE otherwise
|
||||||
|
*
|
||||||
|
* @see elm_button_autorepeat_set()
|
||||||
|
*/
|
||||||
EAPI Eina_Bool elm_button_autorepeat_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI Eina_Bool elm_button_autorepeat_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Set the initial timeout before the autorepeat event is generated
|
||||||
|
*
|
||||||
|
* Sets the timeout, in seconds, since the button is pressed until the
|
||||||
|
* first @c repeated signal is emitted. If @p t is 0.0 or less, there
|
||||||
|
* won't be any delay and the even will be fired the moment the button is
|
||||||
|
* pressed.
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @param t Timeout in seconds
|
||||||
|
*
|
||||||
|
* @see elm_button_autorepeat_set()
|
||||||
|
* @see elm_button_autorepeat_gap_timeout_set()
|
||||||
|
*/
|
||||||
EAPI void elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t) EINA_ARG_NONNULL(1);
|
EAPI void elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Get the initial timeout before the autorepeat event is generated
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return Timeout in seconds
|
||||||
|
*
|
||||||
|
* @see elm_button_autorepeat_initial_timeout_set()
|
||||||
|
*/
|
||||||
EAPI double elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI double elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Set the interval between each generated autorepeat event
|
||||||
|
*
|
||||||
|
* After the first @c repeated event is fired, all subsequent ones will
|
||||||
|
* follow after a delay of @p t seconds for each.
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @param t Interval in seconds
|
||||||
|
*
|
||||||
|
* @see elm_button_autorepeat_initial_timeout_set()
|
||||||
|
*/
|
||||||
EAPI void elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t) EINA_ARG_NONNULL(1);
|
EAPI void elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* Get the interval between each generated autorepeat event
|
||||||
|
*
|
||||||
|
* @param obj The button object
|
||||||
|
* @return Interval in seconds
|
||||||
|
*/
|
||||||
EAPI double elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
EAPI double elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
/* fileselector */
|
/* fileselector */
|
||||||
EAPI Evas_Object *elm_fileselector_button_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
|
EAPI Evas_Object *elm_fileselector_button_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#include "elm_priv.h"
|
#include "elm_priv.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup Button Button
|
|
||||||
*
|
|
||||||
* This is a push-button. Press it and run some function. It can contain
|
|
||||||
* a simple label and icon object.
|
|
||||||
*
|
|
||||||
* Signals that you can add callbacks for are:
|
|
||||||
*
|
|
||||||
* "clicked" - the user clicked the button
|
|
||||||
* "repeated" - the user pressed the button without releasing it
|
|
||||||
* "unpressed" - when the button is unpressed (released)
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _Widget_Data Widget_Data;
|
typedef struct _Widget_Data Widget_Data;
|
||||||
|
|
||||||
struct _Widget_Data
|
struct _Widget_Data
|
||||||
|
@ -298,13 +285,6 @@ _signal_unpressed(void *data, Evas_Object *obj __UNUSED__, const char *emission
|
||||||
evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
|
evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new button to the parent
|
|
||||||
* @param parent The parent object
|
|
||||||
* @return The new object or NULL if it cannot be created
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_button_add(Evas_Object *parent)
|
elm_button_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
|
@ -349,14 +329,6 @@ elm_button_add(Evas_Object *parent)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the label used in the button
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @param label The text will be written on the button
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_button_label_set(Evas_Object *obj, const char *label)
|
elm_button_label_set(Evas_Object *obj, const char *label)
|
||||||
{
|
{
|
||||||
|
@ -382,18 +354,6 @@ elm_button_label_get(const Evas_Object *obj)
|
||||||
return wd->label;
|
return wd->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the icon used for the button
|
|
||||||
*
|
|
||||||
* Once the icon object is set, a previously set one will be deleted
|
|
||||||
* If you want to keep that old content object, use the
|
|
||||||
* elm_button_icon_unset() function.
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @param icon The icon object for the button
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||||
{
|
{
|
||||||
|
@ -415,16 +375,6 @@ elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||||
_sizing_eval(obj);
|
_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the icon used for the button
|
|
||||||
*
|
|
||||||
* Return the icon object which is set for this widget.
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @return The icon object that is being used
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_button_icon_get(const Evas_Object *obj)
|
elm_button_icon_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -434,16 +384,6 @@ elm_button_icon_get(const Evas_Object *obj)
|
||||||
return wd->icon;
|
return wd->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unset the icon used for the button
|
|
||||||
*
|
|
||||||
* Unparent and return the icon object which was set for this widget.
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @return The icon object that was being used
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_button_icon_unset(Evas_Object *obj)
|
elm_button_icon_unset(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -458,14 +398,6 @@ elm_button_icon_unset(Evas_Object *obj)
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn on/off the autorepeat event generated when the user keeps pressing on the button
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @param on A bool to turn on/off the event
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
|
elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
|
||||||
{
|
{
|
||||||
|
@ -481,14 +413,6 @@ elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
|
||||||
wd->repeating = EINA_FALSE;
|
wd->repeating = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get if autorepeat event is on
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @return If autorepeat is on
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
elm_button_autorepeat_get(const Evas_Object *obj)
|
elm_button_autorepeat_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -498,14 +422,6 @@ elm_button_autorepeat_get(const Evas_Object *obj)
|
||||||
return wd->autorepeat;
|
return wd->autorepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the initial timeout before the autorepeat event is generated
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @param t Timeout
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
|
elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
|
||||||
{
|
{
|
||||||
|
@ -521,14 +437,6 @@ elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
|
||||||
wd->ar_threshold = t;
|
wd->ar_threshold = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the initial timeout before the autorepeat event is generated
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @return Timeout
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI double
|
EAPI double
|
||||||
elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
|
elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -538,14 +446,6 @@ elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
|
||||||
return wd->ar_threshold;
|
return wd->ar_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the interval between each generated autorepeat event
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @param t Interval
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
|
elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
|
||||||
{
|
{
|
||||||
|
@ -558,14 +458,6 @@ elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
|
||||||
if ((wd->repeating) && (wd->timer)) ecore_timer_interval_set(wd->timer, t);
|
if ((wd->repeating) && (wd->timer)) ecore_timer_interval_set(wd->timer, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the interval between each generated autorepeat event
|
|
||||||
*
|
|
||||||
* @param obj The button object
|
|
||||||
* @return Interval
|
|
||||||
*
|
|
||||||
* @ingroup Button
|
|
||||||
*/
|
|
||||||
EAPI double
|
EAPI double
|
||||||
elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
|
elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue