work work.. smell smell - scrollbars in and mostly functioning


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 22 years ago
parent b3da0db8eb
commit 14f5d57ee5
  1. BIN
      data/config/appearance/default/scrollbars/scroll_base_h.bits.db
  2. BIN
      data/config/appearance/default/scrollbars/scroll_base_v.bits.db
  3. 177
      src/scrollbar.c
  4. 4
      src/scrollbar.h
  5. 163
      src/view.c
  6. 11
      src/view.h

@ -3,10 +3,54 @@
static void e_scrollbar_recalc(E_Scrollbar *sb);
static void e_scrollbar_setup_bits(E_Scrollbar *sb);
static void e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
static void e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
static void e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
static void e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
static void e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
static void
e_scrollbar_recalc(E_Scrollbar *sb)
{
if (sb->base)
{
double x, y, w, h;
ebits_get_bit_geometry(sb->base, "Trough_Area",
&x, &y, &w, &h);
sb->bar_area.x = x + sb->x;
sb->bar_area.y = y + sb->y;
sb->bar_area.w = w;
sb->bar_area.h = h;
if (sb->direction)
{
sb->bar_pos.w = sb->bar_area.w;
sb->bar_pos.h = (sb->bar_area.h * sb->range) / sb->max;
sb->bar_pos.x = sb->bar_area.x;
sb->bar_pos.y = sb->bar_area.y +
((sb->bar_area.h * sb->val) / (sb->max - 1));
}
else
{
sb->bar_pos.w = (sb->bar_area.w * sb->range) / sb->max;
sb->bar_pos.h = sb->bar_area.h;
sb->bar_pos.x = sb->bar_area.x +
((sb->bar_area.w * sb->val) / (sb->max - 1));
sb->bar_pos.y = sb->bar_area.y;
}
}
else
{
sb->bar_area.x = sb->x;
sb->bar_area.y = sb->y;
sb->bar_area.w = sb->w;
sb->bar_area.h = sb->h;
sb->bar_pos.x = sb->bar_area.x;
sb->bar_pos.y = sb->bar_area.y;
sb->bar_pos.w = sb->bar_area.w;
sb->bar_pos.h = sb->bar_area.h;
}
UN(sb);
}
@ -29,6 +73,137 @@ e_scrollbar_setup_bits(E_Scrollbar *sb)
sprintf(buf, "%s/scroll_bar_h.bits.db", e_config_get("scrollbars"));
sb->bar = ebits_load(buf);
}
if (sb->base)
{
ebits_add_to_evas(sb->base, sb->evas);
ebits_set_bit_callback(sb->base, "Scrollbar_Trough", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb);
ebits_set_bit_callback(sb->base, "Scrollbar_Trough", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb);
ebits_set_bit_callback(sb->base, "Scrollbar_Arrow1", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb);
ebits_set_bit_callback(sb->base, "Scrollbar_Arrow1", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb);
ebits_set_bit_callback(sb->base, "Scrollbar_Arrow2", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb);
ebits_set_bit_callback(sb->base, "Scrollbar_Arrow2", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb);
}
if (sb->bar)
{
ebits_add_to_evas(sb->bar, sb->evas);
ebits_set_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_DOWN, e_sb_bar_down_cb, sb);
ebits_set_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_UP, e_sb_bar_up_cb, sb);
ebits_set_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_MOVE, e_sb_bar_move_cb, sb);
}
}
static void
e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
{
E_Scrollbar *sb;
double prev;
sb = data;
if (sb->mouse_down) return;
sb->mouse_down = bt;
if (!class) return;
prev = sb->val;
if (!strcmp(class, "Scrollbar_Arrow1"))
{
sb->val -= 16;
if (sb->val < 0) sb->val = 0;
}
else if (!strcmp(class, "Scrollbar_Arrow2"))
{
sb->val += 16;
if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range;
}
else if (!strcmp(class, "Scrollbar_Trough"))
{
}
e_scrollbar_recalc(sb);
if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y);
if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h);
if (prev != sb->val)
{
if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val);
}
}
static void
e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
{
E_Scrollbar *sb;
sb = data;
if (bt == sb->mouse_down) sb->mouse_down = 0;
else return;
if (!class) return;
if (!strcmp(class, "Scrollbar_Arrow1"))
{
}
else if (!strcmp(class, "Scrollbar_Arrow2"))
{
}
else if (!strcmp(class, "Scrollbar_Trough"))
{
}
}
static void
e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
{
E_Scrollbar *sb;
sb = data;
if (sb->mouse_down) return;
sb->mouse_down = bt;
sb->down_x = x;
sb->down_y = y;
sb->mouse_x = x;
sb->mouse_y = y;
}
static void
e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
{
E_Scrollbar *sb;
sb = data;
if (bt == sb->mouse_down) sb->mouse_down = 0;
else return;
}
static void
e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
{
E_Scrollbar *sb;
int dx, dy;
double prev;
sb = data;
if (!sb->mouse_down) return;
dx = x - sb->mouse_x;
dy = y - sb->mouse_y;
sb->mouse_x = x;
sb->mouse_y = y;
prev = sb->val;
if (sb->direction)
{
if (sb->bar_area.h > sb->bar_pos.h) sb->val +=
((double)dy * sb->max) / sb->bar_area.h;
else sb->val = 0;
}
else
{
if (sb->bar_area.w > sb->bar_pos.w) sb->val +=
((double)dx * sb->max) / sb->bar_area.w;
else sb->val = 0;
}
if (sb->val < 0) sb->val = 0;
if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range;
if (prev != sb->val)
{
e_scrollbar_recalc(sb);
if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y);
if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h);
if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val);
}
}
E_Scrollbar *
@ -128,6 +303,7 @@ void
e_scrollbar_set_direction(E_Scrollbar *sb, int d)
{
if (d == sb->direction) return;
sb->direction = d;
if (sb->evas)
{
Evas evas;
@ -176,6 +352,7 @@ void
e_scrollbar_set_value(E_Scrollbar *sb, double val)
{
if (sb->val == val) return;
if (val > sb->max - sb->range) val = sb->max - sb->range;
sb->val = val;
e_scrollbar_recalc(sb);
if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y);

@ -19,6 +19,10 @@ struct _E_Scrollbar
int direction;
double x, y, w, h;
int mouse_down;
int down_x, down_y;
int mouse_x, mouse_y;
struct {
double x, y, w, h;
} bar_area;

@ -44,6 +44,8 @@ static void e_view_handle_fs_restart(void *data);
static void e_view_resort_timeout(int val, void *data);
static int e_view_restart_alphabetical_qsort_cb(const void *data1, const void *data2);
static void e_view_geometry_record_timeout(int val, void *data);
static void e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar *sb, double val);
static void e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar *sb, double val);
void
e_view_selection_update(E_View *v)
@ -213,6 +215,26 @@ e_view_selection_update(E_View *v)
evas_show(v->evas, v->select.obj.clip);
}
static void
e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar *sb, double val)
{
E_View *v;
v = _data;
e_view_scroll_to(v, v->scroll.x, v->spacing.window.t - sb->val);
UN(val);
}
static void
e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar *sb, double val)
{
E_View *v;
v = _data;
e_view_scroll_to(v, v->spacing.window.l - sb->val, v->scroll.y);
UN(val);
}
static void
e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
@ -573,28 +595,40 @@ e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max
Evas_List l;
int x1, x2, y1, y2;
x1 = 999999999;
x2 = -999999999;
y1 = 999999999;
y2 = -999999999;
if (!v->icons)
{
if (min_x) *min_x = 0;
if (min_y) *min_y = 0;
if (max_x) *max_x = 1;
if (max_y) *max_y = 1;
return;
}
for (l = v->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
if (ic->geom.x < x1) x1 = ic->geom.x;
if (ic->geom.y < y1) y1 = ic->geom.y;
if (ic->geom.x + ic->geom.w > x2) x2 = ic->geom.x + ic->geom.w;
if (ic->geom.y + ic->geom.h > y2) y2 = ic->geom.y + ic->geom.h;
x1 = v->extents.x1;
x2 = v->extents.x2;
y1 = v->extents.y1;
y2 = v->extents.y2;
if (!v->extents.valid)
{
x1 = 999999999;
x2 = -999999999;
y1 = 999999999;
y2 = -999999999;
if (!v->icons)
{
if (min_x) *min_x = 0;
if (min_y) *min_y = 0;
if (max_x) *max_x = 1;
if (max_y) *max_y = 1;
return;
}
for (l = v->icons; l; l = l->next)
{
E_Icon *ic;
ic = l->data;
if (ic->geom.x < x1) x1 = ic->geom.x;
if (ic->geom.y < y1) y1 = ic->geom.y;
if (ic->geom.x + ic->geom.w > x2) x2 = ic->geom.x + ic->geom.w;
if (ic->geom.y + ic->geom.h > y2) y2 = ic->geom.y + ic->geom.h;
}
v->extents.x1 = x1;
v->extents.y1 = y1;
v->extents.x2 = x2;
v->extents.y2 = y2;
}
v->extents.valid = 1;
if (x1 > 0) x1 = 0;
if (y1 > 0) y1 = 0;
if (min_x) *min_x = x1;
@ -1096,8 +1130,10 @@ e_configure(Eevent * ev)
if (e->win == v->win.base)
{
/* win, root, x, y, w, h, wm_generated */
printf("configure for view %s\n", v->dir);
if (e->wm_generated)
{
printf("wm generated %i %i, %ix%i\n", e->x, e->y, e->w, e->h);
if ((e->x != v->location.x) || (e->y != v->location.y))
{
v->location.x = e->x;
@ -1105,8 +1141,10 @@ e_configure(Eevent * ev)
e_view_queue_geometry_record(v);
}
}
printf("size %ix%i\n", e->w, e->h);
if ((e->w != v->size.w) || (e->h != v->size.h))
{
printf("... a new size!\n");
v->size.w = e->w;
v->size.h = e->h;
if (v->pmap) e_pixmap_free(v->pmap);
@ -1125,11 +1163,16 @@ e_configure(Eevent * ev)
{
e_background_set_size(v->bg, v->size.w, v->size.h);
}
printf("evas_set_output_viewpor(%p)\n", v->evas);
evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h);
evas_set_output_size(v->evas, v->size.w, v->size.h);
e_view_scroll_to(v, v->scroll.x, v->scroll.y);
e_view_arrange(v);
e_view_queue_geometry_record(v);
e_scrollbar_move(v->scrollbar.v, v->size.w - 12, 0);
e_scrollbar_resize(v->scrollbar.v, 12, v->size.h - 12);
e_scrollbar_move(v->scrollbar.h, 0, v->size.h - 12);
e_scrollbar_resize(v->scrollbar.h, v->size.w - 12, 12);
}
}
}
@ -1280,19 +1323,19 @@ e_key_down(Eevent * ev)
{
if (!strcmp(e->key, "Up"))
{
e_view_scroll_by(v, 0, 8);
e_scrollbar_set_value(v->scrollbar.v, v->scrollbar.v->val - 8);
}
else if (!strcmp(e->key, "Down"))
{
e_view_scroll_by(v, 0, -8);
e_scrollbar_set_value(v->scrollbar.v, v->scrollbar.v->val + 8);
}
else if (!strcmp(e->key, "Left"))
{
e_view_scroll_by(v, 8, 0);
e_scrollbar_set_value(v->scrollbar.h, v->scrollbar.h->val - 8);
}
else if (!strcmp(e->key, "Right"))
{
e_view_scroll_by(v, -8, 0);
e_scrollbar_set_value(v->scrollbar.h, v->scrollbar.h->val + 8);
}
else if (!strcmp(e->key, "Escape"))
{
@ -1606,6 +1649,7 @@ e_view_icon_apply_xy(E_Icon *ic)
/* [I] */
/* Ig */
/* [txt] */
if (ic->geom.text.w > ic->geom.icon.w) ic->geom.w = ic->geom.text.w;
else ic->geom.w = ic->geom.icon.w;
ic->geom.h = ic->geom.icon.h + ic->geom.text.h + ic->view->spacing.icon.g;
@ -1674,6 +1718,11 @@ e_view_icon_apply_xy(E_Icon *ic)
ic->geom.text.w + pl + pr, ic->geom.text.h + pt + pb);
ebits_show(ic->obj.sel.over.text);
}
if (ic->geom.x != ic->prev_geom.x) ic->view->extents.valid = 0;
else if (ic->geom.y != ic->prev_geom.y) ic->view->extents.valid = 0;
else if (ic->geom.w != ic->prev_geom.w) ic->view->extents.valid = 0;
else if (ic->geom.h != ic->prev_geom.h) ic->view->extents.valid = 0;
ic->prev_geom = ic->geom;
}
static int
@ -1714,6 +1763,8 @@ e_view_arrange(E_View *v)
{
Evas_List l;
int x, y;
int x1, x2, y1, y2;
double sv, sr, sm;
x = v->spacing.window.l;
y = v->spacing.window.t;
@ -1732,6 +1783,24 @@ e_view_arrange(E_View *v)
e_view_icon_apply_xy(ic);
x += ic->geom.w + v->spacing.icon.s;
}
e_view_icons_get_extents(v, &x1, &y1, &x2, &y2);
sv = - (v->scroll.y - v->spacing.window.t);
sr = v->size.h - v->spacing.window.t - v->spacing.window.b;
sm = y2 - y1;
if (sr > sm) sr = sm;
e_scrollbar_set_value(v->scrollbar.v, sv);
e_scrollbar_set_range(v->scrollbar.v, sr);
e_scrollbar_set_max(v->scrollbar.v, sm);
sv = - (v->scroll.x - v->spacing.window.l);
sr = v->size.w - v->spacing.window.l - v->spacing.window.r;
sm = x2 - x1;
if (sr > sm) sr = sm;
e_scrollbar_set_value(v->scrollbar.h, sv);
e_scrollbar_set_range(v->scrollbar.h, sr);
e_scrollbar_set_max(v->scrollbar.h, sm);
}
void
@ -1906,6 +1975,7 @@ e_view_file_added(int id, char *file)
ic->obj.icon = evas_add_image_from_file(ic->view->evas, NULL);
ic->obj.text = e_text_new(ic->view->evas, ic->file, "filename");
v->icons = evas_list_append(v->icons, ic);
v->extents.valid = 0;
}
}
@ -1929,6 +1999,7 @@ e_view_file_deleted(int id, char *file)
OBJ_UNREF(ic);
v->icons = evas_list_remove(v->icons, ic);
v->changed = 1;
v->extents.valid = 0;
e_view_queue_resort(v);
}
}
@ -2052,9 +2123,9 @@ _member.r = _r; _member.g = _g; _member.b = _b; _member.a = _a;
SETCOL(v->select.config.grad_b, 255, 255, 255, 100);
v->spacing.window.l = 3;
v->spacing.window.r = 3;
v->spacing.window.r = 15;
v->spacing.window.t = 3;
v->spacing.window.b = 3;
v->spacing.window.b = 15;
v->spacing.icon.s = 7;
v->spacing.icon.g = 7;
v->spacing.icon.b = 7;
@ -2130,6 +2201,12 @@ e_view_realize(E_View *v)
v->win.main = evas_get_window(v->evas);
evas_event_move(v->evas, -999999, -999999);
e_add_child(v->win.base, v->win.main);
e_window_set_events(v->win.base,
XEV_VISIBILITY | XEV_CONFIGURE |
XEV_PROPERTY | XEV_FOCUS);
e_window_set_events(v->win.main,
XEV_EXPOSE | XEV_MOUSE_MOVE |
XEV_BUTTON | XEV_IN_OUT | XEV_KEY);
if (v->options.back_pixmap)
{
v->pmap = e_pixmap_new(v->win.main, v->size.w, v->size.h, 0);
@ -2153,12 +2230,32 @@ e_view_realize(E_View *v)
evas_set_color(v->evas, v->obj_bg, 0, 0, 0, 0);
evas_show(v->evas, v->obj_bg);
e_window_set_events(v->win.base,
XEV_VISIBILITY | XEV_CONFIGURE |
XEV_PROPERTY | XEV_FOCUS);
e_window_set_events(v->win.main,
XEV_EXPOSE | XEV_MOUSE_MOVE |
XEV_BUTTON | XEV_IN_OUT | XEV_KEY);
v->scrollbar.v = e_scrollbar_new();
e_scrollbar_set_change_func(v->scrollbar.v, e_view_scrollbar_v_change_cb, v);
e_scrollbar_set_direction(v->scrollbar.v, 1);
e_scrollbar_add_to_evas(v->scrollbar.v, v->evas);
e_scrollbar_set_layer(v->scrollbar.v, 2000);
e_scrollbar_set_value(v->scrollbar.v, 0.0);
e_scrollbar_set_range(v->scrollbar.v, 1.0);
e_scrollbar_set_max(v->scrollbar.v, 1.0);
v->scrollbar.h = e_scrollbar_new();
e_scrollbar_set_change_func(v->scrollbar.h, e_view_scrollbar_h_change_cb, v);
e_scrollbar_set_direction(v->scrollbar.h, 0);
e_scrollbar_add_to_evas(v->scrollbar.h, v->evas);
e_scrollbar_set_layer(v->scrollbar.h, 2000);
e_scrollbar_set_value(v->scrollbar.h, 0.0);
e_scrollbar_set_range(v->scrollbar.h, 1.0);
e_scrollbar_set_max(v->scrollbar.h, 1.0);
e_scrollbar_move(v->scrollbar.v, v->size.w - 12, 0);
e_scrollbar_resize(v->scrollbar.v, 12, v->size.h - 12);
e_scrollbar_move(v->scrollbar.h, 0, v->size.h - 12);
e_scrollbar_resize(v->scrollbar.h, v->size.w - 12, 12);
e_scrollbar_show(v->scrollbar.v);
e_scrollbar_show(v->scrollbar.h);
e_window_show(v->win.main);
{

@ -3,6 +3,7 @@
#include "e.h"
#include "background.h"
#include "scrollbar.h"
#include "fs.h"
#include "text.h"
@ -98,11 +99,19 @@ struct _E_View
} offset;
int update;
} drag;
struct {
int valid;
double x1, x2, y1, y2;
} extents;
Evas_Object obj_bg;
E_Background *bg;
struct {
E_Scrollbar *h, *v;
} scrollbar;
int is_listing;
int monitor_id;
@ -168,7 +177,7 @@ struct _E_Icon
struct {
int w, h;
} text;
} geom;
} geom, prev_geom;
int changed;
};

Loading…
Cancel
Save