123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- /********************************************************\
- ** Filename: videoresize.m **
- ** Version: 1.0 **
- ** Date: 23. Jan. 2008 - 11:23 **
- **********************************************************
- ** Type: winamp.wasabi/maki **
- ** Project: Bento **
- **********************************************************
- ** Author: Martin Poehlmann aka Deimos **
- ** E-Mail: [email protected] **
- ** Internet: http://www.skinconsortium.com **
- ** http://home.cs.tum.edu/~poehlman **
- \********************************************************/
- #include <lib/std.mi>
- #include attribs/init_Autoresize.m
- Function adjust(int x, int y);
- Function fade(GuiObject o, int a);
- Class GuiObject Mousetrap;
- Global Mousetrap resizer;
- Global Mousetrap wdh, outer, bg;
- Global Group sg;
- Global Int sx, sy, ox, oy, dx, dy;
- Global Boolean move;
- Global Timer refresh;
- System.onScriptLoaded ()
- {
- initAttribs_Autoresize();
- sg = getScriptGroup();
- wdh = sg.getObject("wdh");
- resizer = sg.getObject("wdh.drag");
- outer = sg.getObject("wdh.outer");
- bg = sg.getObject("bg");
- refresh = new Timer;
- refresh.setDelay(133);
- video_inframe_attrib.onDataChanged ();
- }
- System.onScriptUnloading ()
- {
- refresh.stop();
- delete refresh;
- }
- resizer.onLeftButtonDown (int x, int y)
- {
- move = true;
- sx = x;
- sy = y;
- ox = wdh.getGuiX();
- oy = wdh.getGuiY();
- refresh.start();
- }
- resizer.onLeftButtonUp (int x, int y)
- {
- move = false;
- refresh.stop();
- }
- resizer.onMouseMove (int x, int y)
- {
- if (!move) return;
- dx = sx - x;
- dy = sy - y;
- }
- // handle the resizing with a timer in order to prevent jittering
- refresh.onTimer ()
- {
- adjust(dx, dy);
- }
- adjust (int x, int y)
- {
- int nx = ox + x;
- int ny = oy + y;
- // Ensure we don't get out of the bounds
- if (nx < 5)
- {
- nx = 5;
- }
- if (ny < 5)
- {
- ny = 5;
- }
- // Minimum h/w: aligned with Nullsoft Video Symbol
- if (sg.getHeight() - 2*ny < 64)
- {
- ny = (64 - sg.getHeight())/(-2);
- }
- if (sg.getWidth() - 2*nx < 100)
- {
- nx = (100 - sg.getWidth())/(-2);
- }
-
- outer.setXmlParam("x", integerToString(nx-1));
- outer.setXmlParam("w", integerToString(-2*(nx-1)));
- outer.setXmlParam("y", integerToString(ny-1));
- outer.setXmlParam("h", integerToString(-2*(ny-1)));
- wdh.setXmlParam("x", integerToString(nx));
- wdh.setXmlParam("w", integerToString(-(2*nx)));
- wdh.setXmlParam("y", integerToString(ny));
- wdh.setXmlParam("h", integerToString(-(2*ny)));
- resizer.setXmlParam("x", integerToString(-nx));
- resizer.setXmlParam("y", integerToString(-ny));
- }
- video_inframe_attrib.onDataChanged ()
- {
- if (getData() == "1")
- {
- outer.show();
- resizer.show();
- outer.setXmlParam("x", integerToString(4));
- outer.setXmlParam("w", integerToString(-8));
- outer.setXmlParam("y", integerToString(4));
- outer.setXmlParam("h", integerToString(-8));
- wdh.setXmlParam("x", integerToString(5));
- wdh.setXmlParam("w", integerToString(-10));
- wdh.setXmlParam("y", integerToString(5));
- wdh.setXmlParam("h", integerToString(-10));
- resizer.setXmlParam("x", integerToString(-5));
- resizer.setXmlParam("y", integerToString(-5));
- }
- else
- {
- outer.hide();
- resizer.hide();
- wdh.setXmlParam("x", integerToString(0));
- wdh.setXmlParam("w", integerToString(0));
- wdh.setXmlParam("y", integerToString(0));
- wdh.setXmlParam("h", integerToString(0));
- }
- }
- /*
- Mousetrap.onEnterArea ()
- {
- if (outer.getAlpha() == 255) return;
- if (video_inframe_attrib.getData() == "1")
- {
- fade(outer, 255);
- fade(resizer, 255);
- }
- }
- Mousetrap.onLeaveArea ()
- {
- if (move) return;
-
- for ( int i = 0; i < sg.getNumObjects(); i++ )
- {
- if (sg.enumObject(i).isMouseOver(getMousePosX(), getMousePosY())) return;
- }
-
- if (video_inframe_attrib.getData() == "1")
- {
- fade(outer, 0);
- fade(resizer, 0);
- }
- }
- fade (GuiObject o, int a)
- {
- o.cancelTarget();
- o.setTargetX(o.getGuiX());
- o.setTargetY(o.getGuiY());
- o.setTargetH(o.getGuiH());
- o.setTargetW(o.getGuiW());
- o.setTargetA(a);
- o.setTargetSpeed(0.3);
- o.gotoTarget();
- }*/
|