Blender-Pipeline/studio/studio_dialogs.py

92 lines
3.5 KiB
Python

# THIS FILE IS A PART OF VCStudio
# PYTHON 3
################################################################################
# This file here will act like simple set of functions for the developer of the
# software. But infect will be a little more complex behimith. To explain the
# idea we need to look a little bit deeper into how this program functions and
# draws UI peaces.
# Basically every Layer py file is a set of instuction of how to draw a specific
# UI on to the screen. Those function return the finished canvas. An image
# basically. That the compositing layer (studio_gtk.py or pm_gtk.py ) combine
# into a bigger picture.
# There is a blur effect added to undernith layers if the top layer is drawn.
# I do this by checking the win.url string. Each layer has they own urls.
# Some are composited at all times. Some only if their url is the url. But all
# get blurred if it's not their url.
# Unfortunatly I can't make a function that will return a value. Because it means
# to stop the drawing of the UI. And I need the UI to get to next frame in order
# to draw the function's UI.
# Let's say I want to add a link to an image to the story-editor. I click on the
# add button. Next what I want to see is a searcher dialog appear. As soon as I
# have selected the image I want to link, then the new link appears in the story
# editor space which is automatically moving. Untill I place it.
# For this I need to set up some kind of variable. And as soon as this variable
# is not None. For example. We are doing the rest of the operation.
# Step 0 : User Clicks the add button. And a funtion is called.
# Step 1 : This function creates a dictionary with a variable NONE and a callable
# Step 2 : win.url changes to the Layer which is the searcher.
# Step 3 : User selects the images, or a file that he or she wanted to select.
# Step 4 : This filename is being written into the variable that used to be NONE.
# Step 5 : As soon as this variable is not NONE the callable is called.
# Step 6 : This callable is the one that does the setup work.
# Of course it would defeat the purpose if the callable always standard. It shold
# be one of the inputs to the dialogue function.
# Function template function_name(win, operation_name, callable):
################################################################################
import os
# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gdk
import cairo
# Own modules
from settings import settings
from settings import talk
from project_manager import pm_project
from studio import analytics
from studio import studio_nodes
#UI modules
from UI import UI_elements
from UI import UI_color
#################
from studio import studio_file_selectLayer
#################
def file_select(win, name, call):
# This function will select files for any kind of stuff. It will search
# through the files of the project. Similar to image searcher in the old
# organizer.
if name not in win.current["calls"]:
win.current["calls"][name] = {
"var" :None, # This is the variable that we are waiting for
"call":call, # This is what it's going to run when it's done
"url" :"file_select",
"back":win.url,# This is where it's going to come back when it's done
"draw":studio_file_selectLayer.layer
}
# Here everything is set. I hope so.