ScrollNotify.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //-----------------------------------------------------------------------------
  2. // Verve
  3. // Copyright (C) - Violent Tulip
  4. //-----------------------------------------------------------------------------
  5. function VEditorScrollControl::onScroll( %this )
  6. {
  7. %notifyObj = %this.getObject( 0 );
  8. if ( %notifyObj.isMethod( "onScroll" ) )
  9. {
  10. %notifyObj.onScroll();
  11. }
  12. }
  13. function VerveEditorScrollNotify::onWake( %this )
  14. {
  15. VerveEditorScrollNotifyV::onWake( %this );
  16. VerveEditorScrollNotifyH::onWake( %this );
  17. }
  18. function VerveEditorScrollNotify::onScroll( %this )
  19. {
  20. %this.onResize();
  21. }
  22. function VerveEditorScrollNotify::onResize( %this )
  23. {
  24. VerveEditorScrollNotifyV::onResize( %this );
  25. VerveEditorScrollNotifyH::onResize( %this );
  26. }
  27. function VerveEditorScrollNotify::onParentResized( %this )
  28. {
  29. %this.schedule( 32, "updateSize" );
  30. }
  31. function VerveEditorScrollNotify::updateSize( %this )
  32. {
  33. VerveEditorScrollNotifyH::updateSize( %this );
  34. VerveEditorScrollNotifyV::updateSize( %this );
  35. }
  36. //-------------------------------------------------------------------------
  37. function VerveEditorScrollNotifyV::onWake( %this )
  38. {
  39. if ( !isObject( $VerveEditor::ScrollNotifyVSet ) )
  40. {
  41. $VerveEditor::ScrollNotifyVSet = new SimSet();
  42. }
  43. $VerveEditor::ScrollNotifyVSet.add( %this );
  44. }
  45. function VerveEditorScrollNotifyV::onScroll( %this )
  46. {
  47. %this.onResize();
  48. }
  49. function VerveEditorScrollNotifyV::onResize( %this )
  50. {
  51. if ( !isObject( $VerveEditor::ScrollNotifyVSet ) )
  52. {
  53. // Not Awake Yet!
  54. return;
  55. }
  56. %scrollPosition = %this.getParent().getScrollPositionY();
  57. if ( !%this.SurpressUpdate )
  58. {
  59. %refSet = $VerveEditor::ScrollNotifyVSet;
  60. %refCount = %refSet.getCount();
  61. for ( %i = 0; %i < %refCount; %i++ )
  62. {
  63. %refObject = %refSet.getObject( %i ).getParent();
  64. %refObject.SurpressUpdate = true;
  65. %refObject.setScrollPosition( %refObject.getScrollPositionX(), %scrollPosition );
  66. %refObject.SurpressUpdate = false;
  67. }
  68. }
  69. }
  70. function VerveEditorScrollNotifyV::onParentResized( %this )
  71. {
  72. %this.schedule( 32, "updateSize" );
  73. }
  74. function VerveEditorScrollNotifyV::updateSize( %this )
  75. {
  76. %minX = getWord( %this.getObject( 0 ).MinExtent, 0 );
  77. %minY = getWord( %this.getParent().getExtent(), 1 ) - 3;
  78. %this.MinExtent = %minX SPC %minY;
  79. %newX = getWord( %this.getExtent(), 0 );
  80. %newY = getWord( VerveEditorTrackStack.getExtent(), 1 );
  81. %this.setExtent( %newX, %newY );
  82. // The onResize callback isn't called if all we did was move around
  83. %this.onResize();
  84. }
  85. //-------------------------------------------------------------------------
  86. function VerveEditorScrollNotifyH::onWake( %this )
  87. {
  88. if ( !isObject( $VerveEditor::ScrollNotifyHSet ) )
  89. {
  90. $VerveEditor::ScrollNotifyHSet = new SimSet();
  91. }
  92. $VerveEditor::ScrollNotifyHSet.add( %this );
  93. }
  94. function VerveEditorScrollNotifyH::onScroll( %this )
  95. {
  96. %this.onResize();
  97. }
  98. function VerveEditorScrollNotifyH::onResize( %this )
  99. {
  100. if ( !isObject( $VerveEditor::ScrollNotifyHSet ) )
  101. {
  102. // Not Awake Yet!
  103. return;
  104. }
  105. %scrollPosition = %this.getParent().getScrollPositionX();
  106. if ( !%this.SurpressUpdate )
  107. {
  108. %refSet = $VerveEditor::ScrollNotifyHSet;
  109. %refCount = %refSet.getCount();
  110. for ( %i = 0; %i < %refCount; %i++ )
  111. {
  112. %refObject = %refSet.getObject( %i ).getParent();
  113. %refObject.SurpressUpdate = true;
  114. %refObject.setScrollPosition( %scrollPosition, %refObject.getScrollPositionY() );
  115. %refObject.SurpressUpdate = false;
  116. }
  117. }
  118. }
  119. function VerveEditorScrollNotifyH::onParentResized( %this )
  120. {
  121. %this.schedule( 32, "updateSize" );
  122. }
  123. function VerveEditorScrollNotifyH::updateSize( %this )
  124. {
  125. %this.MinExtent = %this.getObject( 0 ).MinExtent;
  126. %this.setExtent( getWord( %this.getParent().getExtent(), 0 ) - 19, getWord( %this.getExtent(), 1 ) );
  127. // The onResize callback isn't called if all we did was move around
  128. %this.onResize();
  129. }