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.6KB

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