GuiScript.tscript 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. function EVPathEditor::maxSize(%this, %window)
  23. {
  24. // Resize the windows to the max height
  25. // and force these to the right side if set
  26. if(EditorSettings.value( "WorldEditor/forceSidebarToSide" ) == 1 && %this.resizing == true)
  27. {
  28. // prevent onResize after a resize
  29. %this.resizing = false;
  30. %fixedWindow = VPathEditorTreeWindow;
  31. %fluidWindow = VPathEditorOptionsWindow;
  32. %offset = -1; // tweak the vertical offset so that it aligns neatly
  33. %top = EditorGuiToolbar.extent.y + %offset;
  34. %bottom = %top + 59;
  35. %maxHeight = Canvas.extent.y - %top - %bottom;
  36. // --- Fixed window (top) ------------------------------------------------
  37. // put it back if it moved
  38. %fixedWindow.position.x = Canvas.extent.x - %fixedWindow.extent.x;
  39. %fixedWindow.position.y = %top;
  40. // don't go beyond the canvas
  41. if(%fixedWindow.extent.y > %maxHeight)
  42. %fixedWindow.extent.y = %maxHeight - %fluidWindow.extent.y;
  43. %position = %fixedWindow.position.x SPC %fixedWindow.position.y;
  44. %extent = %window.extent.x SPC %fixedWindow.extent.y;
  45. %fixedWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
  46. // --- Fluid window (bottom) ---------------------------------------------
  47. // position is relative to the top window
  48. %position = %fixedWindow.position.x SPC %fixedWindow.extent.y + %top;
  49. %extent = %window.extent.x SPC Canvas.extent.y - %fixedWindow.extent.y - %bottom;
  50. %fluidWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
  51. // --- AssetBrowser window ----------------------------------------------
  52. if(isObject(AssetBrowserWindow))
  53. {
  54. // Only resize the AssetBrowser if it's docked
  55. if(AssetBrowserWindow.docked == true)
  56. {
  57. // The width is relative to the sidepanel
  58. %browserWidth = Canvas.extent.x - %extent.x;
  59. %browserHeight = AssetBrowserWindow.extent.y;
  60. %browserPosY = Canvas.extent.y - AssetBrowserWindow.extent.y - 33;
  61. AssetBrowserWindow.resize(0, %browserPosY, %browserWidth, %browserHeight);
  62. }
  63. }
  64. // --- Windowed Console --------------------------------------------------
  65. if(isObject(windowConsoleControl))
  66. {
  67. // Only resize the AssetBrowser if it's docked
  68. if(windowConsoleControl.docked == true)
  69. {
  70. // The width is relative to the sidepanel
  71. %consoleWidth = Canvas.extent.x - %extent.x;
  72. %consoleHeight = windowConsoleControl.extent.y;
  73. %consolePosY = Canvas.extent.y - windowConsoleControl.extent.y - 33;
  74. windowConsoleControl.resize(0, %consolePosY, %consoleWidth, %consoleHeight);
  75. }
  76. }
  77. }
  78. }
  79. function VPathEditorTreeWindow::onMouseDragged(%this)
  80. {
  81. %parent = EVPathEditor;
  82. if(%parent.resizing == false)
  83. {
  84. %parent.resizing = true;
  85. %parent.maxSize(%this);
  86. }
  87. }
  88. function VPathEditorOptionsWindow::onMouseDragged(%this)
  89. {
  90. %parent = EVPathEditor;
  91. if(%parent.resizing == false)
  92. {
  93. %parent.resizing = true;
  94. %parent.maxSize(%this);
  95. }
  96. }
  97. function EVPathEditor::onResize(%this, %newPosition, %newExtent)
  98. {
  99. // Window to focus on (mostly the fluid window)
  100. %window = RoadEditorOptionsWindow;
  101. if(%this.resizing == false)
  102. {
  103. // Only resize once
  104. %this.resizing = true;
  105. %this.maxSize(%window);
  106. }
  107. FieldInfoControl.position = 5 SPC EWInspectorWindow.extent.y - 40;
  108. }