Canvas layout: port part_text to efl_part

You now use the following:

  efl_text_set(efl_part(edje_obj, "part"), "text");
  const char *text = efl_text_get(efl_part(edje_obj, "part"));

The former method of edje_object_part_text_set/get is now legacy.

Also, adjusted 'tests/emotion/emotion_test_main-eo.c' with
this change.
This commit is contained in:
Daniel Hirt 2017-05-30 10:31:19 +03:00
parent 4a1b42aee8
commit 6e1b5fdd10
10 changed files with 97 additions and 30 deletions

View File

@ -8,6 +8,7 @@ edje_eolian_files = \
lib/edje/efl_canvas_layout_internal_table.eo \
lib/edje/efl_canvas_layout_internal_swallow.eo \
lib/edje/efl_canvas_layout_external.eo \
lib/edje/efl_canvas_layout_internal_text.eo \
lib/edje/edje_edit.eo
edje_eolian_type_files = \
@ -101,7 +102,8 @@ lib/edje/edje_part_helper.h \
lib/edje/edje_part_external.c \
lib/edje/edje_part_swallow.c \
lib/edje/edje_part_table.c \
lib/edje/edje_part_box.c
lib/edje/edje_part_box.c \
lib/edje/edje_part_text.c
lib_edje_libedje_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EDJE_COMMON_CPPFLAGS)
lib_edje_libedje_la_LIBADD = @EDJE_LIBS@ @EDJE_LUA_LIBS@

View File

@ -7,4 +7,5 @@
#include "efl_canvas_layout_internal_box.eo.h"
#include "efl_canvas_layout_internal_table.eo.h"
#include "efl_canvas_layout_internal_swallow.eo.h"
#include "efl_canvas_layout_internal_text.eo.h"
#include "efl_canvas_layout_external.eo.h"

View File

@ -1353,9 +1353,30 @@ EAPI Eina_Bool edje_object_part_drag_page_get(const Edje_Object *obj, const char
*/
EAPI Eina_Bool edje_object_part_drag_page(Edje_Object *obj, const char *part, double dx, double dy);
/**
* @brief Sets a given text to an Edje object @c TEXT or TEXTBLOCK
* parts.
*
* @param[in] part The part name
* @param[in] text The text to set on that part
*
* @ingroup Edje_Object
*/
EAPI Eina_Bool edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text);
/**
* @brief Gets the text currntly set to the given part
*
* @param[in] part The part name
*
* @return The text set on the part, @c null otherwise.
*
* @ingroup Edje_Object
*/
EAPI const char * edje_object_part_text_get(const Edje_Object *obj, const char *part);
/**
* @}
*/
#include "edje_object.eo.legacy.h"
#include "edje_edit.eo.legacy.h"

View File

@ -780,25 +780,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
data: void_ptr; [[The data associated to the callback function.]]
}
}
@property part_text {
set {
[[Sets the text for an object part]]
return: bool; [[$true on success, $false otherwise]]
}
get {
[[Returns the text of the object part.
This function returns the text associated to the object part.
See also @.part_text.set().]]
}
keys {
part: string; [[The part name]]
}
values {
text: string; [[The text string]]
}
}
@property part_text_escaped {
set {
[[Sets the text for an object part, but converts HTML escapes to UTF8

View File

@ -9,6 +9,7 @@ PROXY_INIT(box)
PROXY_INIT(table)
PROXY_INIT(swallow)
PROXY_INIT(external)
PROXY_INIT(text)
PROXY_INIT(other)
void
@ -18,6 +19,7 @@ _edje_internal_proxy_shutdown(void)
_table_shutdown();
_swallow_shutdown();
_external_shutdown();
_text_shutdown();
_other_shutdown();
}

View File

@ -0,0 +1,26 @@
#include "edje_private.h"
#include "edje_part_helper.h"
#include "efl_canvas_layout_internal_text.eo.h"
#define MY_CLASS EFL_CANVAS_LAYOUT_INTERNAL_TEXT_CLASS
PROXY_IMPLEMENTATION(text, INTERNAL_TEXT, EINA_FALSE)
#undef PROXY_IMPLEMENTATION
EOLIAN static void
_efl_canvas_layout_internal_text_efl_text_text_set(Eo *obj,
void *_pd EINA_UNUSED, const char *text)
{
PROXY_DATA_GET(obj, pd);
_edje_efl_text_set(obj, pd->ed, pd->part, text);
}
EOLIAN static const char *
_efl_canvas_layout_internal_text_efl_text_text_get(Eo *obj,
void *_pd EINA_UNUSED)
{
PROXY_DATA_GET(obj, pd);
RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part));
}
#include "efl_canvas_layout_internal_text.eo.c"

View File

@ -3146,6 +3146,11 @@ Edje_External_Param_Type _edje_object_part_external_param_type_get(Edje *ed, con
Evas_Object *_edje_object_part_external_object_get(Edje *ed, const char *part);
Evas_Object *_edje_object_part_external_content_get(Edje *ed, const char *part, const char *content);
/* part text */
Eo *_edje_text_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp);
Eina_Bool _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text);
const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part);
void _edje_internal_proxy_shutdown(void);
// Svg loader

View File

@ -2005,8 +2005,8 @@ _edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_
eud->u.string.type = type;
}
EOLIAN Eina_Bool
_edje_object_part_text_set(Eo *obj, Edje *ed, const char *part, const char *text)
Eina_Bool
_edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text)
{
Edje_Real_Part *rp;
Eina_Bool int_ret;
@ -2026,8 +2026,8 @@ _edje_object_part_text_set(Eo *obj, Edje *ed, const char *part, const char *text
return int_ret;
}
EOLIAN const char *
_edje_object_part_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
const char *
_edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
{
Edje_Real_Part *rp;
@ -3690,6 +3690,10 @@ _edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part)
return _edje_swallow_internal_proxy_get(obj, ed, rp);
else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
return _edje_external_internal_proxy_get(obj, ed, rp);
else if (rp->part->type == EDJE_PART_TYPE_TEXT)
return _edje_text_internal_proxy_get(obj, ed, rp);
else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
return _edje_text_internal_proxy_get(obj, ed, rp);
else
return _edje_other_internal_proxy_get(obj, ed, rp);
}
@ -6551,4 +6555,17 @@ edje_object_part_swallow_get(const Edje_Object *obj, const char *part)
return efl_content_get(efl_part(obj, part));
}
EAPI Eina_Bool
edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text)
{
efl_text_set(efl_part(obj, part), text);
return EINA_TRUE;
}
EAPI const char *
edje_object_part_text_get(const Edje_Object *obj, const char *part)
{
return efl_text_get(efl_part(obj, part));
}
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/

View File

@ -0,0 +1,12 @@
class Efl.Canvas.Layout_Internal.Text (Efl.Canvas.Layout_Internal, Efl.Text)
{
[[Represents a TEXT part of a layout
Its lifetime is limited to one function call only, unless an extra
reference is explicitely held.
]]
data: null;
implements {
Efl.Text.text { set; get; }
}
}

View File

@ -320,7 +320,7 @@ video_obj_time_changed(Evas_Object *obj, Evas_Object *edje)
snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
ph, pm, ps, pf, lh, lm, ls);
edje_obj_part_text_set(edje, "video_progress_txt", buf);
efl_text_set(efl_part(edje, "video_progress_txt"), buf);
}
static void
@ -478,7 +478,7 @@ video_obj_signal_alpha_cb(void *data, Evas_Object *o, const char *emission EINA_
alpha = 255 * y;
efl_gfx_color_set(ov, alpha, alpha, alpha, alpha);
snprintf(buf, sizeof(buf), "alpha %.0f", alpha);
edje_obj_part_text_set(o, "video_alpha_txt", buf);
efl_text_set(efl_part(o, "video_alpha_txt"), buf);
}
static void
@ -491,7 +491,7 @@ video_obj_signal_vol_cb(void *data, Evas_Object *o, const char *emission EINA_UN
efl_ui_drag_value_get(efl_part(o, source), NULL, &vol);
emotion_object_audio_volume_set(ov, vol);
snprintf(buf, sizeof(buf), "vol %.2f", vol);
edje_obj_part_text_set(o, "video_volume_txt", buf);
efl_text_set(efl_part(o, "video_volume_txt"), buf);
}
static void
@ -642,9 +642,9 @@ init_video_object(const char *module_filename, const char *filename)
edje_obj_signal_callback_add(oe, "frame_resize", "stop", video_obj_signal_frame_resize_stop_cb, oe);
edje_obj_signal_callback_add(oe, "mouse, move", "*", video_obj_signal_frame_move_cb, oe);
efl_ui_drag_value_set(efl_part(oe, "video_alpha"), 0.0, 1.0);
edje_obj_part_text_set(oe, "video_alpha_txt", "alpha 255");
efl_text_set(efl_part(oe, "video_alpha_txt"), "alpha 255");
efl_ui_drag_value_set(efl_part(oe, "video_volume"), 0.0, 0.5);
edje_obj_part_text_set(oe, "video_volume_txt", "vol 0.50");
efl_text_set(efl_part(oe, "video_volume_txt"), "vol 0.50");
edje_obj_signal_emit(oe, "video_state", "play");
efl_gfx_visible_set(oe, EINA_TRUE);
}