GuiScript.tscript 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. %top = EditorGuiToolbar.extent.y + 6;
  33. %bottom = %top + 65 - 6;
  34. %maxHeight = Canvas.extent.y - %top - %bottom;
  35. // --- Fixed window (top) ------------------------------------------------
  36. // put it back if it moved
  37. %fixedWindow.position.x = Canvas.extent.x - %fixedWindow.extent.x;
  38. %fixedWindow.position.y = %top;
  39. // don't go beyond the canvas
  40. if(%fixedWindow.extent.y > %maxHeight)
  41. %fixedWindow.extent.y = %maxHeight - %fluidWindow.extent.y;
  42. %position = %fixedWindow.position.x SPC %fixedWindow.position.y;
  43. %extent = %window.extent.x SPC %fixedWindow.extent.y;
  44. %fixedWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
  45. // --- Fluid window (bottom) ---------------------------------------------
  46. // position is relative to the top window
  47. %position = %fixedWindow.position.x SPC %fixedWindow.extent.y + %top;
  48. %extent = %window.extent.x SPC Canvas.extent.y - %fixedWindow.extent.y - %bottom;
  49. %fluidWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
  50. // --- AssetBrowser window ----------------------------------------------
  51. if(isObject(AssetBrowserWindow))
  52. {
  53. // Only resize the AssetBrowser if it's docked
  54. if(AssetBrowserWindow.docked == true)
  55. {
  56. // The width is relative to the sidepanel
  57. %browserWidth = Canvas.extent.x - %extent.x;
  58. %browserHeight = AssetBrowserWindow.extent.y;
  59. %browserPosY = Canvas.extent.y - AssetBrowserWindow.extent.y - 33;
  60. AssetBrowserWindow.resize(0, %browserPosY, %browserWidth, %browserHeight);
  61. }
  62. }
  63. // --- Windowed Console --------------------------------------------------
  64. if(isObject(windowConsoleControl))
  65. {
  66. // Only resize the AssetBrowser if it's docked
  67. if(windowConsoleControl.docked == true)
  68. {
  69. // The width is relative to the sidepanel
  70. %consoleWidth = Canvas.extent.x - %extent.x;
  71. %consoleHeight = windowConsoleControl.extent.y;
  72. %consolePosY = Canvas.extent.y - windowConsoleControl.extent.y - 33;
  73. windowConsoleControl.resize(0, %consolePosY, %consoleWidth, %consoleHeight);
  74. }
  75. }
  76. }
  77. }
  78. function VPathEditorTreeWindow::onMouseDragged(%this)
  79. {
  80. %parent = EVPathEditor;
  81. if(%parent.resizing == false)
  82. {
  83. %parent.resizing = true;
  84. %parent.maxSize(%this);
  85. }
  86. }
  87. function VPathEditorOptionsWindow::onMouseDragged(%this)
  88. {
  89. %parent = EVPathEditor;
  90. if(%parent.resizing == false)
  91. {
  92. %parent.resizing = true;
  93. %parent.maxSize(%this);
  94. }
  95. }
  96. function EVPathEditor::onResize(%this, %newPosition, %newExtent)
  97. {
  98. // Window to focus on (mostly the fluid window)
  99. %window = RoadEditorOptionsWindow;
  100. if(%this.resizing == false)
  101. {
  102. // Only resize once
  103. %this.resizing = true;
  104. %this.maxSize(%window);
  105. }
  106. FieldInfoControl.position = 5 SPC EWInspectorWindow.extent.y - 40;
  107. }