scroller: Introducing Efl.Ui.Scroller

Summary:
scrollable widgets had a interface_scrollable as a mixin so that the
widgets had a 'is-a' relation with interface_scrollabe.  however, new
scroller concept don't have 'is-a' relationship, but 'has-a'
relationship.  scrollable widgets should have a scroll manager inside
them, then scroll manager handles event from user and api
implementations.  and also we cut the features such as paging because
there will be aka 'elm_pager'.

we are expecting that the new concept make us to maintain the scroller
easier.  please excuse for many unorganized code and logics. : (

[contained commit]
scrollable: add efl_ui_scroller example
scrollable: refactoring for behavior in case of multiple scroller
scrollable: remove repetitive scrollbar code.
scrollable: combine calculating bounce distance code.
scroll_manager: mouse up function refactoring
scroll_manager: mouse move function refactoring
scroll_manager: warp animator wip
scroll_manager: fix denominator value when calculating flicking behavior.
Fix to disconnect bounce animator once animation is done
gather duplicated animator drop logics
gather duplicated conditions
Rearrange prototypes and append comment
Add manipulate functions for animators
scroll_manager: change member_add function.
scroll_manger: apply mirroring logic
scroll_manager: apply scrollbar
apply API to scroller widget
scroll_manager: apply scroll event callback
Change logics for all about scroll animating
efl_ui_pan: add efl_ui_pan
scrollable:  change content_min_limit to match_content
scroll theme: apply overlapped scrollbar
+ many others!

Reviewers: akanad, woohyun, cedric, jpeg

Subscribers: jenkins, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5222

Note by @jpeg:
Unfortunately this patch comes in a massive single blob, after too many
rebase operations. It has now come to a point where I think the API is
nice and it works as I'd expect.
Now I only wonder how applicable this will be for Efl.Ui.List. As we can
see Photocam (legacy and unified API) could be transformed to use this
new API.
This commit is contained in:
Wonki Kim 2017-12-18 21:08:25 +09:00 committed by Jean-Philippe Andre
parent 29ce7550eb
commit 47bf356435
25 changed files with 4551 additions and 245 deletions

View File

@ -8,6 +8,8 @@ efl_eolian_legacy_files = \
lib/efl/interfaces/efl_ui_draggable.eo \
lib/efl/interfaces/efl_ui_clickable.eo \
lib/efl/interfaces/efl_ui_scrollable.eo \
lib/efl/interfaces/efl_ui_scrollable_interactive.eo \
lib/efl/interfaces/efl_ui_scrollbar.eo \
lib/efl/interfaces/efl_ui_selectable.eo \
lib/efl/interfaces/efl_ui_zoom.eo \
$(NULL)

View File

@ -82,6 +82,9 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_widget_part_bg.eo \
lib/elementary/efl_ui_widget_part_shadow.eo \
lib/elementary/efl_ui_win_part.eo \
lib/elementary/efl_ui_scroller.eo \
lib/elementary/efl_ui_scroll_manager.eo \
lib/elementary/efl_ui_pan.eo \
lib/elementary/efl_access.eo \
lib/elementary/efl_access_action.eo \
lib/elementary/efl_access_component.eo \
@ -358,6 +361,9 @@ includesunstable_HEADERS = \
lib/elementary/elm_code_parse.h \
lib/elementary/elm_code_syntax.h \
lib/elementary/efl_ui_multibuttonentry.h \
lib/elementary/efl_ui_widget_scroller.h \
lib/elementary/efl_ui_widget_scroll_manager.h \
lib/elementary/efl_ui_widget_pan.h \
lib/elementary/Efl_Ui.h
includesunstabledir = $(includedir)/elementary-@VMAJ@
@ -748,6 +754,9 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_list_precise_layouter.c \
lib/elementary/efl_ui_list_segarray.c \
lib/elementary/efl_ui_layout_factory.c \
lib/elementary/efl_ui_scroller.c \
lib/elementary/efl_ui_scroll_manager.c \
lib/elementary/efl_ui_pan.c \
$(NULL)
@ -915,6 +924,7 @@ bin/elementary/test_progressbar.c \
bin/elementary/test_radio.c \
bin/elementary/test_scaling.c \
bin/elementary/test_scroller.c \
bin/elementary/test_ui_scroller.c \
bin/elementary/test_segment_control.c \
bin/elementary/test_separator.c \
bin/elementary/test_slider.c \

View File

@ -176,6 +176,8 @@ void test_scroller2(void *data, Evas_Object *obj, void *event_info);
void test_scroller3(void *data, Evas_Object *obj, void *event_info);
void test_scroller4(void *data, Evas_Object *obj, void *event_info);
void test_scroller5(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_scroller(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_scroller2(void *data, Evas_Object *obj, void *event_info);
void test_spinner(void *data, Evas_Object *obj, void *event_info);
void test_ui_spin(void *data, Evas_Object *obj, void *event_info);
void test_ui_spin_button(void *data, Evas_Object *obj, void *event_info);
@ -1024,6 +1026,7 @@ add_tests:
ADD_TEST(NULL, "Scroller", "Scroller 3", test_scroller3);
ADD_TEST(NULL, "Scroller", "Page Scroller", test_scroller4);
ADD_TEST(NULL, "Scroller", "Scroller on Popup", test_scroller5);
ADD_TEST_EO(NULL, "Scroller", "Efl.Ui.Scroller", test_efl_ui_scroller);
//------------------------------//
// FIXME: add frame test

View File

@ -0,0 +1,124 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
static void
_bt_clicked(void *data EINA_UNUSED, const Efl_Event *ev)
{
printf("click went through on %p\n", ev->object);
}
static void
_scroll_start_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{
printf("scroll start: %p\n", ev->object);
}
static void
_scroll_stop_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{
printf("scroll stop: %p\n", ev->object);
}
void
test_efl_ui_scroller(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eo *win, *sc, *sc2, *sc3, *bx, *bx2, *gd, *gd2;
int i, j;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Efl Ui Scroller"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_gfx_size_set(win, EINA_SIZE2D(320, 400));
sc = efl_add(EFL_UI_SCROLLER_CLASS, win,
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _scroll_start_cb, NULL),
efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _scroll_stop_cb, NULL),
efl_content_set(win, efl_added));
bx = efl_add(EFL_UI_BOX_CLASS, sc,
efl_ui_direction_set(efl_added, EFL_UI_DIR_DOWN),
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0),
efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, 0),
efl_content_set(sc, efl_added));
for (i = 0; i < 3; i++)
{
efl_add(EFL_UI_BUTTON_CLASS, bx,
efl_text_set(efl_added, "Vertical"),
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, 0.5),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _bt_clicked, NULL),
efl_pack(bx, efl_added));
}
sc2 = efl_add(EFL_UI_SCROLLER_CLASS, bx,
efl_ui_scrollable_match_content_set(efl_added, EINA_FALSE, EINA_TRUE),
efl_pack(bx, efl_added));
bx2 = efl_add(EFL_UI_BOX_CLASS, sc2,
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_content_set(sc2, efl_added));
for (i = 0; i < 10; i++)
{
efl_add(EFL_UI_BUTTON_CLASS, bx2,
efl_text_set(efl_added, "... Horizontal scrolling ..."),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _bt_clicked, NULL),
efl_pack(bx2, efl_added));
}
for (i = 0; i < 3; i++)
{
efl_add(EFL_UI_BUTTON_CLASS, bx,
efl_text_set(efl_added, "Vertical"),
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, 0.5),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _bt_clicked, NULL),
efl_pack(bx, efl_added));
}
gd = efl_add(EFL_UI_GRID_CLASS, bx,
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
efl_gfx_size_hint_align_set(efl_added, 0.5, 0),
efl_pack(bx, efl_added));
efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
efl_gfx_color_set(efl_added, 0, 0, 0, 0),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(200, 120)),
efl_pack_grid(gd, efl_added, 0, 0, 1, 1));
sc3 = efl_add(EFL_UI_SCROLLER_CLASS, win,
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL),
efl_pack_grid(gd, efl_added, 0, 0, 1, 1));
gd2 = efl_add(EFL_UI_GRID_CLASS, sc3,
efl_content_set(sc3, efl_added));
for (j = 0; j < 16; j++)
{
for (i = 0; i < 16; i++)
{
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Both"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _bt_clicked, NULL),
efl_pack_grid(gd2, efl_added, i, j, 1, 1));
}
}
for (i = 0; i < 200; i++)
{
efl_add(EFL_UI_BUTTON_CLASS, bx,
efl_text_set(efl_added, "Vertical"),
efl_gfx_size_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
efl_gfx_size_hint_align_set(efl_added, EVAS_HINT_FILL, 0.5),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _bt_clicked, NULL),
efl_pack(bx, efl_added));
}
}

View File

@ -0,0 +1,31 @@
//Compile with:
//gcc -g efl_ui_scroller_example.c -o efl_ui_scroller_example `pkg-config --cflags --libs elementary`
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <Elementary.h>
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
{
Eo *win, *scroller, *content;
char buf[64];
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_app_info_set(efl_main, "elementary", "images/plant_01.jpg");
win = efl_add(EFL_UI_WIN_CLASS, NULL, "TEST", ELM_WIN_BASIC,
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_gfx_size_set(win, EINA_SIZE2D(300, 400));
scroller = efl_add(EFL_UI_SCROLLER_CLASS, win);
efl_content_set(win, scroller);
content = efl_add(EFL_UI_IMAGE_CLASS, scroller);
snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
efl_file_set(content, buf, NULL);
efl_gfx_size_set(content, EINA_SIZE2D(5000, 5000));
efl_content_set(scroller, content);
}
EFL_MAIN()

View File

@ -98,6 +98,8 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
#include "interfaces/efl_ui_draggable.eo.h"
#include "interfaces/efl_ui_clickable.eo.h"
#include "interfaces/efl_ui_scrollable.eo.h"
#include "interfaces/efl_ui_scrollbar.eo.h"
#include "interfaces/efl_ui_scrollable_interactive.eo.h"
#include "interfaces/efl_ui_selectable.eo.h"
#include "interfaces/efl_ui_zoom.eo.h"

View File

@ -3,6 +3,8 @@
#endif
#define EFL_CANVAS_BETA
#define EFL_UI_SCROLLBAR_PROTECTED
#define EFL_UI_SCROLLBAR_BETA
#include <Efl.h>
@ -75,6 +77,8 @@
#include "interfaces/efl_ui_draggable.eo.c"
#include "interfaces/efl_ui_clickable.eo.c"
#include "interfaces/efl_ui_scrollable.eo.c"
#include "interfaces/efl_ui_scrollable_interactive.eo.c"
#include "interfaces/efl_ui_scrollbar.eo.c"
#include "interfaces/efl_ui_selectable.eo.c"
#include "interfaces/efl_ui_zoom.eo.c"

View File

@ -1,9 +1,33 @@
enum Efl.Ui.Scroll_Block
{
[[Direction in which a scroller should be blocked.
Note: These options may be effective only in case of thumbscroll (i.e.
when scrolling by dragging).
@since 1.21
]]
none = 0, [[Don't block any movement.]]
vertical = 1, [[Block vertical movement.]]
horizontal = 2 [[Block horizontal movement.]]
}
interface Efl.Ui.Scrollable ()
{
[[Efl UI scrollable interface]]
event_prefix: efl_ui;
events {
scroll; [[Called when scroll operation started]]
scroll,start; [[Called when scroll operation started]]
scroll; [[Called when scroll operation]]
scroll,stop; [[Called when scroll operation stopped]]
scroll,up; [[Called when scrolling to upwards]]
scroll,down; [[Called when scrolling to downwards]]
scroll,left; [[Called when scrolling to left]]
scroll,right; [[Called when scrolling to right]]
edge,up; [[Called when hitting the top edge]]
edge,down; [[Called when hitting the bottom edge]]
edge,left; [[Called when hitting the left edge]]
edge,right; [[Called when hitting the right edge]]
scroll,anim,start; [[Called when scroll animation started]]
scroll,anim,stop; [[Called when scroll animation stopped]]
scroll,drag,start; [[Called when scroll drag started]]

View File

@ -0,0 +1,156 @@
import eina_types;
interface Efl.Ui.Scrollable.Interactive (Efl.Ui.Scrollable)
{
eo_prefix: efl_ui_scrollable;
methods {
@property content_pos {
[[The content position]]
set {
}
get {
}
values {
pos: Eina.Position2D; [[The position is virtual value, (0, 0) starting at the top-left.]]
}
}
@property content_size {
[[The content size]]
get {
}
values {
size: Eina.Size2D; [[The content size in pixels.]]
}
}
@property viewport_geometry {
[[The viewport geometry]]
get {
}
values {
rect: Eina.Rect; [[It is absolute geometry.]]
}
}
@property bounce_enabled {
[[Bouncing behavior
When scrolling, the scroller may "bounce" when reaching an edge of the
content object. This is a visual way to indicate the end has been reached.
This is enabled by default for both axis. This API will set if it is enabled
for the given axis with the boolean parameters for each axis.]]
set {
}
get {
}
values {
horiz: bool; [[Horizontal bounce policy.]]
vert: bool; [[Vertical bounce policy.]]
}
}
@property scroll_freeze {
[[Freeze property
This function will freeze scrolling movement (by input of a user).
Unlike efl_ui_scrollable_movement_block_set, this function freezes bidirectional.
If you want to freeze only one direction,
See @.movement_block.set.
]]
get {
}
set {
}
values {
freeze: bool; [[$true if freeze, $false otherwise]]
}
}
@property scroll_hold {
[[Hold property
When hold turns on, it only scrolls by holding action.
]]
get {
}
set {
}
values {
hold: bool; [[$true if hold, $false otherwise]]
}
}
@property looping {
[[Controls an infinite loop for a scroller.]]
set {
}
get {
}
values {
loop_h: bool; [[The scrolling horizontal loop]]
loop_v: bool; [[The Scrolling vertical loop]]
}
}
@property movement_block {
[[Blocking of scrolling (per axis)
This function will block scrolling movement (by input of a user) in
a given direction. One can disable movements in the X axis, the Y
axis or both. The default value is $none, where movements are
allowed in both directions.
]]
set {
}
get {
}
values {
block: Efl.Ui.Scroll_Block(Efl.Ui.Scroll_Block.none); [[Which axis (or axes) to block]]
}
}
@property gravity {
[[Control scrolling gravity on the scrollable
The gravity defines how the scroller will adjust its view
when the size of the scroller contents increases.
The scroller will adjust the view to glue itself as follows.
x=0.0, for staying where it is relative to the left edge of the content
x=1.0, for staying where it is relative to the rigth edge of the content
y=0.0, for staying where it is relative to the top edge of the content
y=1.0, for staying where it is relative to the bottom edge of the content
Default values for x and y are 0.0]]
set {
}
get {
}
values {
x: double; [[Horizontal scrolling gravity]]
y: double; [[Vertical scrolling gravity]]
}
}
@property match_content {
[[Prevent the scrollable from being smaller than the minimum size of the content.
By default the scroller will be as small as its design allows,
irrespective of its content. This will make the scroller minimum size the
right size horizontally and/or vertically to perfectly fit its content in
that direction.]]
set {
}
values {
w: bool; [[Whether to limit the minimum horizontal size]]
h: bool; [[Whether to limit the minimum vertical size]]
}
}
scroll {
[[Show a specific virtual region within the scroller content object.
This will ensure all (or part if it does not fit) of the designated
region in the virtual content object (0, 0 starting at the top-left of the
virtual content object) is shown within the scroller. This allows the scroller to "smoothly slide"
to this location (if configuration in general calls for transitions). It
may not jump immediately to the new location and make take a while and
show other content along the way.
]]
params {
@in rect: Eina.Rect; [[The position where to scroll. and The size user want to see]]
@in animation: bool; [[Whether to scroll with animation or not]]
}
}
}
}

View File

@ -0,0 +1,70 @@
enum Efl.Ui.Scrollbar_Mode
{
auto = 0, [[Visible if necessary]]
on, [[Always visible]]
off, [[Always invisible]]
last [[]]
}
enum Efl.Ui.Scrollbar_Direction
{
horizontal = 0,
vertical,
last
}
interface Efl.Ui.Scrollbar ()
{
methods {
@property bar_mode {
[[Scrollbar visibility policy]]
set {
}
get {
}
values {
hbar: Efl.Ui.Scrollbar_Mode; [[Horizontal scrollbar]]
vbar: Efl.Ui.Scrollbar_Mode; [[Vertical scrollbar]]
}
}
@property bar_size {
[[Scrollbar size.
It is calculated based on viewport size-content sizes.
]]
get {
}
values {
width: double; [[Value between 0.0 and 1.0]]
height: double; [[Value between 0.0 and 1.0]]
}
}
@property bar_position {
[[Scrollbar position.
It is calculated based on current position-maximum positions.
]]
set {
}
get {
}
values {
posx: double; [[Value between 0.0 and 1.0]]
posy: double; [[Value between 0.0 and 1.0]]
}
}
bar_visibility_update @protected @beta{
[[ Update bar visibility.
The object will call this function whenever the bar
need to be shown or hidden.
]]
}
}
events {
bar,press; [[Called when bar is pressed]]
bar,unpress; [[Called when bar is unpressed]]
bar,drag; [[Called when bar is dragged]]
bar,size,changed; [[Called when bar size is changed]]
bar,pos,changed; [[Called when bar position is changed]]
bar,show; [[Callend when bar is shown]]
bar,hide; [[Called when bar is hidden]]
}
}

View File

@ -324,6 +324,9 @@ EAPI extern Elm_Version *elm_version;
# include <efl_ui_list_relayout.eo.h>
# include <efl_ui_list.eo.h>
# include <efl_ui_list_pan.eo.h>
# include <efl_ui_scroll_manager.eo.h>
# include <efl_ui_scroller.eo.h>
# include <efl_ui_pan.eo.h>
#endif
/* include deprecated calls last of all */

View File

@ -76,20 +76,6 @@ enum Efl.Ui.Softcursor_Mode
off [[Never use a softcursor.]]
}
enum Efl.Ui.Scroll_Block
{
[[Direction in which a scroller should be blocked.
Note: These options may be effective only in case of thumbscroll (i.e.
when scrolling by dragging).
@since 1.21
]]
none = 0, [[Don't block any movement.]]
vertical = 1, [[Block vertical movement.]]
horizontal = 2 [[Block horizontal movement.]]
}
/* 'on_access_activate' is beta API in the Widget class */
enum Efl.Ui.Activate
{

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
class Efl.Ui.Image_Zoomable (Elm.Widget, Efl.Ui.Image, Efl.Ui.Zoom,
Elm.Interface_Scrollable,
Efl.Ui.Scrollable)
Efl.Ui.Scrollable.Interactive,
Efl.Ui.Scrollbar)
{
[[Elementary Image Zoomable class]]
legacy_prefix: elm_photocam;
@ -61,13 +61,15 @@ class Efl.Ui.Image_Zoomable (Elm.Widget, Efl.Ui.Image, Efl.Ui.Zoom,
Elm.Widget.theme_apply;
Elm.Widget.on_focus_update;
Elm.Widget.widget_event;
Elm.Interface_Scrollable.region_bring_in;
Efl.Ui.Scrollable.Interactive.scroll;
Efl.Access.Widget.Action.elm_actions { get; }
Efl.File.file { get; set; }
Efl.Orientation.orientation { get; set; }
Efl.Flipable.flip { get; set; }
Efl.Layout.Group.group_size_min { get; }
Efl.Layout.Group.group_size_max { get; }
Efl.Layout.Signal.signal_callback_add;
Efl.Layout.Signal.signal_callback_del;
//Efl.Canvas.Layout_Group.group_data { get; }
}
events {

View File

@ -1,4 +1,4 @@
class Efl.Ui.Image_Zoomable_Pan (Elm.Pan)
class Efl.Ui.Image_Zoomable_Pan (Efl.Ui.Pan)
{
[[Elementary photocom pan class]]
legacy_prefix: elm_photocam_pan;
@ -8,10 +8,10 @@ class Efl.Ui.Image_Zoomable_Pan (Elm.Pan)
Efl.Gfx.position { set; }
Efl.Gfx.size { set; }
Efl.Canvas.Group.group_calculate;
Elm.Pan.content_size { get; }
Elm.Pan.pos { get; set; }
Elm.Pan.pos_min { get; }
Elm.Pan.pos_max { get; }
Efl.Ui.Pan.content_size { get; }
Efl.Ui.Pan.pan_position { get; set; }
Efl.Ui.Pan.pan_position_min { get; }
Efl.Ui.Pan.pan_position_max { get; }
}
events {
load; [[Called when load started]]

View File

@ -59,10 +59,10 @@ struct _Efl_Ui_Image_Zoomable_Grid
struct _Efl_Ui_Image_Zoomable_Data
{
Evas_Object *hit_rect;
Eo *smanager;
Eo *pan_obj;
Evas_Object *g_layer;
Evas_Object *pan_obj;
Evas_Coord pan_x, pan_y, minw, minh;
@ -109,11 +109,7 @@ struct _Efl_Ui_Image_Zoomable_Data
} spos;
} size;
struct
{
Eina_Bool show : 1;
Evas_Coord x, y, w, h;
} show;
Eina_Rect show;
int tsize;
Evas_Object *img; /* low res version of image (scale down == 8) */
@ -147,11 +143,13 @@ struct _Efl_Ui_Image_Zoomable_Data
Eina_Bool orientation_changed : 1;
Eina_Bool play : 1;
Eina_Bool anim : 1;
Eina_Bool freeze_want : 1;
Eina_Bool show_item: 1;
};
struct _Efl_Ui_Image_Zoomable_Pan_Data
{
Evas_Object *wobj;
Eo *wobj;
Efl_Ui_Image_Zoomable_Data *wsd;
};

View File

@ -0,0 +1,197 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_widget_pan.h"
#define MY_CLASS EFL_UI_PAN_CLASS
#define MY_CLASS_NAME "Efl_Ui_Pan"
#define EFL_UI_PAN_DATA_GET(o, sd) \
Efl_Ui_Pan_Data *sd = efl_data_scope_safe_get(o, MY_CLASS)
#define EFL_UI_PAN_DATA_GET_OR_RETURN(o, ptr, ...) \
EFL_UI_PAN_DATA_GET(o, ptr); \
if (EINA_UNLIKELY(!ptr)) \
{ \
CRI("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return __VA_ARGS__; \
}
EOLIAN static void
_efl_ui_pan_efl_gfx_position_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Position2D pos)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
return;
efl_gfx_position_set(efl_super(obj, MY_CLASS), pos);
psd->x = pos.x;
psd->y = pos.y;
evas_object_smart_changed(obj);
}
EOLIAN static void
_efl_ui_pan_efl_gfx_size_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Size2D sz)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
return;
efl_gfx_size_set(efl_super(obj, MY_CLASS), sz);
psd->w = sz.w;
psd->h = sz.h;
evas_object_smart_changed(obj);
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_VIEWPORT_CHANGED, NULL);
}
EOLIAN static void
_efl_ui_pan_efl_gfx_visible_set(Eo *obj, Efl_Ui_Pan_Data *psd, Eina_Bool vis)
{
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
return;
efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);
if (psd->content) efl_gfx_visible_set(psd->content, vis);
}
EOLIAN static void
_efl_ui_pan_pan_position_set(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd, Eina_Position2D pos)
{
if ((pos.x == psd->px) && (pos.y == psd->py)) return;
psd->px = pos.x;
psd->py = pos.y;
evas_object_smart_changed(obj);
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_POSITION_CHANGED, NULL);
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
return EINA_POSITION2D(psd->px, psd->py);
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
Eina_Position2D pos = { 0, 0};
if (psd->w < psd->content_w) pos.x = psd->content_w - psd->w;
if (psd->h < psd->content_h) pos.y = psd->content_h - psd->h;
return pos;
}
EOLIAN static Eina_Position2D
_efl_ui_pan_pan_position_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *_pd EINA_UNUSED)
{
return EINA_POSITION2D(0 ,0);
}
EOLIAN static Eina_Size2D
_efl_ui_pan_content_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
return EINA_SIZE2D(psd->content_w, psd->content_h);
}
EOLIAN static Eo *
_efl_ui_pan_efl_object_constructor(Eo *obj, Efl_Ui_Pan_Data *_pd EINA_UNUSED)
{
efl_canvas_group_clipped_set(obj, EINA_TRUE);
obj = efl_constructor(efl_super(obj, MY_CLASS));
return obj;
}
EOLIAN static void
_efl_ui_pan_efl_object_destructor(Eo *obj, Efl_Ui_Pan_Data *sd EINA_UNUSED)
{
efl_content_set(obj, NULL);
efl_destructor(efl_super(obj, MY_CLASS));
}
static void
_efl_ui_pan_content_del_cb(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *pobj = data;
EFL_UI_PAN_DATA_GET_OR_RETURN(pobj, psd);
psd->content = NULL;
psd->content_w = psd->content_h = psd->px = psd->py = 0;
efl_event_callback_call(pobj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
}
static void
_efl_ui_pan_content_resize_cb(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *pobj = data;
EFL_UI_PAN_DATA_GET_OR_RETURN(pobj, psd);
Eina_Size2D sz = efl_gfx_size_get(psd->content);
if ((sz.w != psd->content_w) || (sz.h != psd->content_h))
{
psd->content_w = sz.w;
psd->content_h = sz.h;
evas_object_smart_changed(pobj);
}
efl_event_callback_call(pobj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
}
EOLIAN static Eina_Bool
_efl_ui_pan_efl_content_content_set(Evas_Object *obj, Efl_Ui_Pan_Data *psd, Evas_Object *content)
{
Eina_Size2D sz;
if (content == psd->content) return EINA_TRUE;
if (psd->content)
{
efl_canvas_group_member_del(obj, psd->content);
evas_object_event_callback_del_full
(psd->content, EVAS_CALLBACK_DEL, _efl_ui_pan_content_del_cb, obj);
evas_object_event_callback_del_full
(psd->content, EVAS_CALLBACK_RESIZE, _efl_ui_pan_content_resize_cb,
obj);
psd->content = NULL;
psd->content_w = psd->content_h = psd->px = psd->py = 0;
}
if (!content) goto end;
psd->content = content;
efl_canvas_group_member_add(obj, content);
sz = efl_gfx_size_get(psd->content);
psd->content_w = sz.w;
psd->content_h = sz.h;
evas_object_event_callback_add
(content, EVAS_CALLBACK_DEL, _efl_ui_pan_content_del_cb, obj);
evas_object_event_callback_add
(content, EVAS_CALLBACK_RESIZE, _efl_ui_pan_content_resize_cb, obj);
if (evas_object_visible_get(obj))
evas_object_show(psd->content);
else
evas_object_hide(psd->content);
evas_object_smart_changed(obj);
end:
efl_event_callback_call(obj, EFL_UI_PAN_EVENT_CONTENT_CHANGED, NULL);
return EINA_TRUE;
}
EOLIAN static void
_efl_ui_pan_efl_canvas_group_group_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Pan_Data *psd)
{
efl_gfx_position_set(psd->content, EINA_POSITION2D(psd->x - psd->px, psd->y - psd->py));
}
#include "efl_ui_pan.eo.c"

View File

@ -0,0 +1,55 @@
class Efl.Ui.Pan (Efl.Canvas.Group,
Efl.Content)
{
[[Elementary pan class]]
methods {
@property pan_position {
[[Position]]
set {
}
get {
}
values {
position: Eina.Position2D;
}
}
@property content_size {
[[Content size]]
get {
}
values {
size: Eina.Size2D;
}
}
@property pan_position_min {
[[The minimal position to scroll]]
get {
}
values {
pos: Eina.Position2D;
}
}
@property pan_position_max {
[[The maximal position to scroll]]
get {
}
values {
pos: Eina.Position2D;
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Gfx.visible { set; }
Efl.Gfx.position { set; }
Efl.Gfx.size { set; }
Efl.Content.content { set; }
Efl.Canvas.Group.group_calculate;
}
events {
content,changed; [[Called when pan content changed]]
viewport,changed; [[Called when pan viewport changed]]
position,changed; [[Called when pan position changed]]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
class Efl.Ui.Scroll.Manager (Efl.Object,
Efl.Ui.Base,
Efl.Ui.Scrollable.Interactive,
Efl.Ui.Scrollbar)
{
[[Efl ui scroll manager class]]
event_prefix: efl_ui;
eo_prefix: efl_ui_scroll_manager;
methods {
@property pan @protected {
[[This is the internal canvas object managed by scroll manager.
This property is protected as it is meant for scrollable object
implementations only, to set and access the internal canvas object.
If pan is set to NULL, scrolling does not work.
]]
set {
}
values {
pan: Efl.Canvas.Object @nullable; [[Pan object]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Ui.Base.mirrored { set; }
Efl.Ui.Scrollable.Interactive.content_pos { set; get; }
Efl.Ui.Scrollable.Interactive.content_size{ get; }
Efl.Ui.Scrollable.Interactive.viewport_geometry{ get; }
Efl.Ui.Scrollable.Interactive.bounce_enabled { set; get; }
Efl.Ui.Scrollable.Interactive.scroll_freeze { get; set; }
Efl.Ui.Scrollable.Interactive.scroll_hold { get; set; }
Efl.Ui.Scrollable.Interactive.looping { get; set; }
Efl.Ui.Scrollable.Interactive.movement_block { get; set; }
Efl.Ui.Scrollable.Interactive.gravity { get; set; }
Efl.Ui.Scrollable.Interactive.match_content { set; }
Efl.Ui.Scrollbar.bar_mode { get; set; }
Efl.Ui.Scrollbar.bar_size { get; }
Efl.Ui.Scrollbar.bar_position { get; set; }
Efl.Ui.Scrollbar.bar_visibility_update;
Efl.Ui.Scrollable.Interactive.scroll;
}
}

View File

@ -0,0 +1,638 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#define ELM_LAYOUT_PROTECTED
#define EFL_UI_SCROLL_MANAGER_PROTECTED
#define EFL_UI_SCROLLBAR_PROTECTED
#define EFL_UI_SCROLLBAR_BETA
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_widget_scroller.h"
#include "elm_widget_layout.h"
#define MY_CLASS EFL_UI_SCROLLER_CLASS
#define MY_CLASS_PFX efl_ui_scroller
#define MY_CLASS_NAME "Efl.Ui.Scroller"
#define EFL_UI_SCROLLER_DATA_GET(o, sd) \
Efl_Ui_Scroller_Data * sd = efl_data_scope_safe_get(o, EFL_UI_SCROLLER_CLASS)
#define EFL_UI_SCROLLER_DATA_GET_OR_RETURN(o, ptr, ...) \
EFL_UI_SCROLLER_DATA_GET(o, ptr); \
if (EINA_UNLIKELY(!ptr)) \
{ \
CRI("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return __VA_ARGS__; \
}
static void
_efl_ui_scroller_content_del_cb(void *data,
const Efl_Event *event EINA_UNUSED)
{
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(data, sd);
sd->content = NULL;
if (!sd->smanager) return;
efl_ui_scrollbar_bar_visibility_update(sd->smanager);
}
EOLIAN static Eina_Bool
_efl_ui_scroller_efl_content_content_set(Eo *obj,
Efl_Ui_Scroller_Data *sd,
Evas_Object *content)
{
if (sd->content)
{
efl_content_set(sd->pan_obj, NULL);
efl_event_callback_del(sd->content, EFL_EVENT_DEL,
_efl_ui_scroller_content_del_cb, obj);
}
sd->content = content;
if (!content) return EINA_TRUE;
efl_event_callback_add(sd->content, EFL_EVENT_DEL,
_efl_ui_scroller_content_del_cb, obj);
efl_content_set(sd->pan_obj, content);
elm_layout_sizing_eval(obj);
return EINA_TRUE;
}
static void
_efl_ui_scroller_bar_read_and_update(Eo *obj)
{
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
double vx, vy;
edje_object_part_drag_value_get
(wd->resize_obj, "elm.dragable.vbar", NULL, &vy);
edje_object_part_drag_value_get
(wd->resize_obj, "elm.dragable.hbar", &vx, NULL);
efl_ui_scrollbar_bar_position_set(sd->smanager, vx, vy);
}
static void
_efl_ui_scroller_reload_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Eo *scroller = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(scroller, sd);
efl_ui_scrollbar_bar_visibility_update(sd->smanager);
}
static void
_efl_ui_scroller_vbar_drag_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
_efl_ui_scroller_bar_read_and_update(data);
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAG, &type);
}
static void
_efl_ui_scroller_vbar_press_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESS, &type);
}
static void
_efl_ui_scroller_vbar_unpress_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_VERTICAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESS, &type);
}
static void
_efl_ui_scroller_edje_drag_start_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Eo *scroller = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(scroller, sd);
_efl_ui_scroller_bar_read_and_update(scroller);
sd->freeze_want = efl_ui_scrollable_scroll_freeze_get(sd->smanager);
efl_ui_scrollable_scroll_freeze_set(sd->smanager, EINA_TRUE);
efl_event_callback_call(scroller, EFL_UI_EVENT_SCROLL_DRAG_START, NULL);
}
static void
_efl_ui_scroller_edje_drag_stop_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Eo *scroller = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(scroller, sd);
_efl_ui_scroller_bar_read_and_update(scroller);
efl_ui_scrollable_scroll_freeze_set(sd->smanager, sd->freeze_want);
efl_event_callback_call(scroller, EFL_UI_EVENT_SCROLL_DRAG_STOP, NULL);
}
static void
_efl_ui_scroller_edje_drag_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
_efl_ui_scroller_bar_read_and_update(data);
}
static void
_efl_ui_scroller_hbar_drag_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
_efl_ui_scroller_bar_read_and_update(data);
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_DRAG, &type);
}
static void
_efl_ui_scroller_hbar_press_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_PRESS, &type);
}
static void
_efl_ui_scroller_hbar_unpress_cb(void *data,
Evas_Object *obj EINA_UNUSED,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
Efl_Ui_Scrollbar_Direction type = EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL;
efl_event_callback_call(data, EFL_UI_SCROLLBAR_EVENT_BAR_UNPRESS, &type);
}
static void
_efl_ui_scroller_bar_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *obj = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
double width = 0.0, height = 0.0;
edje_object_calc_force(wd->resize_obj);
efl_ui_scrollbar_bar_size_get(sd->smanager, &width, &height);
edje_object_part_drag_size_set(wd->resize_obj, "elm.dragable.hbar", width, 1.0);
edje_object_part_drag_size_set(wd->resize_obj, "elm.dragable.vbar", 1.0, height);
}
static void
_efl_ui_scroller_bar_pos_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *obj = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
double posx = 0.0, posy = 0.0;
efl_ui_scrollbar_bar_position_get(sd->smanager, &posx, &posy);
edje_object_part_drag_value_set(wd->resize_obj, "elm.dragable.hbar", posx, 0.0);
edje_object_part_drag_value_set(wd->resize_obj, "elm.dragable.vbar", 0.0, posy);
}
static void
_efl_ui_scroller_bar_show_cb(void *data, const Efl_Event *event)
{
Eo *obj = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
Efl_Ui_Scrollbar_Direction type = *(Efl_Ui_Scrollbar_Direction *)(event->info);
if (type == EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL)
edje_object_signal_emit(wd->resize_obj, "elm,action,show,hbar", "elm");
else if (type == EFL_UI_SCROLLBAR_DIRECTION_VERTICAL)
edje_object_signal_emit(wd->resize_obj, "elm,action,show,vbar", "elm");
}
static void
_efl_ui_scroller_bar_hide_cb(void *data, const Efl_Event *event)
{
Eo *obj = data;
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
Efl_Ui_Scrollbar_Direction type = *(Efl_Ui_Scrollbar_Direction *)(event->info);
if (type == EFL_UI_SCROLLBAR_DIRECTION_HORIZONTAL)
edje_object_signal_emit(wd->resize_obj, "elm,action,hide,hbar", "elm");
else if (type == EFL_UI_SCROLLBAR_DIRECTION_VERTICAL)
edje_object_signal_emit(wd->resize_obj, "elm,action,hide,vbar", "elm");
}
static void
_scroll_edje_object_attach(Eo *obj)
{
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
efl_layout_signal_callback_add
(obj, "reload", "elm", _efl_ui_scroller_reload_cb, obj);
efl_layout_signal_callback_add
(obj, "drag", "elm.dragable.vbar", _efl_ui_scroller_vbar_drag_cb,
obj);
efl_layout_signal_callback_add
(obj, "drag,set", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,start", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_start_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,stop", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_stop_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,step", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,page", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "elm,vbar,press", "elm",
_efl_ui_scroller_vbar_press_cb, obj);
efl_layout_signal_callback_add
(obj, "elm,vbar,unpress", "elm",
_efl_ui_scroller_vbar_unpress_cb, obj);
efl_layout_signal_callback_add
(obj, "drag", "elm.dragable.hbar", _efl_ui_scroller_hbar_drag_cb,
obj);
efl_layout_signal_callback_add
(obj, "drag,set", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,start", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_start_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,stop", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_stop_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,step", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "drag,page", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_add
(obj, "elm,hbar,press", "elm",
_efl_ui_scroller_hbar_press_cb, obj);
efl_layout_signal_callback_add
(obj, "elm,hbar,unpress", "elm",
_efl_ui_scroller_hbar_unpress_cb, obj);
}
static void
_scroll_edje_object_detach(Evas_Object *obj)
{
EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, sd);
efl_layout_signal_callback_del
(obj, "reload", "elm", _efl_ui_scroller_reload_cb, obj);
efl_layout_signal_callback_del
(obj, "drag", "elm.dragable.vbar", _efl_ui_scroller_vbar_drag_cb,
obj);
efl_layout_signal_callback_del
(obj, "drag,set", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,start", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_start_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,stop", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_stop_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,step", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,page", "elm.dragable.vbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "elm,vbar,press", "elm",
_efl_ui_scroller_vbar_press_cb, obj);
efl_layout_signal_callback_del
(obj, "elm,vbar,unpress", "elm",
_efl_ui_scroller_vbar_unpress_cb, obj);
efl_layout_signal_callback_del
(obj, "drag", "elm.dragable.hbar", _efl_ui_scroller_hbar_drag_cb,
obj);
efl_layout_signal_callback_del
(obj, "drag,set", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,start", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_start_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,stop", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_stop_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,step", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "drag,page", "elm.dragable.hbar",
_efl_ui_scroller_edje_drag_cb, obj);
efl_layout_signal_callback_del
(obj, "elm,hbar,press", "elm",
_efl_ui_scroller_hbar_press_cb, obj);
efl_layout_signal_callback_del
(obj, "elm,hbar,unpress", "elm",
_efl_ui_scroller_hbar_unpress_cb, obj);
}
static void
_efl_ui_scroller_pan_resized_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
elm_layout_sizing_eval(data);
}
static void
_efl_ui_scroller_resized_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
elm_layout_sizing_eval(data);
}
static void
_efl_ui_scroller_size_hint_changed_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
elm_layout_sizing_eval(data);
}
EOLIAN static Eo *
_efl_ui_scroller_efl_object_constructor(Eo *obj,
Efl_Ui_Scroller_Data *sd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
return obj;
}
EOLIAN static Eo *
_efl_ui_scroller_efl_object_finalize(Eo *obj,
Efl_Ui_Scroller_Data *sd EINA_UNUSED)
{
obj = efl_finalize(efl_super(obj, MY_CLASS));
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
efl_ui_layout_theme_set(obj, "scroller", "base", efl_ui_widget_style_get(obj));
sd->smanager = efl_add(EFL_UI_SCROLL_MANAGER_CLASS, obj);
efl_ui_mirrored_set(sd->smanager, efl_ui_mirrored_get(obj));
sd->pan_obj = efl_add(EFL_UI_PAN_CLASS, obj);
efl_ui_scroll_manager_pan_set(sd->smanager, sd->pan_obj);
edje_object_part_swallow(wd->resize_obj, "elm.swallow.content", sd->pan_obj);
_scroll_edje_object_attach(obj);
efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
_efl_ui_scroller_bar_size_changed_cb, obj);
efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
_efl_ui_scroller_bar_pos_changed_cb, obj);
efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
_efl_ui_scroller_bar_show_cb, obj);
efl_event_callback_add(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
_efl_ui_scroller_bar_hide_cb, obj);
efl_event_callback_add(obj, EFL_GFX_EVENT_RESIZE,
_efl_ui_scroller_resized_cb, obj);
efl_event_callback_add(obj, EFL_GFX_EVENT_CHANGE_SIZE_HINTS,
_efl_ui_scroller_size_hint_changed_cb, obj);
efl_event_callback_add(sd->pan_obj, EFL_GFX_EVENT_RESIZE,
_efl_ui_scroller_pan_resized_cb, obj);
return obj;
}
EOLIAN static void
_efl_ui_scroller_efl_object_destructor(Eo *obj,
Efl_Ui_Scroller_Data *sd EINA_UNUSED)
{
_scroll_edje_object_detach(obj);
efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
_efl_ui_scroller_bar_size_changed_cb, obj);
efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
_efl_ui_scroller_bar_pos_changed_cb, obj);
efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
_efl_ui_scroller_bar_show_cb, obj);
efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
_efl_ui_scroller_bar_hide_cb, obj);
efl_event_callback_del(obj, EFL_GFX_EVENT_RESIZE,
_efl_ui_scroller_resized_cb, obj);
efl_event_callback_del(obj, EFL_GFX_EVENT_CHANGE_SIZE_HINTS,
_efl_ui_scroller_size_hint_changed_cb, obj);
efl_event_callback_del(sd->pan_obj, EFL_GFX_EVENT_RESIZE,
_efl_ui_scroller_pan_resized_cb, obj);
efl_del(sd->pan_obj);
sd->pan_obj = NULL;
efl_del(sd->smanager);
sd->smanager = NULL;
efl_destructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_efl_ui_scroller_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Scroller_Data *sd)
{
Eina_Size2D min = {0, 0}, max = {0, 0}, size = {-1, -1};
Eina_Rect view = {};
Evas_Coord vmw = 0, vmh = 0;
double xw = 0.0, yw = 0.0;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
if (sd->content)
{
min = efl_gfx_size_hint_combined_min_get(sd->content);
max = efl_gfx_size_hint_max_get(sd->content);
efl_gfx_size_hint_weight_get(sd->content, &xw, &yw);
}
if (sd->smanager)
view = efl_ui_scrollable_viewport_geometry_get(sd->smanager);
if (xw > 0.0)
{
if ((min.w > 0) && (view.w < min.w))
view.w = min.w;
else if ((max.w > 0) && (view.w > max.w))
view.w = max.w;
}
else if (min.w > 0)
view.w = min.w;
if (yw > 0.0)
{
if ((min.h > 0) && (view.h < min.h))
view.h = min.h;
else if ((max.h > 0) && (view.h > max.h))
view.h = max.h;
}
else if (min.h > 0)
view.h = min.h;
if (sd->content) efl_gfx_size_set(sd->content, EINA_SIZE2D(view.w, view.h));
edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh);
if (sd->match_content_w) size.w = vmw + min.w;
if (sd->match_content_h) size.h = vmh + min.h;
max = efl_gfx_size_hint_max_get(obj);
if ((max.w > 0) && (size.w > max.w)) size.w = max.w;
if ((max.h > 0) && (size.h > max.h)) size.h = max.h;
efl_gfx_size_hint_min_set(obj, size);
}
EOLIAN static Efl_Ui_Theme_Apply
_efl_ui_scroller_elm_widget_theme_apply(Eo *obj, Efl_Ui_Scroller_Data *sd)
{
Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED;
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
efl_ui_mirrored_set(sd->smanager, efl_ui_mirrored_get(obj));
elm_layout_sizing_eval(obj);
return int_ret;
}
EOLIAN static Eina_Size2D
_efl_ui_scroller_efl_ui_scrollable_interactive_content_size_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd)
{
return efl_ui_scrollable_content_size_get(sd->smanager);
}
EOLIAN static Eina_Rect
_efl_ui_scroller_efl_ui_scrollable_interactive_viewport_geometry_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd)
{
return efl_ui_scrollable_viewport_geometry_get(sd->smanager);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_bounce_enabled_set(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Bool horiz,
Eina_Bool vert)
{
efl_ui_scrollable_bounce_enabled_set(sd->smanager, horiz, vert);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_bounce_enabled_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Bool *horiz,
Eina_Bool *vert)
{
efl_ui_scrollable_bounce_enabled_get(sd->smanager, horiz, vert);
}
EOLIAN static Eina_Bool
_efl_ui_scroller_efl_ui_scrollable_interactive_scroll_hold_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd)
{
return efl_ui_scrollable_scroll_hold_get(sd->smanager);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_scroll_hold_set(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Bool hold)
{
efl_ui_scrollable_scroll_hold_set(sd->smanager, hold);
}
EOLIAN static Eina_Bool
_efl_ui_scroller_efl_ui_scrollable_interactive_scroll_freeze_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd)
{
return efl_ui_scrollable_scroll_freeze_get(sd->smanager);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_scroll_freeze_set(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Bool freeze)
{
efl_ui_scrollable_scroll_freeze_set(sd->smanager, freeze);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_match_content_set(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Bool match_content_w,
Eina_Bool match_content_h)
{
sd->match_content_w = !!match_content_w;
sd->match_content_h = !!match_content_h;
efl_ui_scrollable_match_content_set(sd->smanager, match_content_w, match_content_h);
elm_layout_sizing_eval(obj);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollbar_bar_mode_set(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Efl_Ui_Scrollbar_Mode hmode,
Efl_Ui_Scrollbar_Mode vmode)
{
efl_ui_scrollbar_bar_mode_set(sd->smanager, hmode, vmode);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollbar_bar_mode_get(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Efl_Ui_Scrollbar_Mode *hmode,
Efl_Ui_Scrollbar_Mode *vmode)
{
efl_ui_scrollbar_bar_mode_get(sd->smanager, hmode, vmode);
}
EOLIAN static void
_efl_ui_scroller_efl_ui_scrollable_interactive_scroll(Eo *obj EINA_UNUSED,
Efl_Ui_Scroller_Data *sd,
Eina_Rect rc,
Eina_Bool animation)
{
efl_ui_scrollable_scroll(sd->smanager, rc, animation);
}
/* Internal EO APIs and hidden overrides */
#define EFL_UI_SCROLLER_EXTRA_OPS \
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_scroller)
#include "efl_ui_scroller.eo.c"

View File

@ -0,0 +1,23 @@
class Efl.Ui.Scroller (Efl.Ui.Layout,
Efl.Ui.Scrollable.Interactive,
Efl.Ui.Scrollbar,
Efl.Content,
Efl.Ui.Drag)
{
[[Efl ui scroller class]]
implements {
Efl.Object.constructor;
Efl.Object.finalize;
Efl.Object.destructor;
Efl.Content.content { set; }
Elm.Widget.theme_apply;
Efl.Ui.Scrollable.Interactive.content_size{ get; }
Efl.Ui.Scrollable.Interactive.viewport_geometry{ get; }
Efl.Ui.Scrollable.Interactive.bounce_enabled { set; get; }
Efl.Ui.Scrollable.Interactive.scroll_freeze { get; set; }
Efl.Ui.Scrollable.Interactive.scroll_hold { get; set; }
Efl.Ui.Scrollable.Interactive.match_content { set; }
Efl.Ui.Scrollbar.bar_mode { get; set; }
Efl.Ui.Scrollable.Interactive.scroll;
}
}

View File

@ -0,0 +1,14 @@
#ifndef EFL_UI_WIDGET_PAN_H
#define EFL_UI_WIDGET_PAN_H
#include "Elementary.h"
typedef struct _Efl_Ui_Pan_Data Efl_Ui_Pan_Data;
struct _Efl_Ui_Pan_Data
{
Evas_Object *content;
Evas_Coord x, y, w, h;
Evas_Coord content_w, content_h, px, py;
};
#endif

View File

@ -0,0 +1,135 @@
#ifndef EFL_UI_WIDGET_SCROLL_MANAGER_H
#define EFL_UI_WIDGET_SCROLL_MANAGER_H
#include "Elementary.h"
typedef double (*Interpolator)(void *data, double progress);
typedef enum {
LINEAR,
ACCEL,
DECEL,
} InterpType;
typedef struct _Efl_Ui_Scroll_Manager_Data
{
Evas_Coord x, y, w, h;
Evas_Coord wx, wy, ww, wh; /**< Last "wanted" geometry */
Evas_Object *obj;
Evas_Object *pan_obj;
Evas_Object *event_rect;
Evas_Object *parent;
Efl_Ui_Scrollbar_Mode hbar_mode, vbar_mode;
Ecore_Timer *hbar_timer, *vbar_timer;
Efl_Ui_Scroll_Block block;
struct
{
Evas_Coord x, y;
Evas_Coord sx, sy;
struct
{
Evas_Coord x, y;
double timestamp, localtimestamp;
} history[60];
struct
{
double tadd, dxsum, dysum;
double est_timestamp_diff;
} hist;
double onhold_vx, onhold_vy;
double onhold_vxe, onhold_vye;
double onhold_tlast;
double last_time_x_wheel;
double last_time_y_wheel;
int hdir, vdir;
Evas_Coord hold_x, hold_y;
Ecore_Idle_Enterer *hold_enterer;
double dragged_began_timestamp;
Eina_Bool dragged : 1;
Eina_Bool dragged_began : 1;
Eina_Bool hold_animator : 1;
Eina_Bool onhold_animator : 1;
Eina_Bool last_hold_x_wheel : 1;
Eina_Bool last_hold_y_wheel : 1;
Eina_Bool dir_x : 1;
Eina_Bool dir_y : 1;
Eina_Bool scroll : 1;
Eina_Bool hold : 1;
Eina_Bool now : 1;
Eina_Bool want_reset : 1;
} down;
struct
{
Evas_Coord w, h;
Eina_Bool resized : 1;
} content_info;
struct
{
Evas_Coord x, y;
} step, page;
struct
{
struct
{
Evas_Coord start, end;
Eina_Bool animator;
Interpolator interp;
double start_t, dur;
} x, y;
} scrollto;
struct
{
struct
{
Evas_Coord p0, p1, p2;
double vel;
Eina_Bool animator;
double start_t;
double t01, t12;
} x, y;
} bounce;
double last_wheel_mul;
unsigned int last_wheel;
void *event_info;
double gravity_x, gravity_y;
Evas_Coord prev_cw, prev_ch;
Eina_Bool hbar_visible : 1;
Eina_Bool vbar_visible : 1;
Eina_Bool bounce_horiz : 1;
Eina_Bool bounce_vert : 1;
Eina_Bool is_mirrored : 1;
Eina_Bool bouncemey : 1;
Eina_Bool bouncemex : 1;
Eina_Bool freeze : 1;
Eina_Bool freeze_want : 1;
Eina_Bool hold : 1;
Eina_Bool match_content_w : 1;
Eina_Bool match_content_h : 1;
Eina_Bool loop_h : 1;
Eina_Bool loop_v : 1;
Eina_Bool scrolling : 1;
} Efl_Ui_Scroll_Manager_Data;
#endif

View File

@ -0,0 +1,17 @@
#ifndef EFL_UI_WIDGET_SCROLLER_H
#define EFL_UI_WIDGET_SCROLLER_H
#include "Elementary.h"
typedef struct _Efl_Ui_Scroller_Data
{
Eo *content;
Eo *pan_obj;
Eo *smanager;
Eina_Bool freeze_want : 1;
Eina_Bool match_content_w: 1;
Eina_Bool match_content_h: 1;
} Efl_Ui_Scroller_Data;
#endif