From 88caf37e1b4fc6fc12b366cfab9c1c92f5500c50 Mon Sep 17 00:00:00 2001 From: Vyacheslav Reutskiy Date: Tue, 17 Jun 2014 10:23:30 +0900 Subject: [PATCH] Elementary/Panes: update functionality (add new 8 API functions) Summary: Added possibility to set the minimum size of the left and right sides. Reviewers: raster, cedric, seoz, Hermet Differential Revision: https://phab.enlightenment.org/D998 --- data/themes/edc/elm/panes.edc | 113 +++++++++++++++++++++++++++++-- src/lib/elm_panes.c | 153 ++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_panes.eo | 116 ++++++++++++++++++++++++++++++++ src/lib/elm_panes_eo.h | 2 +- src/lib/elm_panes_legacy.h | 2 +- src/lib/elm_widget_panes.h | 6 ++ 6 files changed, 386 insertions(+), 6 deletions(-) diff --git a/data/themes/edc/elm/panes.edc b/data/themes/edc/elm/panes.edc index 63f1166..84aa3b4 100644 --- a/data/themes/edc/elm/panes.edc +++ b/data/themes/edc/elm/panes.edc @@ -9,6 +9,32 @@ group { name: "elm/panes/vertical/default"; description { state: "default" 0.0; } } + part { name: "right_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "left_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "sub_whole"; type: SPACER; + description { state: "default" 0.0; + rel1.relative: 1.0 0.0; + rel1.to_x: "left_constraint"; + rel2.relative: 0.0 1.0; + rel2.to_x: "right_constraint"; + } + } part { name: "whole_left"; type: RECT; description { state: "default" 0.0; rel2.to_x: "elm.bar"; @@ -40,7 +66,7 @@ group { name: "elm/panes/vertical/default"; } } part { name: "elm.bar"; type: SPACER; - dragable { confine: "whole"; + dragable { confine: "sub_whole"; x: 1 1 1; y: 0 0 0; } @@ -104,6 +130,32 @@ group { name: "elm/panes/horizontal/default"; description { state: "default" 0.0; } } + part { name: "right_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 0 0 0; + y: 1 1 1; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "left_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 0 0 0; + y: 1 1 1; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "sub_whole"; type: SPACER; + description { state: "default" 0.0; + rel1.relative: 0.0 1.0; + rel1.to_y: "left_constraint"; + rel2.relative: 1.0 0.0; + rel2.to_y: "right_constraint"; + } + } part { name: "whole_left"; type: RECT; description { state: "default" 0.0; rel2.to_y: "elm.bar"; @@ -135,7 +187,7 @@ group { name: "elm/panes/horizontal/default"; } } part { name: "elm.bar"; type: SPACER; - dragable { confine: "whole"; + dragable { confine: "sub_whole"; x: 0 0 0; y: 1 1 1; } @@ -194,6 +246,7 @@ group { name: "elm/panes/horizontal/default"; //////////////////////////////////////////////////////////////////////////// + group { name: "elm/panes/vertical/flush"; images.image: "downlight_glow_left.png" COMP; images.image: "downlight_glow_right.png" COMP; @@ -202,6 +255,32 @@ group { name: "elm/panes/vertical/flush"; description { state: "default" 0.0; } } + part { name: "right_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "left_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "sub_whole"; type: SPACER; + description { state: "default" 0.0; + rel1.relative: 1.0 0.0; + rel1.to_x: "left_constraint"; + rel2.relative: 0.0 1.0; + rel2.to_x: "right_constraint"; + } + } part { name: "whole_left"; type: RECT; description { state: "default" 0.0; rel2.to_x: "elm.bar"; @@ -229,7 +308,7 @@ group { name: "elm/panes/vertical/flush"; } } part { name: "elm.bar"; type: SPACER; - dragable { confine: "whole"; + dragable { confine: "sub_whole"; x: 1 1 1; y: 0 0 0; } @@ -388,6 +467,32 @@ group { name: "elm/panes/horizontal/flush"; description { state: "default" 0.0; } } + part { name: "right_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 0 0 0; + y: 1 1 1; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "left_constraint"; type: SPACER; + dragable { confine: "whole"; + x: 0 0 0; + y: 1 1 1; + } + description { state: "default" 0.0; + max: 0 0; + } + } + part { name: "sub_whole"; type: SPACER; + description { state: "default" 0.0; + rel1.relative: 0.0 1.0; + rel1.to_y: "left_constraint"; + rel2.relative: 1.0 0.0; + rel2.to_y: "right_constraint"; + } + } part { name: "whole_left"; type: RECT; description { state: "default" 0.0; rel2.to_y: "elm.bar"; @@ -415,7 +520,7 @@ group { name: "elm/panes/horizontal/flush"; } } part { name: "elm.bar"; type: SPACER; - dragable { confine: "whole"; + dragable { confine: "sub_whole"; x: 0 0 0; y: 1 1 1; } diff --git a/src/lib/elm_panes.c b/src/lib/elm_panes.c index 3826dd2..dfb6e82 100644 --- a/src/lib/elm_panes.c +++ b/src/lib/elm_panes.c @@ -178,6 +178,87 @@ _on_unpressed(void *data, } } +static void +_set_min_size(void *data) +{ + ELM_PANES_DATA_GET(data, sd); + ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); + + double sizer = sd->right_min_relative_size; + double sizel = sd->left_min_relative_size; + if ((sd->left_min_relative_size + sd->right_min_relative_size) > 1) + { + double sum = sizer + sizel; + sizer = sizer / sum; + sizel = sizel / sum; + } + if (sd->horizontal) + { + edje_object_part_drag_value_set + (wd->resize_obj, "right_constraint", 0.0, (1 - sizer)); + edje_object_part_drag_value_set + (wd->resize_obj, "left_constraint", 0.0, sizel); + } + else + { + edje_object_part_drag_value_set + (wd->resize_obj, "right_constraint", (1 - sizer), 0.0); + edje_object_part_drag_value_set + (wd->resize_obj, "left_constraint", sizel, 0.0); + } +} + +static void +_update_fixed_sides(void *data) +{ + ELM_PANES_DATA_GET(data, sd); + ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); + Evas_Coord w, h; + evas_object_geometry_get(wd->resize_obj, NULL, NULL, &w, &h); + + if (sd->right_min_size_is_relative) + { + if (sd->horizontal) + sd->right_min_size = (int)(h * sd->right_min_relative_size); + else + sd->right_min_size =(int)(w * sd->right_min_relative_size); + } + else + { + sd->right_min_relative_size = 0; + if (sd->horizontal && (h > 0)) + sd->right_min_relative_size = sd->right_min_size / (double)h; + if (!sd->horizontal && (w > 0)) + sd->right_min_relative_size = sd->right_min_size / (double)w; + } + + if(sd->left_min_size_is_relative) + { + if (sd->horizontal) + sd->left_min_size = (int)(h * sd->left_min_relative_size); + else + sd->left_min_size = (int)(w * sd->left_min_relative_size); + } + else + { + sd->left_min_relative_size = 0; + if (sd->horizontal && (h > 0)) + sd->left_min_relative_size = sd->left_min_size / (double)h; + if (!sd->horizontal && (w > 0)) + sd->left_min_relative_size = sd->left_min_size / (double)w; + } + _set_min_size(data); +} + +static void +_on_resize(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + _update_fixed_sides(data); +} + EOLIAN static void _elm_panes_evas_object_smart_add(Eo *obj, Elm_Panes_Data *_pd EINA_UNUSED) { @@ -205,6 +286,17 @@ _elm_panes_evas_object_smart_add(Eo *obj, Elm_Panes_Data *_pd EINA_UNUSED) edje_object_signal_callback_add (wd->resize_obj, "elm,action,unpress", "*", _on_unpressed, obj); + evas_object_event_callback_add + (wd->resize_obj, EVAS_CALLBACK_RESIZE, + _on_resize, obj); + + sd->right_min_size_is_relative = EINA_TRUE; + sd->left_min_size_is_relative = EINA_TRUE; + sd->right_min_size = 0; + sd->left_min_size = 0; + sd->right_min_relative_size = 0; + sd->left_min_relative_size = 0; + _update_fixed_sides(obj); elm_widget_can_focus_set(obj, EINA_FALSE); @@ -329,6 +421,7 @@ _elm_panes_horizontal_set(Eo *obj, Elm_Panes_Data *sd, Eina_Bool horizontal) { sd->horizontal = horizontal; eo_do(obj, elm_obj_widget_theme_apply()); + _update_fixed_sides(obj); elm_panes_content_left_size_set(obj, 0.5); } @@ -367,6 +460,66 @@ _elm_panes_fixed_get(Eo *obj EINA_UNUSED, Elm_Panes_Data *sd) return sd->fixed; } +EOLIAN static void +_elm_panes_content_left_min_relative_size_set(Eo *obj, Elm_Panes_Data *_pd, double size) +{ + _pd->left_min_relative_size = size; + if (_pd->left_min_relative_size < 0) _pd->left_min_relative_size = 0; + _pd->left_min_size_is_relative = EINA_TRUE; + _update_fixed_sides(obj); +} + +EOLIAN static double +_elm_panes_content_left_min_relative_size_get(Eo *obj EINA_UNUSED, Elm_Panes_Data *_pd) +{ + return _pd->left_min_relative_size; +} + +EOLIAN static void +_elm_panes_content_right_min_relative_size_set(Eo *obj, Elm_Panes_Data *_pd, double size) +{ + _pd->right_min_relative_size = size; + if (_pd->right_min_relative_size < 0) _pd->right_min_relative_size = 0; + _pd->right_min_size_is_relative = EINA_TRUE; + _update_fixed_sides(obj); +} + +EOLIAN static double +_elm_panes_content_right_min_relative_size_get(Eo *obj EINA_UNUSED, Elm_Panes_Data *_pd) +{ + return _pd->right_min_relative_size; +} + +EOLIAN static void +_elm_panes_content_left_min_size_set(Eo *obj, Elm_Panes_Data *_pd, Evas_Coord size) +{ + _pd->left_min_size = size; + if (_pd->left_min_size < 0) _pd->left_min_size = 0; + _pd->left_min_size_is_relative = EINA_FALSE; + _update_fixed_sides(obj); +} + +EOLIAN static Evas_Coord +_elm_panes_content_left_min_size_get(Eo *obj EINA_UNUSED, Elm_Panes_Data *_pd) +{ + return _pd->left_min_size; +} + +EOLIAN static void +_elm_panes_content_right_min_size_set(Eo *obj, Elm_Panes_Data *_pd, Evas_Coord size) +{ + _pd->right_min_size = size; + if (_pd->right_min_size < 0) _pd->right_min_size = 0; + _pd->right_min_size_is_relative = EINA_FALSE; + _update_fixed_sides(obj); +} + +EOLIAN static Evas_Coord +_elm_panes_content_right_min_size_get(Eo *obj EINA_UNUSED, Elm_Panes_Data *_pd) +{ + return _pd->right_min_size; +} + EOLIAN static Eina_Bool _elm_panes_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Panes_Data *_pd EINA_UNUSED) { diff --git a/src/lib/elm_panes.eo b/src/lib/elm_panes.eo index 0bdbd08..955f87a 100644 --- a/src/lib/elm_panes.eo +++ b/src/lib/elm_panes.eo @@ -140,6 +140,122 @@ class Elm_Panes (Elm_Layout) of right side. */ } } + content_left_min_relative_size { + set { + /*@ + Set the relative minimum size of panes widget's left side. + + @param obj The panes object. + @param size double value between 0.0 and 1.0 representing size + proportion of minimum size of left side. + + @see elm_panes_content_left_min_size_relative_get() + + @ingroup Panes */ + } + get { + /*@ + Get the relative minimum size of panes widget's left side. + + @param obj The panes object. + @return double value between 0.0 and 1.0 representing size proportion + of minimum size of left side. + + @see elm_panes_content_left_min_relative_size_set() for more details. + + @ingroup Panes */ + } + values { + double size; /*@ value between 0.0 and 1.0 representing size proportion + of minimum size of left side. */ + } + } + content_right_min_relative_size { + set { + /*@ + Set the relative minimum size of panes widget's right side. + + @param obj The panes object. + @param size double value between 0.0 and 1.0 representing size proportion + of minimum size of right side. + + @see elm_panes_content_right_min_relative_size_get() + + @ingroup Panes */ + } + get { + /*@ + Get the relative minimum size of panes widget's right side. + + @param obj The panes object. + @return double value between 0.0 and 1.0 representing size proportion + of minimum size of right side. + + @see elm_panes_content_right_min_size_set() for more details. + + @ingroup Panes */ + } + values { + double size; /*@ value between 0.0 and 1.0 representing size proportion + of minimum size of right side. */ + } + } + content_left_min_size { + set { + /*@ + Set the absolute minimum size of panes widget's left side. + + @param obj The panes object. + @param size int value representing minimum size of left side in pixels. + + @see elm_panes_content_left_min_size_get() + + @ingroup Panes */ + } + get { + /*@ + Get the absolute minimum size of panes widget's left side. + + @param obj The panes object. + @retur int value representing minimum size of left side in pixels. + + @see elm_panes_content_left_min_size_set() for more details. + + @ingroup Panes */ + } + values { + Evas_Coord size; /*@ value representing minimum size of left side + in pixels. */ + } + } + content_right_min_size { + set { + /*@ + Set the absolute minimum size of panes widget's right side. + + @param obj The panes object. + @param size int value representing minimum size of right side in pixels. + + @see elm_panes_content_right_min_size_get() + + @ingroup Panes */ + } + get { + /*@ + Get the absolute minimum size of panes widget's right side. + + @param obj The panes object. + @retur int value representing minimum size of right side in pixels. + + @see elm_panes_content_right_min_size_set() for more details. + + @ingroup Panes */ + } + values { + Evas_Coord size; /*@ value representing minimum size of right side + in pixels. */ + } + } } implements { class::constructor; diff --git a/src/lib/elm_panes_eo.h b/src/lib/elm_panes_eo.h index d0284fb..659a93b 100644 --- a/src/lib/elm_panes_eo.h +++ b/src/lib/elm_panes_eo.h @@ -1 +1 @@ -#include "elm_panes.eo.h" \ No newline at end of file +#include "elm_panes.eo.h" diff --git a/src/lib/elm_panes_legacy.h b/src/lib/elm_panes_legacy.h index 7ee243a..c1c625b 100644 --- a/src/lib/elm_panes_legacy.h +++ b/src/lib/elm_panes_legacy.h @@ -11,4 +11,4 @@ */ EAPI Evas_Object *elm_panes_add(Evas_Object *parent); -#include "elm_panes.eo.legacy.h" \ No newline at end of file +#include "elm_panes.eo.legacy.h" diff --git a/src/lib/elm_widget_panes.h b/src/lib/elm_widget_panes.h index 480b73e..be5e884 100644 --- a/src/lib/elm_widget_panes.h +++ b/src/lib/elm_widget_panes.h @@ -28,9 +28,15 @@ struct _Elm_Panes_Data Eina_Bool move; } move; + double left_min_relative_size; + double right_min_relative_size; + Evas_Coord left_min_size; + Evas_Coord right_min_size; Eina_Bool double_clicked : 1; Eina_Bool horizontal : 1; Eina_Bool fixed : 1; + Eina_Bool left_min_size_is_relative : 1; + Eina_Bool right_min_size_is_relative : 1; }; /** -- 2.7.4