Updated demo and fixed bug in spacing
Python CI / test (push) Successful in 4m10s

This commit is contained in:
2025-11-08 18:51:33 +01:00
parent 284a6e3393
commit 1993b0bf48
7 changed files with 1161 additions and 183 deletions
+78 -113
View File
@@ -192,131 +192,96 @@ def generate_reader_html(book_title: str, book_author: str, page_image_data: str
return html
def generate_settings_overlay() -> str:
def generate_settings_overlay(
font_scale: float = 1.0,
line_spacing: int = 5,
inter_block_spacing: int = 15,
word_spacing: int = 0,
page_size: tuple = (800, 1200)
) -> str:
"""
Generate HTML for the settings overlay.
Generate HTML for the settings overlay with current values.
Uses simple paragraphs with links, similar to TOC overlay,
since pyWebLayout doesn't support HTML tables.
Args:
font_scale: Current font scale (e.g., 1.0 = 100%, 1.2 = 120%)
line_spacing: Current line spacing in pixels
inter_block_spacing: Current inter-block spacing in pixels
word_spacing: Current word spacing in pixels
page_size: Page dimensions (width, height) for sizing the overlay
Returns:
HTML string for settings overlay
HTML string for settings overlay with clickable controls
"""
html = '''
# Format current values for display
font_percent = int(font_scale * 100)
html = f'''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.overlay-panel {
background-color: white;
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0,0,0,0.3);
padding: 20px;
min-width: 400px;
}
.overlay-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #ddd;
}
.overlay-title {
font-size: 24px;
font-weight: bold;
}
.close-button {
background-color: #dc3545;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.close-button:hover {
background-color: #c82333;
}
.settings-table {
width: 100%;
border-collapse: collapse;
}
.settings-table td {
padding: 10px;
border-bottom: 1px solid #eee;
}
.setting-label {
font-weight: bold;
width: 40%;
}
.setting-control {
width: 60%;
text-align: right;
}
.control-button {
background-color: #007bff;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 5px;
}
.control-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="overlay-panel">
<div class="overlay-header">
<span class="overlay-title">Settings</span>
<button class="close-button" id="btn-close">Close</button>
</div>
<body style="background-color: white; margin: 0; padding: 25px; font-family: Arial, sans-serif;">
<table class="settings-table">
<tr>
<td class="setting-label">Font Size</td>
<td class="setting-control">
<button class="control-button" id="btn-font-decrease">A-</button>
<button class="control-button" id="btn-font-increase">A+</button>
</td>
</tr>
<tr>
<td class="setting-label">Line Spacing</td>
<td class="setting-control">
<button class="control-button" id="btn-spacing-decrease">-</button>
<button class="control-button" id="btn-spacing-increase">+</button>
</td>
</tr>
<tr>
<td class="setting-label">Brightness</td>
<td class="setting-control">
<button class="control-button" id="btn-brightness-decrease">-</button>
<button class="control-button" id="btn-brightness-increase">+</button>
</td>
</tr>
<tr>
<td class="setting-label">WiFi</td>
<td class="setting-control">
<button class="control-button" id="btn-wifi">Configure</button>
</td>
</tr>
</table>
<h1 style="color: #000; margin: 0 0 8px 0; font-size: 24px; text-align: center; font-weight: bold;">
Settings
</h1>
<p style="text-align: center; color: #666; margin: 0 0 15px 0; padding-bottom: 12px;
border-bottom: 2px solid #ccc; font-size: 13px;">
Adjust reading preferences
</p>
<div style="margin: 15px 0;">
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0; border-left: 3px solid #007bff;">
<b>Font Size: {font_percent}%</b>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:font_decrease" style="text-decoration: none; color: #000;">Decrease [ - ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:font_increase" style="text-decoration: none; color: #000;">Increase [ + ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0; border-left: 3px solid #28a745;">
<b>Line Spacing: {line_spacing}px</b>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:line_spacing_decrease" style="text-decoration: none; color: #000;">Decrease [ - ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:line_spacing_increase" style="text-decoration: none; color: #000;">Increase [ + ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0; border-left: 3px solid #17a2b8;">
<b>Paragraph Spacing: {inter_block_spacing}px</b>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:block_spacing_decrease" style="text-decoration: none; color: #000;">Decrease [ - ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:block_spacing_increase" style="text-decoration: none; color: #000;">Increase [ + ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0; border-left: 3px solid #ffc107;">
<b>Word Spacing: {word_spacing}px</b>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:word_spacing_decrease" style="text-decoration: none; color: #000;">Decrease [ - ]</a>
</p>
<p style="padding: 12px; margin: 5px 0; background-color: #f0f0f0;">
<a href="setting:word_spacing_increase" style="text-decoration: none; color: #000;">Increase [ + ]</a>
</p>
</div>
<p style="text-align: center; margin: 15px 0 0 0; padding-top: 12px;
border-top: 2px solid #ccc; color: #888; font-size: 11px;">
Changes apply in real-time • Tap outside to close
</p>
</body>
</html>
'''