-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolbar.py
More file actions
64 lines (52 loc) · 1.87 KB
/
Copy pathtoolbar.py
File metadata and controls
64 lines (52 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""toolbar.py — toolbar action callbacks (add_text, add_obj, new_document, on_preset, on_lang_change)."""
import dearpygui.dearpygui as dpg
import state
import draw
import panels
import history
import i18n
def add_text(s, u):
state.st["add_mode"] = "text"
state.set_status(i18n.t("status_draw_text"))
def add_obj(s, u):
state.st["add_mode"] = "obj"
state.set_status(i18n.t("status_draw_obj"))
def on_style_mode_change(s, val: str) -> None:
state.g_style_mode = val
is_photo = (val == "photo")
for tag in ("ui_text_style_photo", "inp_style_photo"):
if dpg.does_item_exist(tag):
dpg.configure_item(tag, show=is_photo)
for tag in ("ui_text_style_art_style", "inp_style_art_style"):
if dpg.does_item_exist(tag):
dpg.configure_item(tag, show=not is_photo)
def new_document(s, u):
history.push_history()
state.st["elements"].clear()
state.st["selected"] = -1
state.st["add_mode"] = None
state.st["drag"] = None
state.st["draw_start"] = None
for tag in ["inp_high", "inp_style_aesthetics", "inp_style_lighting",
"inp_style_photo", "inp_style_art_style", "inp_style_medium",
"inp_style_palette", "inp_bg"]:
if dpg.does_item_exist(tag):
dpg.set_value(tag, "")
# Reset to art mode
if dpg.does_item_exist("style_mode_radio"):
dpg.set_value("style_mode_radio", "art")
on_style_mode_change(None, "art")
panels.refresh_all()
state.set_status(i18n.t("status_new"))
def on_preset(s, name):
for p in state.PRESETS:
if p["name"] == name:
state.st["img_w"], state.st["img_h"] = p["w"], p["h"]
break
draw.redraw()
def on_lang_change(s, lang_name: str) -> None:
i18n.set_lang(lang_name)
import ui
ui.refresh_ui_strings()
panels.refresh_all()
state.set_status(i18n.t("status_initial"))