1/* 2 Copyright (C) 2008,2009 INdT - Instituto Nokia de Tecnologia 3 4 This file is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This file is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18*/ 19 20group { 21 name: "scrollbar.vertical"; 22 23 min: 0 0; /* if > 0, this is the minimum size that will be allocated. 24 * If wants to draw on top, just overflow usign edje's rel1/rel2 25 */ 26 27 images { 28 image: "widget/scrollbar/scrollbar_v.png" COMP; 29 image: "widget/scrollbar/scrollbar_knob_v.png" COMP; 30 } 31 32 script { 33 public hide_timer; 34 35 public hide_timer_cb(val) { 36 run_program(PROGRAM:"hide"); 37 return 0; 38 } 39 40 public hide_timer_stop() { 41 new id = get_int(hide_timer); 42 if (id <= 0) 43 return; 44 45 cancel_timer(id); 46 set_int(hide_timer, 0); 47 } 48 49 public hide_timer_start() { 50 set_int(hide_timer, timer(1.0, "hide_timer_cb", 0)); 51 } 52 53 public message(Msg_Type:type, id, ...) { 54 if ((id == 0) && (type == MSG_FLOAT_SET)) { 55 new Float:vy, Float:sy; 56 57 vy = getfarg(2); 58 sy = getfarg(3); 59 60 if (vy >= 0.0) { 61 set_drag_size(PART:"img.knob", 1.0, sy); 62 set_drag(PART:"img.knob", 0.0, vy); 63 run_program(PROGRAM:"show"); 64 } else 65 run_program(PROGRAM:"hide"); 66 67 hide_timer_stop(); 68 hide_timer_start(); 69 } 70 } 71 72 public update_drag_pos() { 73 new Float:x, Float:y; 74 get_drag(PART:"img.knob", x, y); 75 send_message(MSG_FLOAT, 1, y); 76 } 77 } 78 79 parts { 80 part { 81 name: "rect.base"; 82 type: RECT; 83 description { 84 min: 10 0; 85 max: 10 999999; 86 align: 1.0 0.5; 87 state: "default" 0.0; 88 color: 255 255 255 0; 89 } 90 } 91 92 part { 93 name: "rect.clipper"; 94 type: RECT; 95 description { 96 state: "default" 0.0; 97 color: 255 255 255 255; 98 rel1.to: "rect.base"; 99 rel2.to: "rect.base"; 100 } 101 description { 102 state: "hidden" 0.0; 103 color: 255 255 255 64; 104 rel1.to: "rect.base"; 105 rel2.to: "rect.base"; 106 } 107 } 108 109 part { 110 name: "img.scrollbar"; 111 type: IMAGE; 112 mouse_events: 0; 113 clip_to: "rect.clipper"; 114 description { 115 state: "default" 0.0; 116 min: 1 30; 117 max: 1 999999; 118 align: 0.5 0.5; 119 image { 120 normal: "widget/scrollbar/scrollbar_v.png"; 121 border: 0 0 15 15; 122 middle: SOLID; 123 } 124 rel1.to: "rect.base"; 125 rel2.to: "rect.base"; 126 } 127 } 128 129 part { 130 name: "rect.knobarea"; 131 type: RECT; 132 description { 133 state: "default" 0.0; 134 color: 255 255 255 0; 135 min: 5 5; 136 max: 5 999999; 137 align: 0.5 0.5; 138 rel1.to: "rect.base"; 139 rel2.to: "rect.base"; 140 } 141 } 142 143 part { 144 name: "img.knob"; 145 type: IMAGE; 146 mouse_events: 1; 147 clip_to: "rect.clipper"; 148 dragable { 149 x: 0 0 0; 150 y: 1 1 0; 151 confine: "rect.knobarea"; 152 } 153 description { 154 state: "default" 0.0; 155 min: 5 5; 156 max: 5 999999; 157 align: 0.5 0.5; 158 image { 159 normal: "widget/scrollbar/scrollbar_knob_v.png"; 160 border: 3 3 3 3; 161 middle: SOLID; 162 } 163 } 164 } 165 } 166 programs { 167 program { 168 name: "load"; 169 signal: "load"; 170 action: STATE_SET "hidden" 0.0; 171 target: "rect.clipper"; 172 } 173 program { 174 name: "hide"; 175 action: STATE_SET "hidden" 0.0; 176 transition: ACCELERATE 0.5; 177 target: "rect.clipper"; 178 } 179 180 program { 181 name: "show"; 182 action: STATE_SET "default" 0.0; 183 target: "rect.clipper"; 184 } 185 186 program { 187 name: "dragged"; 188 signal: "drag"; 189 source: "img.knob"; 190 script { 191 update_drag_pos(); 192 } 193 } 194 } 195} 196 197group { 198 name: "scrollbar.horizontal"; 199 200 min: 0 0; /* if > 0, this is the minimum size that will be allocated. 201 * If wants to draw on top, just overflow usign edje's rel1/rel2 202 */ 203 204 images { 205 image: "widget/scrollbar/scrollbar_h.png" COMP; 206 image: "widget/scrollbar/scrollbar_knob_h.png" COMP; 207 } 208 209 script { 210 public hide_timer; 211 212 public hide_timer_cb(val) { 213 run_program(PROGRAM:"hide"); 214 return 0; 215 } 216 217 public hide_timer_stop() { 218 new id = get_int(hide_timer); 219 if (id <= 0) 220 return; 221 222 cancel_timer(id); 223 set_int(hide_timer, 0); 224 } 225 226 public hide_timer_start() { 227 set_int(hide_timer, timer(1.0, "hide_timer_cb", 0)); 228 } 229 230 public message(Msg_Type:type, id, ...) { 231 if ((id == 0) && (type == MSG_FLOAT_SET)) { 232 new Float:vx, Float:sx; 233 234 vx = getfarg(2); 235 sx = getfarg(3); 236 237 if (vx >= 0.0) { 238 set_drag_size(PART:"img.knob", sx, 1.0); 239 set_drag(PART:"img.knob", vx, 0.0); 240 run_program(PROGRAM:"show"); 241 } else 242 run_program(PROGRAM:"hide"); 243 244 hide_timer_stop(); 245 hide_timer_start(); 246 } 247 } 248 249 public update_drag_pos() { 250 new Float:x, Float:y; 251 get_drag(PART:"img.knob", x, y); 252 send_message(MSG_FLOAT, 1, x); 253 } 254 } 255 256 parts { 257 part { 258 name: "rect.base"; 259 type: RECT; 260 description { 261 state: "default" 0.0; 262 min: 0 10; 263 max: 999999 10; 264 align: 0.5 1.0; 265 color: 255 255 255 0; 266 } 267 } 268 269 part { 270 name: "rect.clipper"; 271 type: RECT; 272 description { 273 state: "default" 0.0; 274 color: 255 255 255 255; 275 rel1.to: "rect.base"; 276 rel2.to: "rect.base"; 277 } 278 description { 279 state: "hidden" 0.0; 280 color: 255 255 255 64; 281 rel1.to: "rect.base"; 282 rel2.to: "rect.base"; 283 } 284 } 285 286 part { 287 name: "img.scrollbar"; 288 type: IMAGE; 289 mouse_events: 0; 290 clip_to: "rect.clipper"; 291 description { 292 state: "default" 0.0; 293 min: 30 1; 294 max: 999999 1; 295 align: 0.5 0.5; 296 image { 297 normal: "widget/scrollbar/scrollbar_h.png"; 298 border: 15 15 0 0; 299 middle: SOLID; 300 } 301 rel1.to: "rect.base"; 302 rel2.to: "rect.base"; 303 } 304 } 305 306 307 part { 308 name: "rect.knobarea"; 309 type: RECT; 310 description { 311 state: "default" 0.0; 312 color: 255 255 255 0; 313 min: 5 5; 314 max: 999999 5; 315 align: 0.5 0.5; 316 rel1.to: "rect.base"; 317 rel2.to: "rect.base"; 318 } 319 } 320 321 part { 322 name: "img.knob"; 323 type: IMAGE; 324 mouse_events: 1; 325 clip_to: "rect.clipper"; 326 dragable { 327 x: 1 1 0; 328 y: 0 0 0; 329 confine: "rect.knobarea"; 330 } 331 description { 332 state: "default" 0.0; 333 min: 5 5; 334 max: 999999 5; 335 image { 336 normal: "widget/scrollbar/scrollbar_knob_h.png"; 337 border: 3 3 3 3; 338 middle: SOLID; 339 } 340 } 341 } 342 } 343 programs { 344 program { 345 name: "load"; 346 signal: "load"; 347 action: STATE_SET "hidden" 0.0; 348 target: "rect.clipper"; 349 } 350 program { 351 name: "hide"; 352 action: STATE_SET "hidden" 0.0; 353 transition: ACCELERATE 0.5; 354 target: "rect.clipper"; 355 } 356 357 program { 358 name: "show"; 359 action: STATE_SET "default" 0.0; 360 target: "rect.clipper"; 361 } 362 363 program { 364 name: "dragged"; 365 signal: "drag"; 366 source: "img.knob"; 367 script { 368 update_drag_pos(); 369 } 370 } 371 } 372} 373