123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- // clog = console.log
- // function nop(){}
-
- glob_dev_hooks = window.glob_dev_hooks || {}
- glob_dev_fns = window.glob_dev_fns || {}
- window.glob_react = window.glob_react || {i:"r0"}
-
-
- function FS_dec(fn) {
- return function() {
- dec_fns[fn.name] && dec_fns[fn.name].pre ? dec_fns[fn.name].pre({that:this, arguments}) : 1
- const ret = fn.apply(this, arguments);
- // console.log('FSD',fn.name,ret, [this,...arguments]);
- const ret2 = dec_fns[fn.name] && dec_fns[fn.name].post ? dec_fns[fn.name].post({that:this, arguments}) : 0
- if (ret2){
- return ret2.ret
- }
- // const result = fn.apply(this, arguments);
- // console.log('Finished');
- return ret;
- }
- }
-
-
-
-
-
-
-
- function save_orig(){
-
- glob_orig = window.glob_orig || {
- Filmstrip:{},
- fs:{},
- rf_filmstrip:{},
- }
-
-
- glob_orig.Filmstrip = Object.assign({},glob_react.Filmstrip)
- glob_orig.fs = Object.assign({},glob_react.fs)
- glob_orig.rf_filmstrip = Object.assign({},glob_react.rf_filmstrip)
- save_orig = nop
- }
-
-
-
-
- if (window.glob_orig){
-
- save_orig = nop
- // save_orig()
- }
- if (!window.glob_orig && window.glob_react){
-
- // save_orig = nop
- save_orig()
- }
- if (window.glob_orig && window.glob_react){
- dec_fs()
- // save_orig = nop
- // save_orig()
- }
-
- // if ((!window.glob_orig) && ){
-
- // }
-
- // glob_react.rf_filmstrip.calculateThumbnailSizeForTileView
-
- // calculateThumbnailSizeForTileView
-
- dec_fns = {
- resizeThumbnailsForTileView:{
- pre:function(){
- // console.trace("resizeThumbnailsForTileView")
-
- },
- post:function(){
-
- },
-
- }
- }
-
-
- function rt(w,h = 0,force = true){
- h ? 0 : h = w / (16/9)
- glob_react.Filmstrip.resizeThumbnailsForTileView(w,h,force)
- }
-
- function dec_fs2(){
- var k,v
- glob_react.rf_filmstrip.calculateThumbnailSizeForTileView = FS_dec(glob_react.rf_filmstrip.calculateThumbnailSizeForTileView)
-
- // for ([k,v] of Object.entries(glob_orig.Filmstrip)){
- // for ([k,v] of Object.entries(glob_react.Filmstrip)){
- // clog("~",k,v.name)
- // glob_react.Filmstrip[k] = FS_dec(v)
- // }
-
- }
-
-
-
- function dec_fs(){
- var k,v
- for ([k,v] of Object.entries(glob_orig.Filmstrip)){
- // for ([k,v] of Object.entries(glob_react.Filmstrip)){
- clog("~",k,v.name)
- glob_react.Filmstrip[k] = FS_dec(v)
- }
-
- }
-
-
-
- modkeys = ["calculateThumbnailSizeForTileView",
- "TILE_VIEW_SIDE_MARGINS",
- "SET_TILE_VIEW_DIMENSIONS",]
-
- // glob_react.rf_filmstrip
- function check_mod_keys(){
- var k
- for (k of modkeys){
- clog(k,glob_react.rf_filmstrip[k])
- }
-
- }
-
- // function setTileViewDimensions_x(dimensions: Object, windowSize: Object) {
- function setTileViewDimensions_x() {
- // dev hook
- if (window.glob_dev_fns && window.glob_dev_fns.setTileViewDimensions){
- // var ret = window.glob_dev_fns.setTileViewDimensions.apply(this,...arguments)
- var ret = window.glob_dev_fns.setTileViewDimensions({that:this,args:arguments})
- if (ret){
- return ret.ret
- }
- }
-
- const thumbnailSize = calculateThumbnailSizeForTileView({
- ...dimensions,
- ...windowSize
- });
- const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
-
- return {
- type: SET_TILE_VIEW_DIMENSIONS,
- dimensions: {
- gridDimensions: dimensions,
- xtra:"xtra_val",
- thumbnailSize,
- filmstripWidth
- }
- };
- }
-
-
-
- glob_dev_fns.getTileViewGridDimensions = function(numberOfParticipants,state,maxColumns){
- clog("getTileViewGridDimensions....")
-
- }
- glob_dev_fns.setTileViewDimensions_x = function(o,dimensions,windowSize,that){
- // console.trace("STV")
- // SET_TILE_VIEW_DIMENSIONS
- windowSize = o.args[1]
- dimensions = o.args[0]
- clog("glob_dev_fns.setTileViewDimensions",arguments)
-
-
-
- var aspect = 16/9
-
- Thumbs = glob_react.Filmstrip._getThumbs()
-
-
- const topBottomPadding = 200;
- const sideMargins = 30 * 2;
-
-
- var thumbs_count = Thumbs.remoteThumbs.length + Thumbs.localThumb.length
-
- var avail_width = windowSize.clientWidth - sideMargins
- var avail_height = windowSize.clientHeight - topBottomPadding
- clog("",avail_width,avail_height)
- const r1 = avail_width/avail_height
-
- const r0 = aspect
-
- var clo = calc_layout2((avail_width/avail_height)/aspect,thumbs_count)
-
-
-
-
-
-
-
-
-
-
- // calc_layout2
- clog(windowSize,dimensions)
-
-
-
-
-
- var bw = avail_width
- var w2,width
- // clog(xgrp,xgrp.length,clo)
- if ((r1/r0) * (clo.c / clo.r) > 1) {
- w2 = bw / ((r1/r0) * clo.c)
- } else {
- w2 = bw / ( clo.r)
- }
-
- // width = 310
- // w2 =w2 - 12
- w2 =w2 - (10 * aspect)
- // w2 =w2 - 15
- // w2 =w2 - 16
- // width = Math.round(w2)
- width = Math.floor(w2)
-
-
-
- var height = Math.floor(width / (aspect))
- clog(clo)
- var avail_width2 = avail_width
- // if (clo.ni < clo.n){
- // r and c are misnamed!
-
- var col,max_width
- if (clo.c == 2){
- col = Math.ceil(clo.ni / 2)
- max_width = (col + .5) * width
- clog("MX...",col ,avail_width2,max_width)
- if (max_width < avail_width2){
- clog("MX",avail_width2,max_width)
- avail_width2 = max_width
- }
-
- }
-
- if (clo.ni <= clo.n + clo.c){
-
- // avail_width2 = Math.round(width * clo.)
- // avail_width2 = Math.round(avail_width2 - width/2)
-
- }
-
-
-
- // return
- const SET_TILE_VIEW_DIMENSIONS = "SET_TILE_VIEW_DIMENSIONS"
-
- return {ret:{
- type: SET_TILE_VIEW_DIMENSIONS,
- dimensions: {
- gridDimensions: {columns:clo.c,visibleRows:clo.r,},
- xtra:"xtra_val2",
- thumbnailSize:{height,width},
- filmstripWidth:avail_width2
- }
- }};
-
-
-
-
-
- /*
- return {
- dimensions:{
- columns:cl.c,
- visibleRows:cl.r,
- }
- }
-
- */
-
-
- return {ret:{
- type: SET_TILE_VIEW_DIMENSIONS,
- dimensions: {
- gridDimensions: dimensions,
- xtra:"xtra_val",
- thumbnailSize,
- filmstripWidth
- }
- }};
-
-
-
-
- }
-
- // ["Filmstrip", "fs", "rf_filmstrip"]
-
-
- function calc_layout2(a,ni){
- var r = 1
- var c = 1
- var n = 1
- clog("mx CL",ni,a)
- while (1){
- if (r * c < n){
- if ( (c + 1) * a < r + 1 ) {
- c++
- } else {
- r++
- }
- }
- n=r*c
- if (n >= ni){
- break
- }
- n=n+1
- }
- clog("CL",ni,r,c,n)
- return {
- r:r,
- c:c,
- n:n,
- ni:ni,
- }
- }
|