mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-05 05:33:28 +03:00
Implement View > Zoom > Custom Zoom
This commit is contained in:
parent
cbe40406a6
commit
37cdcdfb13
@ -252,6 +252,13 @@ CharacterSelectorDialogWindow .cancel {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#zoom_dialog .window_content {
|
||||||
|
padding: 2 4;
|
||||||
|
width: 50;
|
||||||
|
/* width: auto; */
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox .window_content {
|
MessageBox .window_content {
|
||||||
width: 50;
|
width: 50;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
41
paint.py
41
paint.py
@ -1411,7 +1411,46 @@ class PaintApp(App):
|
|||||||
def action_large_size(self) -> None:
|
def action_large_size(self) -> None:
|
||||||
self.magnification = 4
|
self.magnification = 4
|
||||||
def action_custom_zoom(self) -> None:
|
def action_custom_zoom(self) -> None:
|
||||||
self.warning_message_box(_("Paint"), "Not implemented.", "ok")
|
for old_window in self.query("#zoom_dialog").nodes:
|
||||||
|
old_window.close()
|
||||||
|
def handle_button(button):
|
||||||
|
if button.has_class("ok"):
|
||||||
|
min_zoom = 1
|
||||||
|
max_zoom = 16
|
||||||
|
try:
|
||||||
|
n = int(window.content.query_one("#zoom_input", Input).value)
|
||||||
|
if n < min_zoom or n > max_zoom:
|
||||||
|
raise ValueError
|
||||||
|
self.magnification = n
|
||||||
|
window.close()
|
||||||
|
except ValueError:
|
||||||
|
self.warning_message_box(_("Zoom"), _("Please enter an integer between %1 and %2.", str(min_zoom), str(max_zoom)), "ok")
|
||||||
|
else:
|
||||||
|
window.close()
|
||||||
|
window = DialogWindow(
|
||||||
|
id="zoom_dialog",
|
||||||
|
title=_("Custom Zoom"),
|
||||||
|
handle_button=handle_button,
|
||||||
|
)
|
||||||
|
window.content.mount(
|
||||||
|
Input(id="zoom_input", value=str(self.magnification), placeholder=_("Zoom")),
|
||||||
|
# Vertical(
|
||||||
|
# Horizontal(
|
||||||
|
# Static(_("Zoom to")),
|
||||||
|
# Input(id="zoom_input", value=str(self.magnification)),
|
||||||
|
# ),
|
||||||
|
# Horizontal(
|
||||||
|
# Static(_("Current zoom:")),
|
||||||
|
# Static(str(self.magnification)),
|
||||||
|
# ),
|
||||||
|
# ),
|
||||||
|
# Horizontal(
|
||||||
|
Button(_("OK"), classes="ok submit", variant="primary"),
|
||||||
|
Button(_("Cancel"), classes="cancel"),
|
||||||
|
# classes="buttons",
|
||||||
|
# )
|
||||||
|
)
|
||||||
|
self.mount(window)
|
||||||
def action_show_grid(self) -> None:
|
def action_show_grid(self) -> None:
|
||||||
self.warning_message_box(_("Paint"), "Not implemented.", "ok")
|
self.warning_message_box(_("Paint"), "Not implemented.", "ok")
|
||||||
def action_show_thumbnail(self) -> None:
|
def action_show_thumbnail(self) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user