From f270ee2afa8fce8c2c4c4a9282bbe4a34fc73511 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Mon, 15 Jan 2018 21:52:24 +0000 Subject: [PATCH] cinera: Theatre Mode This also changes the hardcoded, unintegrated output to wrap cineraMenus and cineraPlayerContainer in a
, as newly reflected in the example template_player.html --- cinera/cinera.c | 15 +++-- cinera/cinera.css | 1 + cinera/cinera_player_post.js | 9 +++ cinera/cinera_player_pre.js | 88 ++++++++++++++++++++++++++++ cinera/examples/template_player.html | 6 +- 5 files changed, 113 insertions(+), 6 deletions(-) diff --git a/cinera/cinera.c b/cinera/cinera.c index a6255ee..317311c 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -14,7 +14,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 25 + .Patch = 26 }; // TODO(matt): Copy in the DB 3 stuff from cinera_working.c @@ -3258,6 +3258,7 @@ AppendedIdentifier: CopyBuffer(&CollationBuffers->Menus, &CreditsMenu); } + // TODO(matt): Maybe figure out a more succinct way to code this Help text CopyStringToBuffer(&CollationBuffers->Menus, "
\n" " ?\n" @@ -3265,7 +3266,9 @@ AppendedIdentifier: " ?

Keyboard Navigation

\n" "\n" "

Global Keys

\n" - " W, A, P / S, D, N Jump to previous / next marker
\n"); + " W, A, P / S, D, N Jump to previous / next marker
\n" + " t / T Toggle theatre / SUPERtheatre mode
\n" + ); if(HasFilterMenu) { @@ -3453,7 +3456,7 @@ AppendedIdentifier: CopyStringToBuffer(&CollationBuffers->Menus, ", References "); if(HasCreditsMenu) { - CopyStringToBuffer(&CollationBuffers->Menus, "and Credits Menus"); + CopyStringToBuffer(&CollationBuffers->Menus, "and Credits Menus"); } else { @@ -3791,11 +3794,15 @@ BuffersToHTML(buffers *CollationBuffers, template *Template, char *OutputPath, i " "); if(PageType == PAGE_PLAYER) { + CopyStringToBuffer(&Master, "
\n" + " "); CopyBuffer(&Master, &CollationBuffers->Menus); CopyStringToBuffer(&Master, "\n" - " "); + " "); CopyBuffer(&Master, &CollationBuffers->Player); CopyStringToBuffer(&Master, "\n" + " "); + CopyStringToBuffer(&Master, "
\n" " "); CopyBuffer(&Master, &CollationBuffers->ScriptPlayer); CopyStringToBuffer(&Master, "\n"); diff --git a/cinera/cinera.css b/cinera/cinera.css index 744048e..f655cd6 100644 --- a/cinera/cinera.css +++ b/cinera/cinera.css @@ -428,6 +428,7 @@ } .cineraPlayerContainer .markers_container { + flex-shrink: 0; overflow-y: scroll; position: relative; } diff --git a/cinera/cinera_player_post.js b/cinera/cinera_player_post.js index 82c2589..b00c28b 100644 --- a/cinera/cinera_player_post.js +++ b/cinera/cinera_player_post.js @@ -144,6 +144,15 @@ var focusedElement = null; var focusedIdentifier = null; var playerContainer = document.querySelector(".cineraPlayerContainer") +var cinera = playerContainer.parentNode; +var views = { + REGULAR: 1, + THEATRE: 2, + SUPERTHEATRE: 3, +}; +var cineraView = views.REGULAR; +initTheatre(); + var player = new Player(playerContainer, onRefChanged); window.addEventListener("resize", function() { player.updateSize(); }); document.addEventListener("keydown", function(ev) { diff --git a/cinera/cinera_player_pre.js b/cinera/cinera_player_pre.js index 4abb200..d1107da 100644 --- a/cinera/cinera_player_pre.js +++ b/cinera/cinera_player_pre.js @@ -412,6 +412,82 @@ function toggleMenuVisibility(element) { } } +function initTheatre() +{ + cinera.style.zIndex=64; + cinera.style.left=0; + cinera.style.top=0; + cinera.style.width="100%"; + cinera.style.height="100%"; +} + +function enterFullScreen_() +{ + if(!document.mozFullScreen && !document.webkitFullScreen) + { + if(cinera.mozRequestFullScreen) + { + cinera.mozRequestFullScreen(); + } + else + { + cinera.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); + } + } +} + +function leaveFullScreen_() +{ + if(document.mozCancelFullScreen) + { + document.mozCancelFullScreen(); + } + else + { + document.webkitExitFullscreen(); + } +} + +function toggleTheatreMode() { + switch(cineraView) + { + case views.REGULAR: + { + cinera.style.position="fixed"; + } cineraView = views.THEATRE; break; + case views.SUPERTHEATRE: + { + leaveFullScreen_(); + } + case views.THEATRE: + { + cinera.style.position="static"; + } cineraView = views.REGULAR; break; + } + player.updateSize(); +} + +function toggleSuperTheatreMode() +{ + switch(cineraView) + { + case views.REGULAR: + { + toggleTheatreMode(); + } + case views.THEATRE: + { + enterFullScreen_(); + } cineraView = views.SUPERTHEATRE; break; + case views.SUPERTHEATRE: + { + leaveFullScreen_(); + toggleTheatreMode(); + } cineraView = views.REGULAR; break; + } + player.updateSize(); +} + function handleKey(key) { var gotKey = true; switch (key) { @@ -439,6 +515,18 @@ function handleKey(key) { toggleMenuVisibility(creditsMenu) } } break; + case "t": { + if(cinera) + { + toggleTheatreMode(); + } + } break; + case "T": { + if(cinera) + { + toggleSuperTheatreMode(); + } + } break; case "Enter": { if(focusedElement) diff --git a/cinera/examples/template_player.html b/cinera/examples/template_player.html index 21e93b4..a4b3e8f 100644 --- a/cinera/examples/template_player.html +++ b/cinera/examples/template_player.html @@ -8,8 +8,10 @@ Awesome Contents

- - +
+ + +