summaryrefslogtreecommitdiff
path: root/src/bin/e_moveresize.c
blob: 2c1edaebbde5b47ab12c1a3fe0a9526bfad7a6ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

static E_Popup *_disp_pop = NULL;
static Evas_Object *_obj = NULL;

static int visible = 0;
static int obj_x = 0;
static int obj_y = 0;
static int obj_w = 0;
static int obj_h = 0;

EAPI void
e_resize_begin(E_Zone *zone, int w, int h)
{
   Evas_Coord ew, eh;
   char buf[40];

   _obj = NULL;
   if (_disp_pop) e_object_del(E_OBJECT(_disp_pop));

   if (e_config->resize_info_visible)
     {
	_disp_pop = e_popup_new(zone, 0, 0, 1, 1);
	if (!_disp_pop) return;
	e_popup_layer_set(_disp_pop, 255);
	_obj = edje_object_add(_disp_pop->evas);
	e_theme_edje_object_set(_obj, "base/theme/borders",
	      "e/widgets/border/default/resize");
	snprintf(buf, sizeof(buf), "9999x9999");
	edje_object_part_text_set(_obj, "e.text.label", buf);

	edje_object_size_min_calc(_obj, &ew, &eh);
	evas_object_move(_obj, 0, 0);
	evas_object_resize(_obj, ew, eh);
	evas_object_show(_obj);
	e_popup_edje_bg_object_set(_disp_pop, _obj);
     }
   
   e_resize_update(w, h);

   if (e_config->resize_info_visible)
     {
	e_popup_move_resize(_disp_pop,
	      (obj_x - _disp_pop->zone->x) +
	      ((obj_w - ew) / 2),
	      (obj_y - _disp_pop->zone->y) +
	      ((obj_h - eh) / 2),
	      ew, eh);
	e_popup_show(_disp_pop);
     }

   visible = 1;
}

EAPI void
e_resize_end(void)
{
   if (e_config->resize_info_visible)
     {
	if (_obj)
	  {
	     evas_object_del(_obj);
	     _obj = NULL;
	  }
	if (_disp_pop)
	  {
	     e_object_del(E_OBJECT(_disp_pop));
	     _disp_pop = NULL;
	  }
     }

   visible = 0;
}

EAPI void
e_resize_update(int w, int h)
{
   char buf[40];

   if (!_disp_pop) return;
   if (!visible)
     {
	evas_object_show(_obj);
	e_popup_show(_disp_pop);
	visible = 1;
     }
   snprintf(buf, sizeof(buf), "%ix%i", w, h);
   edje_object_part_text_set(_obj, "e.text.label", buf);
}

EAPI void
e_move_begin(E_Zone *zone, int x, int y)
{
   Evas_Coord ew, eh;
   char buf[40];

   _obj = NULL;
   if (_disp_pop) e_object_del(E_OBJECT(_disp_pop));

   if (e_config->move_info_visible)
     {
	_disp_pop = e_popup_new(zone, 0, 0, 1, 1);
	_obj = edje_object_add(_disp_pop->evas);
	e_theme_edje_object_set(_obj, "base/theme/borders",
	      "e/widgets/border/default/move");
	snprintf(buf, sizeof(buf), "9999 9999");
	edje_object_part_text_set(_obj, "e.text.label", buf);

	edje_object_size_min_calc(_obj, &ew, &eh);
	evas_object_move(_obj, 0, 0);
	evas_object_resize(_obj, ew, eh);
	evas_object_show(_obj);
	e_popup_edje_bg_object_set(_disp_pop, _obj);
     }

   if (e_config->move_info_visible)
     {
	e_popup_move_resize(_disp_pop,
	      (obj_x - _disp_pop->zone->x) +
	      ((obj_w - ew) / 2),
	      (obj_y - _disp_pop->zone->y) +
	      ((obj_h - eh) / 2),
	      ew, eh);
     }
}

EAPI void
e_move_end(void)
{
   if (e_config->move_info_visible)
     {
	if (_obj)
	  {
	     evas_object_del(_obj);
	     _obj = NULL;
	  }
	if (_disp_pop)
	  {
	     e_object_del(E_OBJECT(_disp_pop));
	     _disp_pop = NULL;
	  }
     }

   visible = 0;
}

EAPI void
e_move_update(int x, int y)
{
   char buf[40];

   if (!_disp_pop) return;
   if (!visible)
     {
	evas_object_show(_obj);
	e_popup_show(_disp_pop);
	visible = 1;
     }
   snprintf(buf, sizeof(buf), "%i %i", x, y);
   edje_object_part_text_set(_obj, "e.text.label", buf);
}

EAPI void
e_move_resize_object_coords_set(int x, int y, int w, int h)
{
   obj_x = x;
   obj_y = y;
   obj_w = w;
   obj_h = h;
   if ((_disp_pop) && (e_config->move_info_visible) && (visible))
     {
	e_popup_move(_disp_pop,
		     (obj_x - _disp_pop->zone->x) +
		     ((obj_w - _disp_pop->w) / 2),
		     (obj_y - _disp_pop->zone->y) +
		     ((obj_h - _disp_pop->h) / 2)
		     );
     }
}