Преглед на файлове

Работа над двухстраничным режимом

Book Pauk преди 4 години
родител
ревизия
cfc946ad12

+ 75 - 2
client/components/Reader/SettingsPage/include/ViewTab/Mode.inc

@@ -8,13 +8,86 @@
     </div>
     </div>
 </div>
 </div>
 
 
+<div class="part-header">Страницы</div>
 <div class="item row">
 <div class="item row">
-    <div class="label-2">Отступ</div>
+    <div class="label-2">Отступ границ</div>
     <div class="col row">
     <div class="col row">
-        <NumInput class="col-left" v-model="dualIndentLR" :min="0" :max="2000" :disable="!dualPageMode">
+        <NumInput class="col-left" v-model="indentLR" :min="0" :max="2000">
+            <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                Слева/справа от края экрана
+            </q-tooltip>
+        </NumInput>
+        <div class="q-px-sm"/>
+        <NumInput class="col" v-model="indentTB" :min="0" :max="2000">
+            <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                Сверху/снизу от края экрана
+            </q-tooltip>
+        </NumInput>
+    </div>
+</div>
+
+<div v-show="dualPageMode" class="item row">
+    <div class="label-2">Отступ внутри</div>
+    <div class="col row">
+        <NumInput class="col-left" v-model="dualIndentLR" :min="0" :max="2000">
             <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
             <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
                 Слева/справа внутри страницы
                 Слева/справа внутри страницы
             </q-tooltip>
             </q-tooltip>
         </NumInput>
         </NumInput>
     </div>
     </div>
+</div>
+
+<div v-show="dualPageMode">
+    <div class="part-header">Разделитель</div>
+    <div class="item row">
+        <div class="label-2">Ширина (px)</div>
+        <div class="col row">
+            <NumInput class="col-left" v-model="dualDivWidth" :min="0" :max="100">
+                <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                    Ширина разделителя
+                </q-tooltip>
+            </NumInput>
+        </div>
+    </div>
+
+    <div class="item row">
+        <div class="label-2">Высота (%)</div>
+        <div class="col row">
+            <NumInput class="col-left" v-model="dualDivHeight" :min="0" :max="100">
+                <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                    Высота разделителя
+                </q-tooltip>
+            </NumInput>
+        </div>
+    </div>
+
+    <div class="item row">
+        <div class="label-2">Прозрачность</div>
+        <div class="col row">
+            <NumInput class="col-left" v-model="dualDivColorAlpha" :min="0" :max="1" :digits="2" :step="0.1"/>
+        </div>
+    </div>
+
+    <div class="item row">
+        <div class="label-2">Заполнение (px)</div>
+        <div class="col row">
+            <NumInput class="col-left" v-model="dualDivStrokeFill" :min="0" :max="2000">
+                <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                    Заполнение пунктира
+                </q-tooltip>
+            </NumInput>
+        </div>
+    </div>
+
+    <div class="item row">
+        <div class="label-2">Промежуток (px)</div>
+        <div class="col row">
+            <NumInput class="col-left" v-model="dualDivStrokeGap" :min="0" :max="2000">
+                <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
+                    Промежуток пунктира
+                </q-tooltip>
+            </NumInput>
+        </div>
+    </div>
+
 </div>
 </div>

+ 0 - 17
client/components/Reader/SettingsPage/include/ViewTab/Text.inc

@@ -15,23 +15,6 @@
     </div>
     </div>
 </div>
 </div>
 
 
-<div class="item row">
-    <div class="label-2">Отступ</div>
-    <div class="col row">
-        <NumInput class="col-left" v-model="indentLR" :min="0" :max="2000">
-            <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
-                Слева/справа
-            </q-tooltip>
-        </NumInput>
-        <div class="q-px-sm"/>
-        <NumInput class="col" v-model="indentTB" :min="0" :max="2000">
-            <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
-                Сверху/снизу
-            </q-tooltip>
-        </NumInput>
-    </div>
-</div>
-
 <div class="item row">
 <div class="item row">
     <div class="label-2">Сдвиг</div>
     <div class="label-2">Сдвиг</div>
     <div class="col row">
     <div class="col row">

+ 22 - 6
client/components/Reader/TextPage/DrawHelper.js

@@ -130,9 +130,9 @@ export default class DrawHelper {
         const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
         const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
 
 
         const boxH = this.h + (isScrolling ? this.lineHeight : 0);
         const boxH = this.h + (isScrolling ? this.lineHeight : 0);
-        let out = `<div style="width: ${this.boxW}px; height: ${boxH}px;` + 
-            ` position: relative; top: ${this.fontSize*this.textShift}px; color: ${this.textColor}; font: ${font}; ${justify}` +
-            ` line-height: ${this.lineHeight}px; white-space: nowrap;">`;
+        let out = `<div class="row no-wrap" style="width: ${this.boxW}px; height: ${boxH}px;` + 
+            ` position: absolute; top: ${this.fontSize*this.textShift}px; color: ${this.textColor}; font: ${font}; ${justify}` +
+            ` line-height: ${this.lineHeight}px; white-space: nowrap; vertical-align: middle;">`;
 
 
         let imageDrawn1 = new Set();
         let imageDrawn1 = new Set();
         let imageDrawn2 = new Set();
         let imageDrawn2 = new Set();
@@ -165,18 +165,34 @@ export default class DrawHelper {
 
 
         //отрисовка строк
         //отрисовка строк
         if (!this.dualPageMode) {
         if (!this.dualPageMode) {
+            out += `<div class="fit">`;
             for (let i = 0; i < len; i++) {
             for (let i = 0; i < len; i++) {
                 out += this.drawLine(lines[i], i, 0, sel, imageDrawn1);
                 out += this.drawLine(lines[i], i, 0, sel, imageDrawn1);
             }
             }
+            out += `</div>`;
         } else {
         } else {
-            out += `<div style="width: ${this.w}px; margin: 0 ${this.dualIndentLR}px 0 ${this.dualIndentLR}px; position: relative; display: inline-block;">`;
-            const l2 = parseInt(Math.ceil(len/2), 10);
+            //левая страница
+            out += `<div style="width: ${this.w}px; margin-left: ${this.dualIndentLR}px; position: relative;">`;
+            const l2 = (this.pageRowsCount > len ? len : this.pageRowsCount);
             for (let i = 0; i < l2; i++) {
             for (let i = 0; i < l2; i++) {
                 out += this.drawLine(lines[i], i, 0, sel, imageDrawn1);
                 out += this.drawLine(lines[i], i, 0, sel, imageDrawn1);
             }
             }
             out += '</div>';
             out += '</div>';
 
 
-            out += `<div style="width: ${this.w}px; margin: 0 ${this.dualIndentLR}px 0 ${this.dualIndentLR}px; position: relative; display: inline-block;">`;
+            //разделитель
+            out += `<div style="width: ${this.dualIndentLR*2}px; top: ${-this.fontSize*this.textShift}px; position: relative">` +
+                `<div class="fit row justify-center items-center">` +
+                    `<div style="height: ${Math.round(boxH*this.dualDivHeight/100)}px; width: ${this.dualDivWidth}px;` + 
+                        `background-image: url(&quot;data:image/svg+xml;utf8,<svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'>` +
+                            //`<rect width='100%' height='100%' style='fill: none; stroke: white; stroke-width: 4; stroke-dasharray: 5 20'/>` +
+                            `<line x1='0' y1='0' x2='0' y2='100%' stroke='${this.dualDivColor}' stroke-width='100%' stroke-dasharray='${this.dualDivStrokeFill} ${this.dualDivStrokeGap}'/>` +
+                        `</svg>&quot;);">` +
+                    `</div>` +
+                `</div>` +
+            `</div>`;
+
+            //правая страница
+            out += `<div style="width: ${this.w}px; margin-right: ${this.dualIndentLR}px; position: relative;">`;
             for (let i = l2; i < len; i++) {
             for (let i = l2; i < len; i++) {
                 out += this.drawLine(lines[i], i, l2, sel, imageDrawn2);
                 out += this.drawLine(lines[i], i, l2, sel, imageDrawn2);
             }
             }

+ 11 - 4
client/components/Reader/TextPage/TextPage.vue

@@ -169,8 +169,8 @@ class TextPage extends Vue {
         this.h = this.scrollHeight - 2*this.indentTB;
         this.h = this.scrollHeight - 2*this.indentTB;
 
 
         this.lineHeight = this.fontSize + this.lineInterval;
         this.lineHeight = this.fontSize + this.lineInterval;
-        const pageRowsCount = 1 + Math.floor((this.h - this.lineHeight + this.lineInterval/2)/this.lineHeight);
-        this.pageLineCount = (this.dualPageMode ? pageRowsCount*2 : pageRowsCount)
+        this.pageRowsCount = 1 + Math.floor((this.h - this.lineHeight + this.lineInterval/2)/this.lineHeight);
+        this.pageLineCount = (this.dualPageMode ? this.pageRowsCount*2 : this.pageRowsCount)
 
 
         //stuff
         //stuff
         this.currentAnimation = '';
         this.currentAnimation = '';
@@ -190,8 +190,16 @@ class TextPage extends Vue {
         this.drawHelper.lastBook = this.lastBook;
         this.drawHelper.lastBook = this.lastBook;
         this.drawHelper.book = this.book;
         this.drawHelper.book = this.book;
         this.drawHelper.parsed = this.parsed;
         this.drawHelper.parsed = this.parsed;
+        this.drawHelper.pageRowsCount = this.pageRowsCount;
         this.drawHelper.pageLineCount = this.pageLineCount;
         this.drawHelper.pageLineCount = this.pageLineCount;
+
         this.drawHelper.dualPageMode = this.dualPageMode;
         this.drawHelper.dualPageMode = this.dualPageMode;
+        this.drawHelper.dualIndentLR = this.dualIndentLR;
+        this.drawHelper.dualDivWidth = this.dualDivWidth;
+        this.drawHelper.dualDivHeight = this.dualDivHeight;
+        this.drawHelper.dualDivColor = this.hex2rgba(this.textColor || '#000000', this.dualDivColorAlpha);
+        this.drawHelper.dualDivStrokeFill = this.dualDivStrokeFill;
+        this.drawHelper.dualDivStrokeGap = this.dualDivStrokeGap;
 
 
         this.drawHelper.backgroundColor = this.backgroundColor;
         this.drawHelper.backgroundColor = this.backgroundColor;
         this.drawHelper.statusBarColor = this.statusBarColor;
         this.drawHelper.statusBarColor = this.statusBarColor;
@@ -207,7 +215,6 @@ class TextPage extends Vue {
         this.drawHelper.w = this.w;
         this.drawHelper.w = this.w;
         this.drawHelper.h = this.h;
         this.drawHelper.h = this.h;
         this.drawHelper.indentLR = this.indentLR;
         this.drawHelper.indentLR = this.indentLR;
-        this.drawHelper.dualIndentLR = this.dualIndentLR;
         this.drawHelper.textAlignJustify = this.textAlignJustify;
         this.drawHelper.textAlignJustify = this.textAlignJustify;
         this.drawHelper.lineHeight = this.lineHeight;
         this.drawHelper.lineHeight = this.lineHeight;
         this.drawHelper.context = this.context;
         this.drawHelper.context = this.context;
@@ -259,7 +266,7 @@ class TextPage extends Vue {
         }
         }
 
 
         //scrolling page
         //scrolling page
-        const pageSpace = this.scrollHeight - pageRowsCount*this.lineHeight;
+        const pageSpace = this.scrollHeight - this.pageRowsCount*this.lineHeight;
         let top = pageSpace/2;
         let top = pageSpace/2;
         if (this.showStatusBar)
         if (this.showStatusBar)
             top += this.statusBarHeight*(this.statusBarTop ? 1 : 0);
             top += this.statusBarHeight*(this.statusBarTop ? 1 : 0);

+ 6 - 0
client/store/modules/reader.js

@@ -225,8 +225,14 @@ const settingDefaults = {
     indentTB: 0,// px, отступ всего текста сверху и снизу
     indentTB: 0,// px, отступ всего текста сверху и снизу
     wordWrap: true,//перенос по слогам
     wordWrap: true,//перенос по слогам
     keepLastToFirst: false,// перенос последней строки в первую при листании
     keepLastToFirst: false,// перенос последней строки в первую при листании
+
     dualPageMode: false,
     dualPageMode: false,
     dualIndentLR: 10,// px, отступ слева и справа внутри страницы в двухстраничном режиме
     dualIndentLR: 10,// px, отступ слева и справа внутри страницы в двухстраничном режиме
+    dualDivWidth: 4,// px, ширина разделителя
+    dualDivHeight: 96,// процент, высота разделителя
+    dualDivColorAlpha: 1,// прозрачность разделителя
+    dualDivStrokeFill: 1,// px, заполнение пунктира
+    dualDivStrokeGap: 1,// px, промежуток пунктира
 
 
     showStatusBar: true,
     showStatusBar: true,
     statusBarTop: false,// top, bottom
     statusBarTop: false,// top, bottom