discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=adf0015cd8b4449aae4fc6ca67d8d44a660fcb8b
commit adf0015cd8b4449aae4fc6ca67d8d44a660fcb8b Author: Mike Blumenkrantz <[email protected]> Date: Wed Feb 14 21:14:52 2018 -0500 elm_map: use Efl.Ui.Zoom for zoom properties --- src/lib/elementary/elm_map.c | 52 ++++++++++-------- src/lib/elementary/elm_map.eo | 91 ++----------------------------- src/lib/elementary/elm_map_legacy.h | 105 ++++++++++++++++++++++++++++++++++++ src/lib/elementary/elm_widget_map.h | 2 +- 4 files changed, 139 insertions(+), 111 deletions(-) diff --git a/src/lib/elementary/elm_map.c b/src/lib/elementary/elm_map.c index fcdee6acc8..fa0a22f984 100644 --- a/src/lib/elementary/elm_map.c +++ b/src/lib/elementary/elm_map.c @@ -324,9 +324,6 @@ static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start"; static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop"; static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start"; static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop"; -static const char SIG_ZOOM_START[] = "zoom,start"; -static const char SIG_ZOOM_STOP[] = "zoom,stop"; -static const char SIG_ZOOM_CHANGE[] = "zoom,change"; static const char SIG_LOADED[] = "loaded"; static const char SIG_TILE_LOAD[] = "tile,load"; static const char SIG_TILE_LOADED[] = "tile,loaded"; @@ -350,9 +347,6 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {SIG_SCROLL_DRAG_STOP, ""}, {SIG_SCROLL_ANIM_START, ""}, {SIG_SCROLL_ANIM_STOP, ""}, - {SIG_ZOOM_START, ""}, - {SIG_ZOOM_STOP, ""}, - {SIG_ZOOM_CHANGE, ""}, {SIG_LOADED, ""}, {SIG_TILE_LOAD, ""}, {SIG_TILE_LOADED, ""}, @@ -1153,7 +1147,7 @@ _zoom_do(Elm_Map_Data *sd, if (sd->obj) sd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout_cb, sd->obj); efl_event_callback_legacy_call - (sd->obj, ELM_MAP_EVENT_ZOOM_CHANGE, NULL); + (sd->obj, EFL_UI_EVENT_ZOOM_CHANGE, NULL); efl_event_callback_legacy_call (sd->pan_obj, ELM_PAN_EVENT_CHANGED, NULL); @@ -3737,7 +3731,7 @@ _zoom_mode_set(Elm_Map_Data *sd, double zoom) { EINA_SAFETY_ON_NULL_RETURN(sd); - if (sd->mode == ELM_MAP_ZOOM_MODE_MANUAL) + if (sd->mode == EFL_UI_ZOOM_MODE_MANUAL) { if (sd->paused) _zoom_do(sd, zoom); else _zoom_with_animation(sd, zoom, 10); @@ -3752,7 +3746,7 @@ _zoom_mode_set(Elm_Map_Data *sd, double zoom) h = sd->size.h; _viewport_coord_get(sd, NULL, NULL, &vw, &vh); - if (sd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT) + if (sd->mode == EFL_UI_ZOOM_MODE_AUTO_FIT) { if ((w < vw) && (h < vh)) { @@ -3776,7 +3770,7 @@ _zoom_mode_set(Elm_Map_Data *sd, double zoom) zoom -= diff; } } - else if (sd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL) + else if (sd->mode == EFL_UI_ZOOM_MODE_AUTO_FILL) { if ((w < vw) || (h < vh)) { @@ -3914,7 +3908,7 @@ _elm_map_pan_efl_gfx_size_set(Eo *obj, Elm_Map_Pan_Data *psd, Eina_Size2D sz) efl_gfx_size_set(efl_super(obj, MY_PAN_CLASS), sz); _sizing_eval(psd->wsd->obj); - elm_map_zoom_mode_set(psd->wobj, psd->wsd->mode); + efl_ui_zoom_mode_set(psd->wobj, psd->wsd->mode); evas_object_smart_changed(obj); } @@ -4171,7 +4165,7 @@ _elm_map_efl_canvas_group_group_add(Eo *obj, Elm_Map_Data *priv) _zoom_do(priv, 0); - priv->mode = ELM_MAP_ZOOM_MODE_MANUAL; + priv->mode = EFL_UI_ZOOM_MODE_MANUAL; if (!elm_need_efreet()) ERR("Efreet initialization failed!"); @@ -4301,12 +4295,12 @@ _elm_map_efl_object_constructor(Eo *obj, Elm_Map_Data *sd) } EOLIAN static void -_elm_map_zoom_set(Eo *obj, Elm_Map_Data *sd, int zoom) +_elm_map_efl_ui_zoom_zoom_level_set(Eo *obj, Elm_Map_Data *sd, double zoom) { ELM_MAP_CHECK(obj); EINA_SAFETY_ON_NULL_RETURN(sd->src_tile); - if (sd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return; + if (sd->mode != EFL_UI_ZOOM_MODE_MANUAL) return; if (zoom < 0) zoom = 0; if (sd->zoom == zoom) return; @@ -4314,30 +4308,44 @@ _elm_map_zoom_set(Eo *obj, Elm_Map_Data *sd, int zoom) sd->calc_job.zoom_mode_set = _zoom_mode_set; evas_object_smart_changed(sd->pan_obj); + efl_ui_zoom_level_set(efl_super(obj, MY_CLASS), zoom); } -EOLIAN static int -_elm_map_zoom_get(Eo *obj EINA_UNUSED, Elm_Map_Data *sd) +EAPI void +elm_map_zoom_set(Eo *obj, int zoom) +{ + efl_ui_zoom_level_set(obj, zoom); +} + +EAPI int +elm_map_zoom_get(const Eo *obj) { - return sd->zoom; + return efl_ui_zoom_level_get(obj); } EOLIAN static void -_elm_map_zoom_mode_set(Eo *obj EINA_UNUSED, Elm_Map_Data *sd, Elm_Map_Zoom_Mode mode) +_elm_map_efl_ui_zoom_zoom_mode_set(Eo *obj, Elm_Map_Data *sd, Efl_Ui_Zoom_Mode mode) { - if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (sd->mode == !!mode)) return; + if ((mode == EFL_UI_ZOOM_MODE_MANUAL) && (sd->mode == !!mode)) return; sd->mode = mode; sd->calc_job.zoom = sd->zoom_detail; sd->calc_job.zoom_mode_set = _zoom_mode_set; evas_object_smart_changed(sd->pan_obj); + efl_ui_zoom_mode_set(efl_super(obj, MY_CLASS), mode); +} + +EAPI void +elm_map_zoom_mode_set(Eo *obj, Elm_Map_Zoom_Mode mode) +{ + efl_ui_zoom_mode_set(obj, mode); } -EOLIAN static Elm_Map_Zoom_Mode -_elm_map_zoom_mode_get(Eo *obj EINA_UNUSED, Elm_Map_Data *sd) +EAPI Elm_Map_Zoom_Mode +elm_map_zoom_mode_get(const Eo *obj) { - return sd->mode; + return efl_ui_zoom_mode_get(obj); } EOLIAN static void diff --git a/src/lib/elementary/elm_map.eo b/src/lib/elementary/elm_map.eo index 9c4d68d162..e70b8f6f8a 100644 --- a/src/lib/elementary/elm_map.eo +++ b/src/lib/elementary/elm_map.eo @@ -6,27 +6,6 @@ type Elm_Map_Name: __undefined_type; [[Elementary map name type]] type Elm_Map_Name_Cb: __undefined_type; [[Elementary map name callback type]] type Elm_Map_Name_List_Cb: __undefined_type; [[Elementary map name list callback type]] -enum Elm.Map.Zoom_Mode -{ - [[ - Set map's zoom behavior. It can be set to manual or automatic. - - Default value is #ELM_MAP_ZOOM_MODE_MANUAL. - - Values <b> don't </b> work as bitmask, only one can be chosen. - - Valid sizes are 2^zoom, consequently the map may be smaller - than the scroller view. - - See @Elm.Map.zoom_mode.set() - See @Elm.Map.zoom_mode.get() - ]] - manual, [[Zoom controlled manually by elm_map_zoom_set(). It's set by default.]] - auto_fit, [[Zoom until map fits inside the scroll frame with no pixels outside this area.]] - auto_fill, [[Zoom until map fills scroll, ensuring no pixels are left unfilled.]] - last [[Sentinel value to indicate last enum field during iteration]] -} - enum Elm.Map.Source_Type { [[ @@ -71,44 +50,13 @@ enum Elm.Map.Route_Method class Elm.Map (Efl.Ui.Widget, Elm.Interface_Scrollable, Efl.Access.Widget.Action, - Efl.Ui.Clickable, Efl.Ui.Legacy) + Efl.Ui.Clickable, Efl.Ui.Legacy, Efl.Ui.Zoom) { [[Elementary map class]] legacy_prefix: elm_map; eo_prefix: elm_obj_map; event_prefix: elm_map; methods { - @property zoom { - set { - [[Set the zoom level of the map. - - This sets the zoom level. - - It will respect limits defined by @.zoom_min.set and - @.zoom_max.set. - - By default these values are 0 (world map) and 18 (maximum zoom). - - This function should be used when zoom mode is set to - #ELM_MAP_ZOOM_MODE_MANUAL. This is the default mode, and - can be set with @.zoom_mode.set. - ]] - } - get { - [[Get the zoom level of the map. - - This returns the current zoom level of the map object. - - Note that if you set the fill mode to other than - #ELM_MAP_ZOOM_MODE_MANUAL (which is the default), the zoom - level may be changed at any time by the map object itself - to account for map size and map viewport size. - ]] - } - values { - zoom: int; [[The zoom level.]] - } - } @property paused { set { [[Pause or unpause the map. @@ -209,40 +157,6 @@ class Elm.Map (Efl.Ui.Widget, Elm.Interface_Scrollable, zoom: int(-1); [[Maximum zoom value to be used.]] } } - @property zoom_mode { - set { - [[Set the zoom mode used by the map object. - - This sets the zoom mode to manual or one of the automatic - levels. Manual (#ELM_MAP_ZOOM_MODE_MANUAL) means that zoom - is set manually by @.zoom_mode.set and will stay at that - level until changed by code or until zoom mode is changed. - This is the default mode. - - The Automatic modes will allow the map object to - automatically adjust zoom mode based on properties. - #ELM_MAP_ZOOM_MODE_AUTO_FIT will adjust zoom so the map - fits inside the scroll frame with no pixels outside this - area. #ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but - ensure no pixels within the frame are left unfilled. Do not - forget that the valid sizes are 2^zoom, consequently the map - may be smaller than the scroller view. - ]] - } - get { - [[Get the zoom mode used by the map object. - - This function returns the current zoom mode used by the ma - object. - ]] - } - values { - mode: Elm.Map.Zoom_Mode; [[The zoom mode of the map, being it - one of #ELM_MAP_ZOOM_MODE_MANUAL - (default), #ELM_MAP_ZOOM_MODE_AUTO_FIT, - or #ELM_MAP_ZOOM_MODE_AUTO_FILL.]] - } - } @property region { get { [[Get the current geographic coordinates of the map. @@ -634,10 +548,11 @@ class Elm.Map (Efl.Ui.Widget, Elm.Interface_Scrollable, Efl.Ui.Focus.Object.on_focus_update; Efl.Ui.Widget.widget_event; Efl.Access.Widget.Action.elm_actions { get; } + Efl.Ui.Zoom.zoom_level { set; } + Efl.Ui.Zoom.zoom_mode { set; } } events { press; [[Called when map was pressed]] - zoom,change; [[Called when map zoom changed]] loaded; [[Called when map loaded]] tile,load; [[Called when title load started]] tile,loaded; [[Called when title load finished]] diff --git a/src/lib/elementary/elm_map_legacy.h b/src/lib/elementary/elm_map_legacy.h index ff0facdb93..993bc966f7 100644 --- a/src/lib/elementary/elm_map_legacy.h +++ b/src/lib/elementary/elm_map_legacy.h @@ -1,3 +1,30 @@ + +/** + * @brief Set map's zoom behavior. It can be set to manual or automatic. + * + * Default value is #ELM_MAP_ZOOM_MODE_MANUAL. + * + * Values <b> don't </b> work as bitmask, only one can be chosen. + * + * Valid sizes are 2^zoom, consequently the map may be smaller than the + * scroller view. + * + * See @ref elm_map_zoom_mode_set() See @ref elm_map_zoom_mode_get() + * + * @ingroup Elm_Map + */ +typedef enum +{ + ELM_MAP_ZOOM_MODE_MANUAL = 0, /**< Zoom controlled manually by + * elm_map_zoom_set(). It's set by default. */ + ELM_MAP_ZOOM_MODE_AUTO_FIT, /**< Zoom until map fits inside the scroll frame + * with no pixels outside this area. */ + ELM_MAP_ZOOM_MODE_AUTO_FILL, /**< Zoom until map fills scroll, ensuring no + * pixels are left unfilled. */ + ELM_MAP_ZOOM_MODE_LAST /**< Sentinel value to indicate last enum field during + * iteration */ +} Elm_Map_Zoom_Mode; + /** * Add a new map widget to the given parent Elementary (container) object. * @@ -10,4 +37,82 @@ */ EAPI Evas_Object *elm_map_add(Evas_Object *parent); + +/** + * @brief Set the zoom level of the map. + * + * This sets the zoom level. + * + * It will respect limits defined by @ref elm_map_zoom_min_set and + * @ref elm_map_zoom_max_set. + * + * By default these values are 0 (world map) and 18 (maximum zoom). + * + * This function should be used when zoom mode is set to + * #ELM_MAP_ZOOM_MODE_MANUAL. This is the default mode, and can be set with + * @ref elm_map_zoom_mode_set. + * + * @param[in] obj The object. + * @param[in] zoom The zoom level. + * + * @ingroup Elm_Map + */ +EAPI void elm_map_zoom_set(Evas_Object *obj, int zoom); + +/** + * @brief Get the zoom level of the map. + * + * This returns the current zoom level of the map object. + * + * Note that if you set the fill mode to other than #ELM_MAP_ZOOM_MODE_MANUAL + * (which is the default), the zoom level may be changed at any time by the map + * object itself to account for map size and map viewport size. + * + * @param[in] obj The object. + * + * @return The zoom level. + * + * @ingroup Elm_Map + */ +EAPI int elm_map_zoom_get(const Evas_Object *obj); + + +/** + * @brief Set the zoom mode used by the map object. + * + * This sets the zoom mode to manual or one of the automatic levels. Manual + * (#ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by + * @ref elm_map_zoom_mode_set and will stay at that level until changed by code + * or until zoom mode is changed. This is the default mode. + * + * The Automatic modes will allow the map object to automatically adjust zoom + * mode based on properties. #ELM_MAP_ZOOM_MODE_AUTO_FIT will adjust zoom so + * the map fits inside the scroll frame with no pixels outside this area. + * #ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but ensure no pixels within the + * frame are left unfilled. Do not forget that the valid sizes are 2^zoom, + * consequently the map may be smaller than the scroller view. + * + * @param[in] obj The object. + * @param[in] mode The zoom mode of the map, being it one of + * #ELM_MAP_ZOOM_MODE_MANUAL (default), #ELM_MAP_ZOOM_MODE_AUTO_FIT, or + * #ELM_MAP_ZOOM_MODE_AUTO_FILL. + * + * @ingroup Elm_Map + */ +EAPI void elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode); + +/** + * @brief Get the zoom mode used by the map object. + * + * This function returns the current zoom mode used by the ma object. + * + * @param[in] obj The object. + * + * @return The zoom mode of the map, being it one of #ELM_MAP_ZOOM_MODE_MANUAL + * (default), #ELM_MAP_ZOOM_MODE_AUTO_FIT, or #ELM_MAP_ZOOM_MODE_AUTO_FILL. + * + * @ingroup Elm_Map + */ +EAPI Elm_Map_Zoom_Mode elm_map_zoom_mode_get(const Evas_Object *obj); + #include "elm_map.eo.legacy.h" diff --git a/src/lib/elementary/elm_widget_map.h b/src/lib/elementary/elm_widget_map.h index 1cd4c183c4..7c569a42ec 100644 --- a/src/lib/elementary/elm_widget_map.h +++ b/src/lib/elementary/elm_widget_map.h @@ -441,7 +441,7 @@ struct _Elm_Map_Data int tile; // Current pixel size of a grid item } size; - Elm_Map_Zoom_Mode mode; + Efl_Ui_Zoom_Mode mode; struct { --
