1
0

simplemaximize.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * simlple maximize script
  3. *
  4. * doesn't require a registry store, so ideal for standardframes
  5. * required objects: maximize & restore as buttons
  6. *
  7. * @author mpdeimos
  8. * @version 0.1
  9. */
  10. #include <lib/std.mi>
  11. Global Button restore, maximize;
  12. Global Layout parent;
  13. Global Int lx, ly, lw, lh;
  14. System.onScriptLoaded ()
  15. {
  16. restore = getScriptGroup().findObject("restore");
  17. maximize = getScriptGroup().findObject("maximize");
  18. parent = getScriptGroup().getParentLayout();
  19. lx = -1;
  20. ly = -1;
  21. lh = -1;
  22. lw = -1;
  23. }
  24. parent.onResize (int x, int y, int w, int h)
  25. {
  26. double d = getScale();
  27. if (getLeft() == getViewPortLeftfromGuiObject(parent) && getTop() == getViewPortTopfromGuiObject(parent) && getWidth() == getViewPortWidthfromGuiObject(parent)/d && getHeight() == getViewPortHeightfromGuiObject(parent)/d)
  28. {
  29. restore.show();
  30. maximize.hide();
  31. }
  32. else
  33. {
  34. restore.hide();
  35. maximize.show();
  36. }
  37. }
  38. maximize.onLeftClick ()
  39. {
  40. lx = parent.getLeft();
  41. ly = parent.getTop();
  42. lw = parent.getWidth();
  43. lh = parent.getHeight();
  44. double d = parent.getScale();
  45. parent.resize(getViewPortLeftfromGuiObject(parent), getViewPortTopfromGuiObject(parent), getViewPortWidthfromGuiObject(parent)/d, getViewPortHeightfromGuiObject(parent)/d);
  46. }
  47. restore.onLeftClick ()
  48. {
  49. if (lx == -1)
  50. lx = parent.getLeft() - 75;
  51. if (ly == -1)
  52. ly = parent.getTop() - 75;
  53. if (lw == -1)
  54. lw = parent.getWidth() - 150;
  55. if (lh == -1)
  56. lh = parent.getHeight() - 150;
  57. parent.resize(lx,ly,lw,lh);
  58. }
  59. // TODO (mpdeimos) add scale recognizing