1/* 2 Copyright (C) 2008,2009 INdT - Instituto Nokia de Tecnologia 3 Copyright (C) 2009,2010 ProFUSION embedded systems 4 Copyright (C) 2009,2010 Samsung Electronics 5 6 This file is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later version. 10 11 This file is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public License 17 along with this library; see the file COPYING.LIB. If not, write to 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20*/ 21 22group { 23 name: "webkit/widget/slider/vertical"; 24 25 min: 11 0; /* if > 0, this is the minimum size that will be allocated. 26 * If wants to draw on top, just overflow usign edje's rel1/rel2 27 */ 28 max: 11 999999; 29 30 images { 31 image: "widget/slider/slider_v.png" COMP; 32 image: "widget/slider/slider_knob_v.png" COMP; 33 image: "widget/slider/slider_knob_press_v.png" COMP; 34 image: "widget/slider/slider_fill_v.png" COMP; 35 } 36 37 script { 38 public isEnabled; 39 public isPressed; 40 public isChecked; 41 public isFocused; 42 public isHovered; 43 44 public show() { 45 46 if (get_int(isEnabled) == 1) { 47 set_state(PART:"img.knob", "default", 0.0); 48 if (get_int(isFocused) == 1) { 49 set_state(PART:"img.knob", "pressed", 0.0); 50 if (get_int(isPressed) == 1) 51 set_state(PART:"img.knob", "pressed", 0.0); 52 } 53 else if (get_int(isHovered) == 1) { 54 set_state(PART:"img.knob", "pressed", 0.0); 55 if (get_int(isPressed) == 1) 56 set_state(PART:"img.knob", "pressed", 0.0); 57 } 58 } 59 else 60 set_state(PART:"img.knob", "default", 0.0); 61 } 62 63 public message(Msg_Type:type, id, ...) { 64 if ((id == 0) && (type == MSG_FLOAT_SET)) { 65 new Float:vy, Float:sy; 66 67 vy = getfarg(2); 68 sy = getfarg(3); 69 70 if (vy >= 0.0) { 71 set_drag_size(PART:"img.knob", 1.0, sy); 72 set_drag(PART:"img.knob", 0.0, vy); 73 run_program(PROGRAM:"show"); 74 } else 75 run_program(PROGRAM:"hide"); 76 } 77 } 78 79 public update_drag_pos() { 80 new Float:x, Float:y; 81 get_drag(PART:"img.knob", x, y); 82 send_message(MSG_FLOAT, 1, y); 83 } 84 } 85 86 parts { 87 part { 88 name: "rect.base"; 89 type: RECT; 90 description { 91 min: 11 29; 92 max: 11 999999; 93 state: "default" 0.0; 94 color: 255 255 255 0; 95 } 96 } 97 part { 98 name: "rect.clipper"; 99 type: RECT; 100 description { 101 state: "default" 0.0; 102 color: 255 255 255 255; 103 } 104 description { 105 state: "hidden" 0.0; 106 color: 255 255 255 128; 107 } 108 } 109 110 part { 111 name: "img.slider"; 112 type: IMAGE; 113 mouse_events: 0; 114 clip_to: "rect.clipper"; 115 description { 116 state: "default" 0.0; 117 min: 5 29; 118 max: 5 999999; 119 rel1.to: "rect.base"; 120 rel2.to: "rect.base"; 121 image { 122 normal: "widget/slider/slider_v.png"; 123 border: 0 0 5 5; 124 } 125 } 126 } 127 128 part { 129 name: "img.slider_fill"; 130 type: IMAGE; 131 mouse_events: 0; 132 clip_to: "rect.clipper"; 133 description { 134 state: "default" 0.0; 135 min: 5 29; 136 max: 5 999999; 137 rel1.to: "img.knob"; 138 rel2.to: "rect.base"; 139 align: 0.5 0.5; 140 image { 141 normal: "widget/slider/slider_fill_v.png"; 142 border: 0 0 5 5; 143 } 144 } 145 } 146 147 part { 148 name: "img.knob"; 149 type: IMAGE; 150 mouse_events: 1; 151 clip_to: "rect.clipper"; 152 dragable { 153 x: 0 0 0; 154 y: 1 1 1; 155 confine: "rect.base"; 156 } 157 description { 158 state: "default" 0.0; 159 min: 11 29; 160 align: 0.5 0.5; 161 image { 162 normal: "widget/slider/slider_knob_v.png"; 163 border: 0 0 6 6; 164 } 165 } 166 description { 167 state: "pressed" 0.0; 168 inherit: "default" 0.0; 169 image.normal: "widget/slider/slider_knob_press_v.png"; 170 } 171 } 172 } 173 programs { 174 program { 175 name: "load"; 176 signal: "load"; 177 action: STATE_SET "hidden" 0.0; 178 target: "rect.clipper"; 179 } 180 program { 181 name: "hide"; 182 action: STATE_SET "hidden" 0.0; 183 transition: ACCELERATE 0.5; 184 target: "rect.clipper"; 185 } 186 187 program { 188 name: "show"; 189 action: STATE_SET "default" 0.0; 190 target: "rect.clipper"; 191 } 192 193 program { 194 name: "dragged"; 195 signal: "drag"; 196 source: "img.knob"; 197 script { 198 update_drag_pos(); 199 } 200 } 201 202 program { 203 name: "enabled"; 204 signal: "enabled"; 205 script { 206 set_int(isEnabled, 1); 207 show(); 208 } 209 } 210 program { 211 name: "pressed"; 212 signal: "pressed"; 213 script { 214 set_int(isPressed, 1); 215 show(); 216 } 217 } 218 program { 219 name: "checked"; 220 signal: "checked"; 221 script { 222 set_int(isChecked, 1); 223 show(); 224 } 225 } 226 program { 227 name: "focused"; 228 signal: "focused"; 229 script { 230 set_int(isFocused, 1); 231 show(); 232 } 233 } 234 program { 235 name: "hovered"; 236 signal: "hovered"; 237 script { 238 set_int(isHovered, 1); 239 show(); 240 } 241 } 242 program { 243 name: "reset"; 244 signal: "reset"; 245 script { 246 set_int(isEnabled, 0); 247 set_int(isPressed, 0); 248 set_int(isChecked, 0); 249 set_int(isFocused, 0); 250 set_int(isHovered, 0); 251 show(); 252 } 253 } 254 } 255} 256 257group { 258 name: "webkit/widget/slider/horizontal"; 259 260 min: 0 11; /* if > 0, this is the minimum size that will be allocated. 261 * If wants to draw on top, just overflow usign edje's rel1/rel2 262 */ 263 max: 999999 11; 264 265 images { 266 image: "widget/slider/slider_h.png" COMP; 267 image: "widget/slider/slider_knob_h.png" COMP; 268 image: "widget/slider/slider_knob_press_h.png" COMP; 269 image: "widget/slider/slider_fill_h.png" COMP; 270 } 271 272 script { 273 public isEnabled; 274 public isPressed; 275 public isChecked; 276 public isFocused; 277 public isHovered; 278 279 public show() { 280 281 if (get_int(isEnabled) == 1) { 282 set_state(PART:"img.knob", "default", 0.0); 283 if (get_int(isFocused) == 1) { 284 set_state(PART:"img.knob", "pressed", 0.0); 285 if (get_int(isPressed) == 1) 286 set_state(PART:"img.knob", "pressed", 0.0); 287 } 288 else if (get_int(isHovered) == 1) { 289 set_state(PART:"img.knob", "pressed", 0.0); 290 if (get_int(isPressed) == 1) 291 set_state(PART:"img.knob", "pressed", 0.0); 292 } 293 } 294 else 295 set_state(PART:"img.knob", "default", 0.0); 296 } 297 298 public message(Msg_Type:type, id, ...) { 299 if ((id == 0) && (type == MSG_FLOAT_SET)) { 300 new Float:vx, Float:sx; 301 302 vx = getfarg(2); 303 sx = getfarg(3); 304 305 if (vx >= 0.0) { 306 set_drag_size(PART:"img.knob", sx, 1.0); 307 set_drag(PART:"img.knob", vx, 0.0); 308 run_program(PROGRAM:"show"); 309 } else 310 run_program(PROGRAM:"hide"); 311 } 312 } 313 314 public update_drag_pos() { 315 new Float:x, Float:y; 316 get_drag(PART:"img.knob", x, y); 317 send_message(MSG_FLOAT, 1, x); 318 } 319 } 320 321 parts { 322 part { 323 name: "rect.base"; 324 type: RECT; 325 description { 326 state: "default" 0.0; 327 min: 29 11; 328 max: 999999 11; 329 color: 255 255 255 0; 330 } 331 } 332 part { 333 name: "rect.clipper"; 334 type: RECT; 335 description { 336 state: "default" 0.0; 337 color: 255 255 255 255; 338 } 339 description { 340 state: "hidden" 0.0; 341 color: 255 255 255 128; 342 } 343 } 344 345 part { 346 name: "img.slider"; 347 type: IMAGE; 348 mouse_events: 0; 349 clip_to: "rect.clipper"; 350 description { 351 state: "default" 0.0; 352 min: 29 5; 353 max: 999999 5; 354 rel1.to: "rect.base"; 355 rel2.to: "rect.base"; 356 align: 0.5 0.5; 357 image { 358 normal: "widget/slider/slider_h.png"; 359 border: 5 5 0 0; 360 } 361 } 362 } 363 364 part { 365 name: "img.slider_fill"; 366 type: IMAGE; 367 mouse_events: 0; 368 clip_to: "rect.clipper"; 369 description { 370 state: "default" 0.0; 371 min: 29 5; 372 max: 999999 5; 373 rel1.to: "rect.base"; 374 rel2.to: "img.knob"; 375 align: 0.5 0.5; 376 image { 377 normal: "widget/slider/slider_fill_h.png"; 378 border: 5 5 0 0; 379 } 380 } 381 } 382 383 part { 384 name: "img.knob"; 385 type: IMAGE; 386 mouse_events: 1; 387 clip_to: "rect.clipper"; 388 dragable { 389 x: 1 1 0; 390 y: 0 0 0; 391 confine: "rect.base"; 392 } 393 description { 394 state: "default" 0.0; 395 min: 29 11; 396 align: 0.5 0.5; 397 image { 398 normal: "widget/slider/slider_knob_h.png"; 399 border: 6 6 0 0; 400 } 401 } 402 description { 403 state: "pressed" 0.0; 404 inherit: "default" 0.0; 405 image.normal: "widget/slider/slider_knob_press_h.png"; 406 } 407 } 408 } 409 programs { 410 program { 411 name: "load"; 412 signal: "load"; 413 action: STATE_SET "hidden" 0.0; 414 target: "rect.clipper"; 415 } 416 program { 417 name: "hide"; 418 action: STATE_SET "hidden" 0.0; 419 transition: ACCELERATE 0.5; 420 target: "rect.clipper"; 421 } 422 423 program { 424 name: "show"; 425 action: STATE_SET "default" 0.0; 426 target: "rect.clipper"; 427 } 428 429 program { 430 name: "dragged"; 431 signal: "drag"; 432 source: "img.knob"; 433 script { 434 update_drag_pos(); 435 } 436 } 437 438 program { 439 name: "enabled"; 440 signal: "enabled"; 441 script { 442 set_int(isEnabled, 1); 443 show(); 444 } 445 } 446 program { 447 name: "pressed"; 448 signal: "pressed"; 449 script { 450 set_int(isPressed, 1); 451 show(); 452 } 453 } 454 program { 455 name: "checked"; 456 signal: "checked"; 457 script { 458 set_int(isChecked, 1); 459 show(); 460 } 461 } 462 program { 463 name: "focused"; 464 signal: "focused"; 465 script { 466 set_int(isFocused, 1); 467 show(); 468 } 469 } 470 program { 471 name: "hovered"; 472 signal: "hovered"; 473 script { 474 set_int(isHovered, 1); 475 show(); 476 } 477 } 478 program { 479 name: "reset"; 480 signal: "reset"; 481 script { 482 set_int(isEnabled, 0); 483 set_int(isPressed, 0); 484 set_int(isChecked, 0); 485 set_int(isFocused, 0); 486 set_int(isHovered, 0); 487 show(); 488 } 489 } 490 } 491} 492