Skip to content

Commit

Permalink
New: Option to start reading in full screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Oct 11, 2023
1 parent 78646fe commit cf3de6e
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 32 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

##### 🚀 New Features

- Option to open directly in continue reading instead of the file list
- Option to open directly in continue reading instead of the file list [`78646fe`](https://github.com/ollm/OpenComic/commit/78646fe6f4a17be6fc9fd0c940fd97d438c812c1)
- Option to start reading in full screen

##### 🐛 Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "Preferències de lectura",
"maxMargin": "Marge horitzontal i vertical màxim",
"globalZoom": "Aplica un zoom global en comptes d'imatge a imatge (Només en lectura vertical)",
"startReadingInFullScreen": "Comença la lectura a pantalla completa",
"trackingAtTheEnd": "Seguiment al final del capítol/tom"
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "Reading preferences",
"maxMargin": "Maximum horizontal and vertical margin",
"globalZoom": "Applies a global zoom instead of image by image (Only in vertical reading)",
"startReadingInFullScreen": "Empieza a leer en pantalla completa",
"trackingAtTheEnd": "Tracking at the end of the chapter/volume"
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "Preferencias de lectura",
"maxMargin": "Margen horizontal y vertical máximo",
"globalZoom": "Aplica un zoom global en vez de imagen a imagen (Solo en lectura vertical)",
"startReadingInFullScreen": "Empieza la lectura en pantalla completa",
"trackingAtTheEnd": "Seguimiento al final del capítulo/tomo"
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
1 change: 1 addition & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"main": "",
"maxMargin": "",
"globalZoom": "",
"startReadingInFullScreen": "",
"trackingAtTheEnd": ""
},
"navigation": {
Expand Down
13 changes: 13 additions & 0 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,19 @@ var readingActive = false, skipNextComic = false, skipPreviousComic = false;
async function openComic(animation = true, path = true, mainPath = true, end = false, fromGoBack = false, fromNextAndPrev = false, fromDeepLoad = false)
{
// Start reading comic
if(config.readingStartReadingInFullScreen && !fromNextAndPrev && !fromGoBack)
{
let win = electronRemote.getCurrentWindow();
let isFullScreen = win.isFullScreen();

if(!isFullScreen)
{
reading.hideContent(!isFullScreen);
win.setFullScreen(!isFullScreen);
win.setMenuBarVisibility(isFullScreen);
}
}

currentPathScrollTop[currentPath === false ? 0 : currentPath] = template.contentRight().children().scrollTop();
currentPath = path;

Expand Down
59 changes: 29 additions & 30 deletions scripts/reading.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,24 +781,27 @@ function returnLargerImage(index)
{
if(_config.readingDoublePage && !_config.readingWebtoon)
{
var imageHeight0 = template.contentRight('.image-position'+(index)+'-0').height();
var imageHeight1 = template.contentRight('.image-position'+(index)+'-1').height();
let image0 = template._contentRight().querySelector('.image-position'+(index)+'-0');
let image1 = template._contentRight().querySelector('.image-position'+(index)+'-1');

if(imageHeight1 === undefined || imageHeight0 >= imageHeight1)
{
var image = template.contentRight('.image-position'+(index)+'-0');
}
let rect0 = image0 ? image0.getBoundingClientRect() : false;
let rect1 = image1 ? image1.getBoundingClientRect() : false;

let imageHeight0 = rect0.height || 0;
let imageHeight1 = rect1.height || 0;

if(imageHeight0 >= imageHeight1)
return {image: image0, height: imageHeight0, top: rect0.top || 0};
else
{
var image = template.contentRight('.image-position'+(index)+'-1');
}
return {image: image1, height: imageHeight1, top: rect1.top || 0};
}
else
{
var image = template.contentRight('.image-position'+(index)+'-0');
}
let image = template._contentRight().querySelector('.image-position'+(index)+'-0');
let rect = image ? image.getBoundingClientRect() : false;

return image;
return {image: image, height: rect.height || 0, top: rect.top || 0};
}
}

var currentPageVisibility = 0, maxPageVisibility = 0, currentPageStart = true, readingDirection = true, disableOnScrollST = false;
Expand Down Expand Up @@ -827,13 +830,12 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)

if(((nextPrevious && currentPageStart) || !nextPrevious || end) && (readingViewIs('scroll') && (_config.readingViewAdjustToWidth || _config.readingWebtoon)))
{
image = returnLargerImage(eIndex-1);

imgHeight = image.height() + _config.readingMargin.top;
let largerImage = returnLargerImage(eIndex-1);
imgHeight = largerImage.height + _config.readingMargin.top;

if(imgHeight > contentHeight)
{
var pageVisibility = Math.floor(imgHeight / contentHeight)
let pageVisibility = Math.floor(imgHeight / contentHeight)

maxPageVisibility = pageVisibility;

Expand All @@ -856,9 +858,8 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
{
eIndex = currentIndex;

image = returnLargerImage(eIndex-1);

imgHeight = image.height() + _config.readingMargin.top;
let largerImage = returnLargerImage(eIndex-1);
imgHeight = largerImage.height + _config.readingMargin.top;

if(readingDirection)
currentPageVisibility++;
Expand All @@ -868,7 +869,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
if(nextPrevious !== false && nextPrevious !== true) currentPageVisibility = nextPrevious;
pageVisibilityIndex = currentPageVisibility;

var pageVisibility = Math.floor(imgHeight / contentHeight);
let pageVisibility = Math.floor(imgHeight / contentHeight);

maxPageVisibility = pageVisibility;

Expand All @@ -880,9 +881,8 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
{
eIndex = index;

image = returnLargerImage(eIndex-1);

imgHeight = image.height() + _config.readingMargin.top;
let largerImage = returnLargerImage(eIndex-1);
imgHeight = largerImage.height + _config.readingMargin.top;

if(imgHeight > contentHeight)
{
Expand Down Expand Up @@ -917,23 +917,22 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
}
else if(readingViewIs('scroll'))
{
var image = returnLargerImage(eIndex-1);

var scrollTop = (image.offset().top - rect.top) + content.scrollTop;
let largerImage = returnLargerImage(eIndex-1);
let scrollTop = (largerImage.top - rect.top) + content.scrollTop;

var scrollSum = 0;
let scrollSum = 0;

if((readingViewIs('scroll') && (_config.readingViewAdjustToWidth || _config.readingWebtoon)) && pageVisibilityIndex !== false)
{
imgHeight = image.height() + _config.readingMargin.top;

if(imgHeight > contentHeight)
{
var pageVisibility = Math.floor(imgHeight / contentHeight);
let pageVisibility = Math.floor(imgHeight / contentHeight);

maxPageVisibility = pageVisibility;

var contentHeightRes = ((contentHeight * pageVisibility) - imgHeight) / pageVisibility;
let contentHeightRes = ((contentHeight * pageVisibility) - imgHeight) / pageVisibility;

scrollSum = ((contentHeight - contentHeightRes) - contentHeight / pageVisibility) * pageVisibilityIndex;
}
Expand All @@ -952,7 +951,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
$(content).stop(true).animate({scrollTop: (scrollTop + scrollSum)+'px'}, animationDurationMS);
}

var newIndex = (eIndex - 1);
let newIndex = (eIndex - 1);

if(_config.readingManga && !readingViewIs('scroll'))
newIndex = (indexNum - newIndex) - 1;
Expand Down
6 changes: 6 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ function setGlobalZoom(value)
storage.updateVar('config', 'readingGlobalZoom', value);
}

function setStartReadingInFullScreen(value)
{
storage.updateVar('config', 'readingStartReadingInFullScreen', value);
}

function setTrackingAtTheEnd(value)
{
storage.updateVar('config', 'readingTrackingAtTheEnd', value);
Expand Down Expand Up @@ -350,6 +355,7 @@ module.exports = {
start: start,
setMaxMargin: setMaxMargin,
setGlobalZoom: setGlobalZoom,
setStartReadingInFullScreen: setStartReadingInFullScreen,
setTrackingAtTheEnd: setTrackingAtTheEnd,
setIgnoreSingleFoldersLibrary: setIgnoreSingleFoldersLibrary,
setWhenOpenFolderContinueReading: setWhenOpenFolderContinueReading,
Expand Down
3 changes: 2 additions & 1 deletion scripts/storage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var changes = 53; // Update this if readingPagesConfig is updated
var changes = 54; // Update this if readingPagesConfig is updated

var readingPagesConfig = {
readingConfigName: '',
Expand Down Expand Up @@ -80,6 +80,7 @@ var storageDefault = {
readingHideBarHeaderFullScreen: true,
readingMaxMargin: 400,
readingGlobalZoom: true,
readingStartReadingInFullScreen: false,
readingTrackingAtTheEnd: true,
controllerDeadZone: 0.06,
startInFullScreen: false,
Expand Down
8 changes: 8 additions & 0 deletions templates/settings.content.right.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ <h2 class="headline-small">{{language.settings.reading.main}}</h2>
</div>
</div>

<div class="menu-simple-text gamepad-item">
{{language.settings.reading.startReadingInFullScreen}}
<div class="switch{{#if config.readingStartReadingInFullScreen}} a{{/if}}" on="settings.setStartReadingInFullScreen(true)" off="settings.setStartReadingInFullScreen(false)">
<div></div>
<svg viewBox="0 0 52 32"><path d="M 8,0 C 3.58,0 0,3.58 0,8 0,12.42 3.58,16 8,16 8,16 8,16 8,16 12.42,16 16,12.42 16,8 16,3.58 12.42,0 8,0 8,0 8,0 8,0 Z"></path></svg>
</div>
</div>

<div class="menu-simple-text gamepad-item">
{{language.settings.reading.trackingAtTheEnd}}
<div class="switch{{#if config.readingTrackingAtTheEnd}} a{{/if}}" on="settings.setTrackingAtTheEnd(true)" off="settings.setTrackingAtTheEnd(false)">
Expand Down

0 comments on commit cf3de6e

Please sign in to comment.