studio_dialogs.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. # THIS FILE IS A PART OF VCStudio
  2. # PYTHON 3
  3. ################################################################################
  4. # This file here will act like simple set of functions for the developer of the
  5. # software. But infect will be a little more complex behimith. To explain the
  6. # idea we need to look a little bit deeper into how this program functions and
  7. # draws UI peaces.
  8. # Basically every Layer py file is a set of instuction of how to draw a specific
  9. # UI on to the screen. Those function return the finished canvas. An image
  10. # basically. That the compositing layer (studio_gtk.py or pm_gtk.py ) combine
  11. # into a bigger picture.
  12. # There is a blur effect added to undernith layers if the top layer is drawn.
  13. # I do this by checking the win.url string. Each layer has they own urls.
  14. # Some are composited at all times. Some only if their url is the url. But all
  15. # get blurred if it's not their url.
  16. # Unfortunatly I can't make a function that will return a value. Because it means
  17. # to stop the drawing of the UI. And I need the UI to get to next frame in order
  18. # to draw the function's UI.
  19. # Let's say I want to add a link to an image to the story-editor. I click on the
  20. # add button. Next what I want to see is a searcher dialog appear. As soon as I
  21. # have selected the image I want to link, then the new link appears in the story
  22. # editor space which is automatically moving. Untill I place it.
  23. # For this I need to set up some kind of variable. And as soon as this variable
  24. # is not None. For example. We are doing the rest of the operation.
  25. # Step 0 : User Clicks the add button. And a funtion is called.
  26. # Step 1 : This function creates a dictionary with a variable NONE and a callable
  27. # Step 2 : win.url changes to the Layer which is the searcher.
  28. # Step 3 : User selects the images, or a file that he or she wanted to select.
  29. # Step 4 : This filename is being written into the variable that used to be NONE.
  30. # Step 5 : As soon as this variable is not NONE the callable is called.
  31. # Step 6 : This callable is the one that does the setup work.
  32. # Of course it would defeat the purpose if the callable always standard. It shold
  33. # be one of the inputs to the dialogue function.
  34. # Function template function_name(win, operation_name, callable):
  35. ################################################################################
  36. import os
  37. # GTK module ( Graphical interface
  38. import gi
  39. gi.require_version('Gtk', '3.0')
  40. from gi.repository import Gtk
  41. from gi.repository import GLib
  42. from gi.repository import Gdk
  43. import cairo
  44. # Own modules
  45. from settings import settings
  46. from settings import talk
  47. from project_manager import pm_project
  48. from studio import analytics
  49. from studio import studio_nodes
  50. #UI modules
  51. from UI import UI_elements
  52. from UI import UI_color
  53. ################################################### ########################
  54. # # #
  55. from studio import studio_file_selectLayer # # These modules he- #
  56. from studio import studio_asset_selectLayer # # re. Are the modu- #
  57. from studio import studio_shot_linkLayer # # les that are ac- #
  58. from studio import studio_asset_configureLayer # # tual UI of dialo- #
  59. from studio import studio_renderLayer # # gs that I was ta- #
  60. from studio import studio_vseLayer # # lking about at #
  61. from UI import UI_helpDialog # # the top. #
  62. # # #
  63. ################################################### ########################
  64. # ^
  65. # |
  66. # Who does that?
  67. def file_select(win, name, call, force=False, IMAGE=True, BLEND=False, VIDEO=True,
  68. FILE=False, CHR=True, VEH=True, LOC=True, OBJ=True, RND=False, FOLDER=False,
  69. SEARCH=""):
  70. # This function will select files for any kind of stuff. It will search
  71. # through the files of the project. Similar to image searcher in the old
  72. # organizer.
  73. if name not in win.current["calls"]:
  74. win.current["calls"][name] = {
  75. "var" :None, # This is the variable that we are waiting for
  76. "call":call, # This is what it's going to run when it's done
  77. "url" :"file_select",
  78. "back":win.url,# This is where it's going to come back when it's done
  79. "draw":studio_file_selectLayer.layer
  80. }
  81. # Now let's make a container to save those setting between frames
  82. if force or "file_selector" not in win.current:
  83. win.current["file_selector"] = {
  84. "image" :IMAGE,
  85. "blender":BLEND,
  86. "video" :VIDEO,
  87. "file" :FILE,
  88. "chr" :CHR,
  89. "veh" :VEH,
  90. "loc" :LOC,
  91. "obj" :OBJ,
  92. "vse" :RND,
  93. "folder" :FOLDER
  94. }
  95. # Search text
  96. win.text["file_select_search"] = {
  97. "text" :SEARCH, # Actuall text you are editing.
  98. "cursor":[len(str(SEARCH)),len(str(SEARCH))], # Cursor
  99. "insert":False, # Whether the insert mode is on
  100. "scroll":"file_select_search_scroll" # If multiline. The pointer for the scroll value.
  101. }
  102. # Let's activate the text so you could type immediatly
  103. win.textactive = "file_select_search"
  104. # Let's clear the LMB just in case
  105. win.previous["LMB"] = False
  106. def asset_select(win, name, call, force=False, cur="chr", SEARCH=""):
  107. # This function will be an asset selector. The idea it to be something
  108. # in between itemselector and assets in the same time.
  109. # If you remember
  110. # in the Blender-Organizer there were tabs on the top bar. If you click
  111. # on Characters let's say, you would get a full screen selector to enter
  112. # a given character.
  113. # But for linking and such you would get a small window with only names.
  114. # But with a search dialog.
  115. # Well this dialog will be some kind a merge of both of them. Having both
  116. # a very good cell-based preview type list and search. And could be used
  117. # not only to enter the asset, but also for linking and such.
  118. if name not in win.current["calls"]:
  119. win.current["calls"][name] = {
  120. "var" :None, # This is the variable that we are waiting for
  121. "call":call, # This is what it's going to run when it's done
  122. "url" :"asset_select",
  123. "back":win.url,# This is where it's going to come back when it's done
  124. "draw":studio_asset_selectLayer.layer
  125. }
  126. # Now let's make a container to save those setting between frames
  127. if force or "asset_cur" not in win.current:
  128. win.current["asset_cur"] = cur
  129. # Search text
  130. win.text["asset_select_search"] = {
  131. "text" :SEARCH, # Actuall text you are editing.
  132. "cursor":[len(str(SEARCH)),len(str(SEARCH))], # Cursor
  133. "insert":False, # Whether the insert mode is on
  134. "scroll":"asset_select_search_scroll" # If multiline. The pointer for the scroll value.
  135. }
  136. # Let's activate the text so you could type immediatly
  137. win.textactive = "asset_select_search"
  138. # Wiping the history of the assets. See studio/studio_asset_selectLayer.py
  139. win.assets = {}
  140. # Let's clear the LMB just in case
  141. win.previous["LMB"] = False
  142. def asset_link(win, name, call, filename, force=False):
  143. # This function will configure the linking of the assets into animation files
  144. # it's in theory a quite simple operation, but requires nesting of dialogs.
  145. # which is untested by the time I'm writting this comment.
  146. if name not in win.current["calls"]:
  147. win.current["calls"][name] = {
  148. "var" :None, # This is the variable that we are waiting for
  149. "call":call, # This is what it's going to run when it's done
  150. "url" :"asset_link",
  151. "back":win.url,# This is where it's going to come back when it's done
  152. "draw":studio_shot_linkLayer.layer
  153. }
  154. # let's prepare the data for this operation
  155. if force or "linking_asset_data" not in win.current\
  156. or win.current["linking_asset_data"]["linking_to"] != filename:
  157. win.current["linking_asset_data"] = {
  158. "linking_to":filename,
  159. "assets":[],
  160. "read":False,
  161. "selected":"",
  162. "mode":"link",
  163. "fraction":0,
  164. "process":False
  165. }
  166. if win.current["linking_asset_data"]["fraction"]:
  167. win.current["linking_asset_data"]["assets"] = []
  168. win.current["linking_asset_data"]["fraction"] = 0
  169. # Wiping the history of the assets. See studio/studio_asset_selectLayer.py
  170. win.assets = {}
  171. # Let's clear the LMB just in case
  172. win.previous["LMB"] = False
  173. def asset_configure(win, name, call, asset, force=False):
  174. # This function going to configure assets. More deatailed explanation is
  175. # in the file: studio/studio_asset_configureLayer.py
  176. if name not in win.current["calls"]:
  177. win.current["calls"][name] = {
  178. "var" :None, # This is the variable that we are waiting for
  179. "call":call, # This is what it's going to run when it's done
  180. "url" :"asset_configure",
  181. "back":win.url,# This is where it's going to come back when it's done
  182. "draw":studio_asset_configureLayer.layer
  183. }
  184. # let's prepare the data for this operation
  185. if force or "asset_configure" not in win.current\
  186. or win.current["asset_configure"]["asset"] != asset:
  187. win.current["asset_configure"] = {
  188. "asset":asset,
  189. "blend_to_copy":"",
  190. "collections":{},
  191. "step3_button":"collection",
  192. "apply":False
  193. }
  194. # Wiping the history of the assets. See studio/studio_asset_selectLayer.py
  195. win.assets = {}
  196. # Let's clear the LMB just in case
  197. win.previous["LMB"] = False
  198. def render(win, name, call, filename="", force=False):
  199. # This function going to launch a window that shows all current renders and
  200. # confuge them.
  201. if name not in win.current["calls"]:
  202. win.current["calls"][name] = {
  203. "var" :None, # This is the variable that we are waiting for
  204. "call":call, # This is what it's going to run when it's done
  205. "url" :"render",
  206. "back":win.url,# This is where it's going to come back when it's done
  207. "draw":studio_renderLayer.layer
  208. }
  209. # let's prepare the data for this operation
  210. if force or "renders_window" not in win.current\
  211. or win.current["renders_window"]["filename"] != filename:
  212. win.current["renders_window"] = {
  213. "filename":filename
  214. }
  215. # Wiping the history of the assets. See studio/studio_asset_selectLayer.py
  216. win.assets = {}
  217. # Let's clear the LMB just in case
  218. win.previous["LMB"] = False
  219. def vse(win, name, call, filename="", force=False):
  220. # This function going to select vse blend files.
  221. if name not in win.current["calls"]:
  222. win.current["calls"][name] = {
  223. "var" :None, # This is the variable that we are waiting for
  224. "call":call, # This is what it's going to run when it's done
  225. "url" :"vse",
  226. "back":win.url,# This is where it's going to come back when it's done
  227. "draw":studio_vseLayer.layer
  228. }
  229. # Let's clear the LMB just in case
  230. win.previous["LMB"] = False
  231. def help(win, name, call, filename="", force=False, SEARCH=""):
  232. # This function going to select vse blend files.
  233. if name not in win.current["calls"]:
  234. win.current["calls"][name] = {
  235. "var" :None, # This is the variable that we are waiting for
  236. "call":call, # This is what it's going to run when it's done
  237. "url" :"help",
  238. "back":win.url,# This is where it's going to come back when it's done
  239. "draw":UI_helpDialog.layer
  240. }
  241. # Let's clear the LMB just in case
  242. win.previous["LMB"] = False
  243. win.text["in_help"] = {
  244. "text" :SEARCH, # Actuall text you are editing.
  245. "cursor":[len(str(SEARCH)),len(str(SEARCH))], # Cursor
  246. "insert":False, # Whether the insert mode is on
  247. "scroll":"in_help_search_scroll" # If multiline. The pointer for the scroll value.
  248. }