You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

react_fn.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. these functions are slighty modified versions of their react counterparts
  3. */
  4. TILE_ASPECT_RATIO = 16 / 9;
  5. function reth(o){
  6. return {ret:o}
  7. }
  8. {
  9. var calcTileGrid=glob_react.fns.calcTileGrid
  10. var getMaxColumnCount=glob_react.fns.getMaxColumnCount
  11. let getMaxColumnCount2=glob_react.fns.getMaxColumnCount
  12. let sideMargins=(135 * 2 )+ 20
  13. // let sideMargins=(135 )+ 20
  14. let topBottomPadding=135 + 100
  15. // glob_dev_fns.getTileViewGridDimensions_set_num
  16. // function getTileViewGridDimensions(state: Object, maxColumns: number = getMaxColumnCount()) {
  17. // glob_dev_fns.getTileViewGridDimensions = function(state: Object, maxColumns: number = getMaxColumnCount()) {
  18. glob_dev_fns.getTileViewGridDimensions = function(state, maxColumns = getMaxColumnCount(),maxColumns2 = getMaxColumnCount2()) {
  19. // When in tile view mode, we must discount ourselves (the local participant) because our
  20. // tile is not visible.
  21. const { iAmRecorder } = state['features/base/config'];
  22. // dev util hook
  23. // const numberOfParticipants = state['features/base/participants'].length - (iAmRecorder ? 1 : 0);
  24. // /*
  25. var numberOfParticipants = state['features/base/participants'].length - (iAmRecorder ? 1 : 0);
  26. // clog("r0 num",numberOfParticipants)
  27. if (window.glob_dev_fns && window.glob_dev_fns.getTileViewGridDimensions_set_num){
  28. const numberOfParticipants_dev = window.glob_dev_fns.getTileViewGridDimensions_set_num(state,maxColumns,numberOfParticipants)
  29. if (typeof(numberOfParticipants_dev)=="number"){numberOfParticipants = numberOfParticipants_dev}
  30. }
  31. // */
  32. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  33. // calculate available width and height for tile view.
  34. // copied from calculateThumbnailSizeForTileView (one variable was dropped)
  35. // const topBottomPadding = 200;
  36. // const sideMargins = 30 * 2;
  37. const viewWidth = clientWidth - sideMargins;
  38. const viewHeight = clientHeight - topBottomPadding;
  39. const viewAspectRatio = viewWidth / viewHeight;
  40. const ratioOfRatios = TILE_ASPECT_RATIO / viewAspectRatio;
  41. const tileGrid = calcTileGrid(ratioOfRatios, numberOfParticipants);
  42. let { columns } = tileGrid;
  43. const { rows, availableTiles } = tileGrid;
  44. // maybe remove a column, for aesthetics.
  45. // clog("r0 dec? columns",columns,rows <= availableTiles - numberOfParticipants,columns > 1,rows <= availableTiles - numberOfParticipants && columns > 1)
  46. // if (rows <= availableTiles - numberOfParticipants && columns > 1) {
  47. if (rows <= availableTiles - numberOfParticipants) {
  48. // clog("r0 dec columns",columns)
  49. columns -= 1;
  50. // clog("r0 dec columns2",columns)
  51. }
  52. const columnsOverflowed = columns > maxColumns;
  53. // clog("r0 NaN",columnsOverflowed,Math.ceil(numberOfParticipants / columns),Math.min(columns, maxColumns) )
  54. // clog("r0 NaN2",Math.min(Math.ceil(numberOfParticipants / columns),maxColumns))
  55. columns = Math.min(columns, maxColumns) || 1;
  56. let visibleRows = Math.ceil(numberOfParticipants / columns) || 1;
  57. if (columnsOverflowed) {
  58. visibleRows = Math.min(visibleRows, maxColumns);
  59. }
  60. // clog("r0 gtvd",{columns,visibleRows,numberOfParticipants},tileGrid)
  61. /*
  62. return {
  63. columns,
  64. visibleRows
  65. };
  66. */
  67. const ret = reth({
  68. columns,
  69. visibleRows
  70. })
  71. clog("!!!",{numberOfParticipants,clientHeight, clientWidth,tileGrid,iAmRecorder,maxColumns,maxColumns2},arguments,ret)
  72. return reth({
  73. columns,
  74. visibleRows
  75. });
  76. }
  77. /*
  78. export function calculateThumbnailSizeForTileView({
  79. columns,
  80. visibleRows,
  81. clientWidth,
  82. clientHeight
  83. }: Object)
  84. */
  85. glob_dev_fns.calculateThumbnailSizeForTileView = function ({
  86. columns,
  87. visibleRows,
  88. clientWidth,
  89. clientHeight
  90. }) {
  91. // clog("calculateThumbnailSizeForTileView new")
  92. // The distance from the top and bottom of the screen, as set by CSS, to
  93. // avoid overlapping UI elements.
  94. // const topBottomPadding = 200;
  95. // Minimum space to keep between the sides of the tiles and the sides
  96. // of the window.
  97. // const sideMargins = 30 * 2;
  98. const verticalMargins = visibleRows * 10;
  99. const viewWidth = clientWidth - sideMargins;
  100. const viewHeight = clientHeight - topBottomPadding - verticalMargins;
  101. const initialWidth = viewWidth / columns;
  102. const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
  103. const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
  104. const width = Math.floor(TILE_ASPECT_RATIO * height);
  105. return reth({
  106. height,
  107. width
  108. });
  109. }
  110. glob_dev_fns.calculateThumbnailSizeForTileView_dev = function ({
  111. columns,
  112. visibleRows,
  113. clientWidth,
  114. clientHeight,
  115. sideMargins=0,
  116. topBottomPadding=0,
  117. verticalMargin = 10,
  118. TILE_ASPECT_RATIO=glob_react.fns.TILE_ASPECT_RATIO
  119. }) {
  120. // clog("calculateThumbnailSizeForTileView new")
  121. // The distance from the top and bottom of the screen, as set by CSS, to
  122. // avoid overlapping UI elements.
  123. // const topBottomPadding = 200;
  124. // Minimum space to keep between the sides of the tiles and the sides
  125. // of the window.
  126. // const sideMargins = 30 * 2;
  127. const verticalMargins = visibleRows * verticalMargin;
  128. const viewWidth = clientWidth - sideMargins;
  129. const viewHeight = clientHeight - topBottomPadding - verticalMargins;
  130. const initialWidth = viewWidth / columns;
  131. const aspectRatioHeight = initialWidth / TILE_ASPECT_RATIO;
  132. const height = Math.floor(Math.min(aspectRatioHeight, viewHeight / visibleRows));
  133. const width = Math.floor(TILE_ASPECT_RATIO * height);
  134. return ({
  135. height,
  136. width,
  137. consts:{verticalMargins,
  138. viewWidth,
  139. viewHeight,
  140. initialWidth,
  141. aspectRatioHeight,},
  142. });
  143. }
  144. }