pm_settingsLayer.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. ####################################
  2. # #
  3. # COPYRIGHT NOTICE #
  4. # #
  5. # This file is a part of Victori- #
  6. # ous Children Studio Organizer. #
  7. # Or simply VCStudio. Copyright #
  8. # of J.Y.Amihud. But don't be sad #
  9. # because I released the entire #
  10. # project under a GNU GPL license. #
  11. # You may use Version 3 or later. #
  12. # See www.gnu.org/licenses if your #
  13. # copy has no License file. Please #
  14. # note. Ones I used the GPL v2 for #
  15. # it. It's no longer the case. #
  16. # #
  17. ####################################
  18. import os
  19. # GTK module ( Graphical interface
  20. import gi
  21. gi.require_version('Gtk', '3.0')
  22. from gi.repository import Gtk
  23. from gi.repository import GLib
  24. from gi.repository import Gdk
  25. import cairo
  26. # Own modules
  27. from settings import settings
  28. from settings import talk
  29. from project_manager import pm_project
  30. #UI modules
  31. from UI import UI_elements
  32. from UI import UI_color
  33. def layer(win):
  34. # Making the layer
  35. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
  36. win.current['h'])
  37. layer = cairo.Context(surface)
  38. #text setting
  39. layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
  40. UI_color.set(layer, win, "dark_overdrop")
  41. layer.rectangle(
  42. 0,
  43. 0,
  44. win.current["w"],
  45. win.current["h"],
  46. )
  47. layer.fill()
  48. UI_color.set(layer, win, "node_background")
  49. UI_elements.roundrect(layer, win,
  50. win.current["w"]/2-250,
  51. 100,
  52. 500,
  53. win.current["h"]-200,
  54. 10)
  55. # Exit button
  56. def do():
  57. win.url = "project_manager"
  58. win.textactive = ""
  59. UI_elements.roundrect(layer, win,
  60. win.current["w"]/2+210,
  61. win.current["h"]-140,
  62. 40,
  63. 40,
  64. 10,
  65. button=do,
  66. icon="cancel",
  67. tip=talk.text("cancel"))
  68. # Clipping everything
  69. UI_elements.roundrect(layer, win,
  70. win.current["w"]/2-250,
  71. 100,
  72. 500,
  73. win.current["h"]-260,
  74. 10,
  75. fill=False)
  76. layer.clip()
  77. clip = [
  78. win.current["w"]/2-250,
  79. 100,
  80. 500,
  81. win.current["h"]-260]
  82. # Setting up the scroll
  83. if "pm_settings" not in win.scroll:
  84. win.scroll["pm_settings"] = 0
  85. current_Y = 0 # The max scroll value
  86. # Username
  87. UI_elements.image(layer, win, "settings/themes/"\
  88. +win.settings["Theme"]+"/icons/user.png",
  89. win.current["w"]/2-240,
  90. 110 + current_Y + win.scroll["pm_settings"],
  91. 40,
  92. 40)
  93. UI_elements.text(layer, win, "Username_setting",
  94. win.current["w"]/2-190,
  95. 110 + current_Y + win.scroll["pm_settings"],
  96. 420,
  97. 40,
  98. set_text=win.settings["Username"],
  99. tip=talk.text("username"))
  100. if win.text["Username_setting"]["text"] != win.settings["Username"]:
  101. def do():
  102. win.settings["Username"] = win.text["Username_setting"]["text"]
  103. settings.write("Username", win.settings["Username"])
  104. UI_elements.roundrect(layer, win,
  105. win.current["w"]/2-240+430,
  106. 110 + current_Y + win.scroll["pm_settings"],
  107. 40,
  108. 40,
  109. 10,
  110. button=do,
  111. icon="ok",
  112. tip=talk.text("checked"))
  113. current_Y += 50
  114. # Preparing lists.
  115. if "settings_lists" not in win.current:
  116. win.current["settings_lists"] = {}
  117. win.current["settings_lists"]["languages"] = settings.list_languages()
  118. win.current["settings_lists"]["languages_open"] = False
  119. win.current["settings_lists"]["themes"] = os.listdir(os.getcwd()+"/settings/themes")
  120. win.current["settings_lists"]["themes_open"] = False
  121. # Languages
  122. def do():
  123. win.current["settings_lists"]["languages_open"] = \
  124. not win.current["settings_lists"]["languages_open"]
  125. UI_elements.roundrect(layer, win,
  126. win.current["w"]/2-240,
  127. 110 + current_Y + win.scroll["pm_settings"],
  128. 450,
  129. 40,
  130. 10,
  131. button=do,
  132. icon="font",
  133. tip=talk.text("change_language"))
  134. UI_color.set(layer, win, "text_normal")
  135. layer.set_font_size(20)
  136. layer.move_to(win.current["w"]/2-180,
  137. current_Y + win.scroll["pm_settings"] + 135)
  138. layer.show_text(win.settings["Language"])
  139. current_Y += 50
  140. if win.current["settings_lists"]["languages_open"]:
  141. for lang in win.current["settings_lists"]["languages"]:
  142. if lang != win.settings["Language"]:
  143. UI_color.set(layer, win, "button_active")
  144. layer.move_to(win.current["w"]/2-227, 102 + current_Y + win.scroll["pm_settings"])
  145. layer.line_to(win.current["w"]/2-227, 152 + current_Y + win.scroll["pm_settings"])
  146. layer.stroke()
  147. def do():
  148. win.settings["Language"] = lang
  149. settings.write("Language", lang)
  150. win.current["settings_lists"]["languages_open"] = False
  151. UI_elements.roundrect(layer, win,
  152. win.current["w"]/2-220,
  153. 110 + current_Y + win.scroll["pm_settings"],
  154. 430,
  155. 40,
  156. 10,
  157. button=do,
  158. icon="font",
  159. tip=talk.text("set_language")+lang)
  160. UI_color.set(layer, win, "text_normal")
  161. layer.set_font_size(20)
  162. layer.move_to(win.current["w"]/2-150,
  163. current_Y + win.scroll["pm_settings"] + 135)
  164. layer.show_text(lang)
  165. current_Y += 50
  166. # Themes. Finally we have some themes to choose from. And a good place to
  167. # change them so the user would not need to do it manually. I think it's
  168. # important.
  169. # So there is a folder in the VCStudio installation called. settings/themes
  170. # which contains all of the themes. So let's look through it.
  171. # Themes
  172. def do():
  173. win.current["settings_lists"]["themes_open"] = \
  174. not win.current["settings_lists"]["themes_open"]
  175. UI_elements.roundrect(layer, win,
  176. win.current["w"]/2-240,
  177. 110 + current_Y + win.scroll["pm_settings"],
  178. 450,
  179. 40,
  180. 10,
  181. button=do,
  182. icon="theme",
  183. tip=talk.text("change_theme"))
  184. UI_color.set(layer, win, "text_normal")
  185. layer.set_font_size(20)
  186. layer.move_to(win.current["w"]/2-180,
  187. current_Y + win.scroll["pm_settings"] + 135)
  188. layer.show_text(win.settings["Theme"])
  189. current_Y += 50
  190. if win.current["settings_lists"]["themes_open"]:
  191. for lang in win.current["settings_lists"]["themes"]:
  192. if lang != win.settings["Theme"]:
  193. UI_color.set(layer, win, "button_active")
  194. layer.move_to(win.current["w"]/2-227, 102 + current_Y + win.scroll["pm_settings"])
  195. layer.line_to(win.current["w"]/2-227, 152 + current_Y + win.scroll["pm_settings"])
  196. layer.stroke()
  197. def do():
  198. win.settings["Theme"] = lang
  199. settings.write("Theme", lang)
  200. win.current["settings_lists"]["themes_open"] = False
  201. win.color = UI_color.get_table()
  202. UI_elements.roundrect(layer, win,
  203. win.current["w"]/2-220,
  204. 110 + current_Y + win.scroll["pm_settings"],
  205. 430,
  206. 40,
  207. 10,
  208. button=do,
  209. icon="theme",
  210. tip=talk.text("set_theme")+lang)
  211. UI_color.set(layer, win, "text_normal")
  212. layer.set_font_size(20)
  213. layer.move_to(win.current["w"]/2-150,
  214. current_Y + win.scroll["pm_settings"] + 135)
  215. layer.show_text(lang)
  216. current_Y += 50
  217. # BLUR
  218. blur_ok = "unchecked"
  219. if win.settings["Blur"]:
  220. blur_ok = "checked"
  221. def do():
  222. win.settings["Blur"] = not win.settings["Blur"]
  223. settings.write("Blur", win.settings["Blur"])
  224. UI_elements.roundrect(layer, win,
  225. win.current["w"]/2-240,
  226. 110 + current_Y + win.scroll["pm_settings"],
  227. 450,
  228. 40,
  229. 10,
  230. button=do,
  231. icon=blur_ok,
  232. tip=talk.text("Blur"))
  233. UI_color.set(layer, win, "text_normal")
  234. layer.set_font_size(20)
  235. layer.move_to(win.current["w"]/2-180,
  236. current_Y + win.scroll["pm_settings"] + 135)
  237. layer.show_text(talk.text("Blur"))
  238. current_Y += 50
  239. if win.settings["Blur"]:
  240. ablur_ok = "unchecked"
  241. if win.settings["Auto_De-Blur"]:
  242. ablur_ok = "checked"
  243. def do():
  244. win.settings["Auto_De-Blur"] = not win.settings["Auto_De-Blur"]
  245. settings.write("Auto_De-Blur", win.settings["Auto_De-Blur"])
  246. UI_elements.roundrect(layer, win,
  247. win.current["w"]/2-240,
  248. 110 + current_Y + win.scroll["pm_settings"],
  249. 450,
  250. 40,
  251. 10,
  252. button=do,
  253. icon=ablur_ok,
  254. tip=talk.text("Auto_De-Blur"))
  255. UI_color.set(layer, win, "text_normal")
  256. layer.set_font_size(20)
  257. layer.move_to(win.current["w"]/2-180,
  258. current_Y + win.scroll["pm_settings"] + 135)
  259. layer.show_text(talk.text("Auto_De-Blur"))
  260. current_Y += 50
  261. # ROUNDNESS
  262. # The roundness setting is a setting that will define how round the UI will
  263. # look. Potentially it can grow beyond 1.0, but will introduce weird rendering
  264. # artifacts. If you wan to do that be free to edit the Setting file manually.
  265. # I'm going to use the Scroller for this setting. But first we need an icon. And
  266. # I think the opengl icon is quite good for this.
  267. UI_elements.image(layer, win, "settings/themes/"\
  268. +win.settings["Theme"]+"/icons/opengl.png",
  269. win.current["w"]/2-240,
  270. 110 + current_Y + win.scroll["pm_settings"],
  271. 40,
  272. 40)
  273. # Then i'm going to hack my way to it. I'm going to use a scroll for a scrooled
  274. # window as the slider. Creativity.
  275. maxround = 1000 # I need it do be a higher number then from 0 to 1 since we want
  276. # to imulate the scroll
  277. if "roundness_setting" not in win.scroll:
  278. win.scroll["roundness_setting"] = 0 - win.settings["Roundness"] * 549
  279. if (0 - win.settings["Roundness"] * 549) != win.scroll["roundness_setting"]:
  280. win.settings["Roundness"] = (win.scroll["roundness_setting"] / 549)*-1
  281. settings.write("Roundness", win.settings["Roundness"])
  282. UI_elements.scroll_area(layer, win, "roundness_setting",
  283. int(win.current["w"]/2-200),
  284. 110 + current_Y + win.scroll["pm_settings"]+33,
  285. 450,
  286. 0,
  287. maxround,
  288. bar=True,
  289. sideways=True,
  290. url="settings_layer"
  291. )
  292. current_Y += 50
  293. # SMOOTH SCROLLING
  294. autod_ok = "unchecked"
  295. if win.settings['Scroll_smoothness']:
  296. autod_ok = "checked"
  297. def do():
  298. win.settings["Scroll_smoothness"] = not win.settings["Scroll_smoothness"]
  299. settings.write("Scroll_smoothness", win.settings["Scroll_smoothness"])
  300. UI_elements.roundrect(layer, win,
  301. win.current["w"]/2-240,
  302. 110 + current_Y + win.scroll["pm_settings"],
  303. 450,
  304. 40,
  305. 10,
  306. button=do,
  307. icon=autod_ok,
  308. tip=talk.text("Scroll_smoothness"))
  309. UI_color.set(layer, win, "text_normal")
  310. layer.set_font_size(20)
  311. layer.move_to(win.current["w"]/2-180,
  312. current_Y + win.scroll["pm_settings"] + 135)
  313. layer.show_text(talk.text("Scroll_smoothness"))
  314. current_Y += 50
  315. # AUTO DOWNLOAD IMAGES
  316. autod_ok = "unchecked"
  317. if win.settings["auto_download_images"]:
  318. autod_ok = "checked"
  319. def do():
  320. win.settings["auto_download_images"] = not win.settings["auto_download_images"]
  321. settings.write("auto_download_images", win.settings["auto_download_images"])
  322. UI_elements.roundrect(layer, win,
  323. win.current["w"]/2-240,
  324. 110 + current_Y + win.scroll["pm_settings"],
  325. 450,
  326. 40,
  327. 10,
  328. button=do,
  329. icon=autod_ok,
  330. tip=talk.text("auto_download_images"))
  331. UI_color.set(layer, win, "text_normal")
  332. layer.set_font_size(20)
  333. layer.move_to(win.current["w"]/2-180,
  334. current_Y + win.scroll["pm_settings"] + 135)
  335. layer.show_text(talk.text("auto_download_images"))
  336. current_Y += 50
  337. # AUTO CHECK FOR UPDATES
  338. autod_ok = "unchecked"
  339. if win.settings["check-for-updates"]:
  340. autod_ok = "checked"
  341. def do():
  342. win.settings["check-for-updates"] = not win.settings["check-for-updates"]
  343. settings.write("check-for-updates", win.settings["check-for-updates"])
  344. UI_elements.roundrect(layer, win,
  345. win.current["w"]/2-240,
  346. 110 + current_Y + win.scroll["pm_settings"],
  347. 450,
  348. 40,
  349. 10,
  350. button=do,
  351. icon=autod_ok,
  352. tip=talk.text("check-for-updates"))
  353. UI_color.set(layer, win, "text_normal")
  354. layer.set_font_size(20)
  355. layer.move_to(win.current["w"]/2-180,
  356. current_Y + win.scroll["pm_settings"] + 135)
  357. layer.show_text(talk.text("check-for-updates"))
  358. UI_elements.scroll_area(layer, win, "pm_settings",
  359. int(win.current["w"]/2-250),
  360. 100,
  361. 500,
  362. win.current["h"]-260,
  363. current_Y,
  364. bar=True,
  365. mmb=True,
  366. url="settings_layer"
  367. )
  368. return surface