Пример #1
0
 def update_info(self, event=None):
     s, t, w, h, clean_s, clean_t = sculpty.map_size(
         self.x_faces.get(), self.y_faces.get(), self.levels.get())
     self.info_frame.config(text="Map Size - %d x %d" % (w, h))
     self.info_text.set(sculpty.lod_info(w, h)[:-1])
     if sculpty.check_clean(w, h, self.x_faces.get(), self.y_faces.get(),
                            self.clean_lods.get()):
         self.clean_lods_input.configure(
             background=gui.theme.others['panel'],
             foreground=gui.theme.defaults['foreground'])
         pow2 = [2, 4, 8, 16, 32, 64, 128, 256]
         if self.x_faces.get() in pow2 and self.y_faces.get() in pow2:
             self.clean_lods_input.configure(state=DISABLED)
         else:
             self.clean_lods_input.configure(state=NORMAL)
     else:
         self.clean_lods_input.configure(
             background=gui.theme.defaults['foreground'],
             foreground=gui.theme.others['panel'],
             state=NORMAL)
     if self.shape_name.get() not in ['Plane', 'Hemi']:
         if self.x_faces.get() < 3:
             clean_s = False
             self.create_button.configure(state=DISABLED)
         if self.y_faces.get() < 3:
             clean_t = False
             self.create_button.configure(state=DISABLED)
         elif self.x_faces.get() > 2:
             self.create_button.configure(state=NORMAL)
     else:
         self.create_button.configure(state=NORMAL)
     if clean_s and clean_t:
         self.levels_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield),
             foreground=gui.theme.defaults['foreground'])
     else:
         self.levels_input.configure(
             background=gui.theme.defaults['foreground'],
             foreground=gui.hex_color(gui.theme.ui.textfield))
     if clean_s:
         self.x_faces_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield),
             foreground=gui.theme.defaults['foreground'])
     else:
         self.x_faces_input.configure(
             background=gui.theme.defaults['foreground'],
             foreground=gui.hex_color(gui.theme.ui.textfield))
     if clean_t:
         self.y_faces_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield),
             foreground=gui.theme.defaults['foreground'])
     else:
         self.y_faces_input.configure(
             background=gui.theme.defaults['foreground'],
             foreground=gui.hex_color(gui.theme.ui.textfield))
Пример #2
0
 def update_info(self, event=None):
     s, t, w, h, clean_s, clean_t = sculpty.map_size(self.x_faces.get(), self.y_faces.get(), self.levels.get())
     self.info_frame.config(text="Map Size - %d x %d" % (w, h))
     self.info_text.set(sculpty.lod_info(w, h)[:-1])
     if sculpty.check_clean(w, h, self.x_faces.get(), self.y_faces.get(), self.clean_lods.get()):
         self.clean_lods_input.configure(
             background=gui.theme.others["panel"], foreground=gui.theme.defaults["foreground"]
         )
         pow2 = [2, 4, 8, 16, 32, 64, 128, 256]
         if self.x_faces.get() in pow2 and self.y_faces.get() in pow2:
             self.clean_lods_input.configure(state=DISABLED)
         else:
             self.clean_lods_input.configure(state=NORMAL)
     else:
         self.clean_lods_input.configure(
             background=gui.theme.defaults["foreground"], foreground=gui.theme.others["panel"], state=NORMAL
         )
     if self.shape_name.get() not in ["Plane", "Hemi"]:
         if self.x_faces.get() < 3:
             clean_s = False
             self.create_button.configure(state=DISABLED)
         if self.y_faces.get() < 3:
             clean_t = False
             self.create_button.configure(state=DISABLED)
         elif self.x_faces.get() > 2:
             self.create_button.configure(state=NORMAL)
     else:
         self.create_button.configure(state=NORMAL)
     if clean_s and clean_t:
         self.levels_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield), foreground=gui.theme.defaults["foreground"]
         )
     else:
         self.levels_input.configure(
             background=gui.theme.defaults["foreground"], foreground=gui.hex_color(gui.theme.ui.textfield)
         )
     if clean_s:
         self.x_faces_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield), foreground=gui.theme.defaults["foreground"]
         )
     else:
         self.x_faces_input.configure(
             background=gui.theme.defaults["foreground"], foreground=gui.hex_color(gui.theme.ui.textfield)
         )
     if clean_t:
         self.y_faces_input.configure(
             background=gui.hex_color(gui.theme.ui.textfield), foreground=gui.theme.defaults["foreground"]
         )
     else:
         self.y_faces_input.configure(
             background=gui.theme.defaults["foreground"], foreground=gui.hex_color(gui.theme.ui.textfield)
         )
Пример #3
0
	def __init__(self, master, theme):
		w,h = 32, 256

		self.theme  = theme
		self.master = master
		self.master.overrideredirect(True)
		
		# ==========================================
		# Main window frame		
		# ==========================================
		topFrame = Frame(master, border=4, bg=hex_colour(theme.popup))
		topFrame.pack()

		frame = LabelFrame(topFrame,
				border=3, relief=FLAT,
				fg=hex_colour(theme.text),
				bg=hex_colour(theme.menu_back),
				text=ADD_SCULPT_MESH_LABEL,
				labelanchor=NW)
		frame.pack(anchor=CENTER)

		# ==========================================
		# Geometry section (top left)
		# ==========================================

		upperFrame = Frame(frame, bg=hex_colour(theme.menu_back))
		upperFrame.pack()
		
		f = LabelFrame(upperFrame,
				text="Geometry",
				bg= hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		f.pack(padx=5, pady=5, fill=BOTH, side=LEFT, anchor=CENTER ) 
		
		ff = Frame(f, bg=hex_colour(theme.menu_back))
		ff.pack()
		fx = Frame(ff, bg=hex_colour(theme.menu_back))
		fx.pack()
		t = Label(fx,
			text="X Faces",
			justify=RIGHT,
			bg=hex_colour(theme.menu_back),
			fg=hex_colour(theme.text))
		t.pack(padx=5, pady=5, side=LEFT)
		self.x_faces = IntVar(self.master, 8)
		s = Spinbox(fx,
				textvariable=self.x_faces,
				from_=1,
				to=256,
				width=3,
				bg=hex_colour(theme.num),
				fg=hex_colour(theme.text),
				activebackground=hex_colour(theme.setting))
		s.pack(padx=5, pady=5, side=RIGHT)
		fy = Frame(ff, bg=hex_colour(theme.menu_back))
		fy.pack()
		t = Label(fy,
				text="Y Faces",
				justify=RIGHT,
				bg=hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		t.pack(padx=5, pady=5, side=LEFT)
		self.y_faces = IntVar(self.master, 8)
		s = Spinbox(fy,
				textvariable=self.y_faces,
				from_=1,
				to=256,
				width=3,
				bg=hex_colour(theme.num),
				fg=hex_colour(theme.text),
				activebackground=hex_colour(theme.setting))
		s.pack(padx=5, pady=5, side=RIGHT)

		self.clean_lods = BooleanVar( self.master, True )
		c = Checkbutton(f,
				text="Clean LODs",
				variable=self.clean_lods,
				bg=hex_colour(theme.menu_back),
				fg=hex_colour(theme.text),
				activebackground=hex_colour(theme.setting),
				border=2,
				highlightthickness=0)
		c.pack(padx=0, pady=5, side=LEFT)


		# ==========================================
		# Subdivision section (top right)
		# ==========================================

		fs = LabelFrame(upperFrame,
				text="Subdivision",
				bg= hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		fs.pack(padx=5, pady=5, fill=BOTH, side=RIGHT, anchor=CENTER )
		
		self.levels = IntVar(self.master, 2)
		fl = Frame(fs, bg=hex_colour(theme.menu_back))
		fl.pack()

		t = Label(fl,
				text="Levels",
				justify=RIGHT,
				bg=hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		t.pack(padx=5, pady=5, side=LEFT)
		s = Spinbox(fl,
				textvariable=self.levels,
				from_=0,
				to=6,
				width=3,
				bg=hex_colour(theme.num),
				fg=hex_colour(theme.text),
				activebackground=hex_colour(theme.setting))
		s.pack(padx=5, pady=5, side=RIGHT)

 		self.subdivision = IntVar(self.master, 1)
		r = Frame(fs, bg=hex_colour(theme.menu_back))
		r.pack(side=LEFT)
		Radiobutton(r,
				text="Catmull",
				variable=self.subdivision,
				highlightthickness=0,
				bg=hex_colour(theme.menu_back),
				value=1).pack()
		Radiobutton(r,
				text="Simple",
				variable=self.subdivision,
				highlightthickness=0,
				bg=hex_colour(theme.menu_back),
				value=0).pack()
		self.sub_type = IntVar(self.master, 1)
		r = Frame(fs, bg=hex_colour(theme.menu_back))
		r.pack(side=RIGHT)
		Radiobutton(r,
				text="Subsurf",
				variable=self.sub_type,
				highlightthickness=0,
				bg=hex_colour(theme.menu_back),
				value=1).pack()
		Radiobutton(r,
				text="Multires",
				variable=self.sub_type,
				highlightthickness=0,
				bg=hex_colour(theme.menu_back),
				value=0).pack()

		# ==========================================
		# LOD display (bottom left)
		# ==========================================				
				
		f = LabelFrame(frame,
				text="Map Image",
				bg=hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		f.pack(padx=6, ipadx=3, pady=3, fill=BOTH, side=LEFT, anchor=CENTER)

		self.lod_display = Label(f,
				text=sculpty.lod_info(w, h)[:-1],
				justify=LEFT,
				bg=hex_colour(theme.menu_back),
				fg=hex_colour(theme.text))
		self.lod_display.pack(padx=5, pady=5, ipadx=3, ipady=3, side=LEFT)

		# ==========================================
		# Sculpty type selection (bottom right)
		# ==========================================

		controlFrame = Frame(frame,bg=hex_colour(theme.menu_back))
		controlFrame.pack(padx=5, pady=6, fill=Y, side=RIGHT, anchor=N)

		self.map_type = Button(controlFrame,
				text="Type",
				command=self.set_map_type,
				border=1,
				bg=hex_colour(theme.menu_hilite),
				fg=hex_colour(theme.menu_text_hi),
				activebackground=hex_colour(theme.setting))
		self.map_type.pack(padx=4, fill=X, pady=5, side=TOP, anchor=CENTER)
		
		self.sculpt_menu = Menu(controlFrame,
				tearoff=0,
				background=hex_colour(theme.menu_back),
				foreground=hex_colour(theme.menu_text),
				activebackground=hex_colour(theme.menu_hilite),
				activeforeground=hex_colour(theme.menu_text_hi) )
		for sculpt_type in [ "Sphere", "Torus", "Plane", "Cylinder", "Hemi"]:
			def type_command( sculpt_type ):
				def new_command():
					self.set_sculpt_type(sculpt_type)
				return new_command
			self.sculpt_menu.add_command(label=sculpt_type,
					command=type_command(sculpt_type))
		library = sculpty.build_lib(LibDir=MenuDir, LibFile=MenuMap)
		library.add_to_menu(self, self.sculpt_menu)

		self.selector = self.map_type
		self.set_sculpt_type("Sphere") # TODO: retrieve settings from registry
		
		# ==========================================
		# Control section (bottom right)
		# ==========================================

		buttonFrame = Frame(controlFrame, bg=hex_colour(theme.menu_back))
		buttonFrame.pack(side=BOTTOM, anchor=CENTER)


		# Cancel/Create buttons need layout tuning.
		createButton = Button(buttonFrame, text="Create",
				command=self.add,
				border=1,
				default=ACTIVE,
				bg=hex_colour(theme.action),
				activebackground=hex_colour(theme.action),
				fg=hex_colour(theme.text),
				activeforeground=hex_colour(theme.text_hi))
		createButton.pack( ipadx=7 , padx=8, pady=0, side=RIGHT, anchor=SE)
		
		b = Button(buttonFrame, text="Cancel",
				command=self.master.quit,
				border=1,
				bg=hex_colour(theme.action),
				activebackground=hex_colour(theme.action),
				fg=hex_colour(theme.text),
				activeforeground=hex_colour(theme.text_hi))
		b.pack( ipadx=7, padx=4, pady=0, side=LEFT, anchor=SW)
		
		# ===============================================================
		# Make master window sticky.
		# Bind <Leave> and <Enter> events to the top window
		# And preset "mouse is in app" and  "no selection active"
		# ===============================================================
		self.master.wm_attributes("-topmost", 1)   # Make sure window remains on top of all others
		self.master.bind( "<Leave>",   self.mouse_leave_handler) # track leave main window
		self.master.bind( "<Enter>",   self.mouse_enter_handler) # track enter main window
		self.set_mouse_in_app(True)
		self.selectorActive = False

		self.master.configure(takefocus=True)
		createButton.focus_force()