enventor - changed panes behavior a little.
now, you can switch the full <-> split view by press/click the arrows again.
This commit is contained in:
parent
47cb4450cf
commit
a98f78455f
5
README
5
README
|
@ -51,9 +51,8 @@ Ctrl+V = Paste Copied Text
|
|||
Ctrl+Home = Go to the Top line
|
||||
Ctrl+End = Go to the Bottom line
|
||||
Ctrl+H = Part Highlighting
|
||||
Ctrl+, = Full Edit View
|
||||
Ctrl+. = Full Edje View
|
||||
Ctrl+/ = Split View
|
||||
Ctrl+, = Full Edit View / Split View
|
||||
Ctrl+. = Full Edje View / Split View
|
||||
Ctrl+W = Show/Hide Dummy Swallow Object
|
||||
|
||||
|
||||
|
|
|
@ -236,11 +236,6 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev)
|
|||
panes_full_view_right(ad->panes);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
if (!strcmp(event->keyname, "slash"))
|
||||
{
|
||||
panes_full_view_cancel(ad->panes);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
|
143
src/bin/panes.c
143
src/bin/panes.c
|
@ -1,12 +1,25 @@
|
|||
#include <Elementary.h>
|
||||
#include "common.h"
|
||||
|
||||
typedef struct _transit_data
|
||||
typedef enum
|
||||
{
|
||||
PANES_FULL_VIEW_LEFT,
|
||||
PANES_FULL_VIEW_RIGHT,
|
||||
PANES_SPLIT_VIEW
|
||||
} Panes_State;
|
||||
|
||||
const char *PANES_DATA = "_panes_data";
|
||||
|
||||
typedef struct _panes_data
|
||||
{
|
||||
Evas_Object *panes;
|
||||
Evas_Object *left_arrow;
|
||||
Evas_Object *right_arrow;
|
||||
Panes_State state;
|
||||
|
||||
double origin;
|
||||
double delta;
|
||||
Evas_Object *panes;
|
||||
} transit_data;
|
||||
} panes_data;
|
||||
|
||||
static double panes_last_right_size1 = 0.5; //when down the panes bar
|
||||
static double panes_last_right_size2 = 0.5; //when up the panes bar
|
||||
|
@ -14,16 +27,9 @@ static double panes_last_right_size2 = 0.5; //when up the panes bar
|
|||
static void
|
||||
transit_op(void *data, Elm_Transit *transit EINA_UNUSED, double progress)
|
||||
{
|
||||
transit_data *td = data;
|
||||
elm_panes_content_right_size_set(td->panes,
|
||||
td->origin + (td->delta * progress));
|
||||
}
|
||||
|
||||
static void
|
||||
transit_free(void *data, Elm_Transit *transit EINA_UNUSED)
|
||||
{
|
||||
transit_data *td = data;
|
||||
free(td);
|
||||
panes_data *pd = data;
|
||||
elm_panes_content_right_size_set(pd->panes,
|
||||
pd->origin + (pd->delta * progress));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -43,112 +49,141 @@ unpress_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
|||
}
|
||||
|
||||
static void
|
||||
double_click_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
double_click_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const double TRANSIT_TIME = 0.25;
|
||||
|
||||
transit_data *td = malloc(sizeof(transit_data));
|
||||
if (!td) return;
|
||||
panes_data *pd = data;
|
||||
|
||||
td->origin = elm_panes_content_right_size_get(obj);
|
||||
td->delta = panes_last_right_size2 - td->origin;
|
||||
td->panes = obj;
|
||||
pd->origin = elm_panes_content_right_size_get(obj);
|
||||
pd->delta = panes_last_right_size2 - pd->origin;
|
||||
|
||||
Elm_Transit *transit = elm_transit_add();
|
||||
elm_transit_effect_add(transit, transit_op, td, transit_free);
|
||||
elm_transit_effect_add(transit, transit_op, pd, NULL);
|
||||
elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
|
||||
elm_transit_duration_set(transit, TRANSIT_TIME);
|
||||
elm_transit_go(transit);
|
||||
|
||||
pd->state = PANES_SPLIT_VIEW;
|
||||
}
|
||||
|
||||
static void
|
||||
left_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
left_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const double TRANSIT_TIME = 0.25;
|
||||
|
||||
Evas_Object *panes = data;
|
||||
double origin = elm_panes_content_right_size_get(panes);
|
||||
panes_data *pd = data;
|
||||
|
||||
//Revert state if the current state is full view left already.
|
||||
if (pd->state == PANES_FULL_VIEW_LEFT)
|
||||
{
|
||||
panes_full_view_cancel(pd->panes);
|
||||
elm_object_text_set(obj, "<");
|
||||
return;
|
||||
}
|
||||
|
||||
double origin = elm_panes_content_right_size_get(pd->panes);
|
||||
if (origin == 1.0) return;
|
||||
|
||||
transit_data *td = malloc(sizeof(transit_data));
|
||||
if (!td) return;
|
||||
|
||||
td->origin = origin;
|
||||
td->delta = 1.0 - td->origin;
|
||||
td->panes = panes;
|
||||
pd->origin = origin;
|
||||
pd->delta = 1.0 - pd->origin;
|
||||
|
||||
Elm_Transit *transit = elm_transit_add();
|
||||
elm_transit_effect_add(transit, transit_op, td, transit_free);
|
||||
elm_transit_effect_add(transit, transit_op, pd, NULL);
|
||||
elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
|
||||
elm_transit_duration_set(transit, TRANSIT_TIME);
|
||||
elm_transit_go(transit);
|
||||
|
||||
pd->state = PANES_FULL_VIEW_LEFT;
|
||||
elm_object_text_set(pd->right_arrow, ">");
|
||||
elm_object_text_set(obj, "|");
|
||||
}
|
||||
|
||||
static void
|
||||
right_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
right_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const double TRANSIT_TIME = 0.25;
|
||||
|
||||
Evas_Object *panes = data;
|
||||
double origin = elm_panes_content_right_size_get(panes);
|
||||
panes_data *pd = data;
|
||||
|
||||
//Revert state if the current state is full view left already.
|
||||
if (pd->state == PANES_FULL_VIEW_RIGHT)
|
||||
{
|
||||
panes_full_view_cancel(pd->panes);
|
||||
elm_object_text_set(obj, ">");
|
||||
return;
|
||||
}
|
||||
|
||||
double origin = elm_panes_content_right_size_get(pd->panes);
|
||||
if (origin == 0.0) return;
|
||||
|
||||
transit_data *td = malloc(sizeof(transit_data));
|
||||
if (!td) return;
|
||||
|
||||
td->origin = origin;
|
||||
td->delta = 0.0 - td->origin;
|
||||
td->panes = panes;
|
||||
pd->origin = origin;
|
||||
pd->delta = 0.0 - pd->origin;
|
||||
|
||||
Elm_Transit *transit = elm_transit_add();
|
||||
elm_transit_effect_add(transit, transit_op, td, transit_free);
|
||||
elm_transit_effect_add(transit, transit_op, pd, NULL);
|
||||
elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
|
||||
elm_transit_duration_set(transit, TRANSIT_TIME);
|
||||
elm_transit_go(transit);
|
||||
|
||||
pd->state = PANES_FULL_VIEW_RIGHT;
|
||||
elm_object_text_set(pd->left_arrow, "<");
|
||||
elm_object_text_set(obj, "|");
|
||||
}
|
||||
|
||||
void
|
||||
panes_full_view_right(Evas_Object *panes)
|
||||
{
|
||||
right_clicked_cb(panes, NULL, NULL);
|
||||
panes_data *pd = evas_object_data_get(panes, PANES_DATA);
|
||||
right_clicked_cb(pd, pd->right_arrow, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
panes_full_view_left(Evas_Object *panes)
|
||||
{
|
||||
left_clicked_cb(panes, NULL, NULL);
|
||||
panes_data *pd = evas_object_data_get(panes, PANES_DATA);
|
||||
left_clicked_cb(pd, pd->left_arrow, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
panes_full_view_cancel(Evas_Object *panes)
|
||||
{
|
||||
double_click_cb(NULL, panes, NULL);
|
||||
panes_data *pd = evas_object_data_get(panes, PANES_DATA);
|
||||
double_click_cb(pd, panes, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
panes_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
panes_data *pd = data;
|
||||
free(pd);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
panes_create(Evas_Object *parent)
|
||||
{
|
||||
panes_data *pd = malloc(sizeof(panes_data));
|
||||
|
||||
//Panes
|
||||
Evas_Object *panes = elm_panes_add(parent);
|
||||
elm_object_style_set(panes, elm_app_name_get());
|
||||
evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_smart_callback_add(panes, "clicked,double",
|
||||
double_click_cb, NULL);
|
||||
double_click_cb, pd);
|
||||
evas_object_smart_callback_add(panes, "press",
|
||||
press_cb, NULL);
|
||||
evas_object_smart_callback_add(panes, "unpress",
|
||||
unpress_cb, NULL);
|
||||
evas_object_event_callback_add(panes, EVAS_CALLBACK_DEL, panes_del_cb, pd);
|
||||
|
||||
evas_object_show(panes);
|
||||
|
||||
//Left Button
|
||||
Evas_Object *left_arrow = elm_button_add(panes);
|
||||
elm_object_text_set(left_arrow, "<");
|
||||
elm_object_focus_allow_set(left_arrow, EINA_FALSE);
|
||||
evas_object_smart_callback_add(left_arrow, "clicked", left_clicked_cb,
|
||||
panes);
|
||||
evas_object_smart_callback_add(left_arrow, "clicked", left_clicked_cb, pd);
|
||||
evas_object_show(left_arrow);
|
||||
|
||||
elm_object_part_content_set(panes, "elm.swallow.left_arrow", left_arrow);
|
||||
|
@ -157,12 +192,18 @@ panes_create(Evas_Object *parent)
|
|||
Evas_Object *right_arrow = elm_button_add(panes);
|
||||
elm_object_text_set(right_arrow, ">");
|
||||
elm_object_focus_allow_set(right_arrow, EINA_FALSE);
|
||||
evas_object_smart_callback_add(right_arrow, "clicked", right_clicked_cb,
|
||||
panes);
|
||||
evas_object_smart_callback_add(right_arrow, "clicked", right_clicked_cb, pd);
|
||||
evas_object_show(right_arrow);
|
||||
|
||||
elm_object_part_content_set(panes, "elm.swallow.right_arrow", right_arrow);
|
||||
|
||||
pd->panes = panes;
|
||||
pd->left_arrow = left_arrow;
|
||||
pd->right_arrow = right_arrow;
|
||||
pd->state = PANES_SPLIT_VIEW;
|
||||
|
||||
evas_object_data_set(panes, PANES_DATA, pd);
|
||||
|
||||
return panes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue