|
|
@@ -5,6 +5,7 @@ import wx
|
|
|
import os
|
|
|
|
|
|
from wx.lib.scrolledpanel import ScrolledPanel
|
|
|
+from wx.lib.agw.cubecolourdialog import *
|
|
|
from direct.wxwidgets.WxSlider import *
|
|
|
from pandac.PandaModules import *
|
|
|
import ObjectGlobals as OG
|
|
|
@@ -141,10 +142,26 @@ class ObjectPropUICombo(ObjectPropUI):
|
|
|
def getValue(self):
|
|
|
return self.ui.GetStringSelection()
|
|
|
|
|
|
+class ColorPicker(CubeColourDialog):
|
|
|
+ def __init__(self, parent, colourData=None, style=CCD_SHOW_ALPHA, alpha = 255, callback=None):
|
|
|
+ self.callback=callback
|
|
|
+ CubeColourDialog.__init__(self, parent, colourData, style)
|
|
|
+ self.okButton.Hide()
|
|
|
+ self.cancelButton.Hide()
|
|
|
+ self._colour.alpha = alpha
|
|
|
+ self.alphaSpin.SetValue(self._colour.alpha)
|
|
|
+ self.DrawAlpha()
|
|
|
+
|
|
|
+ def SetPanelColours(self):
|
|
|
+ self.oldColourPanel.RefreshColour(self._oldColour)
|
|
|
+ self.newColourPanel.RefreshColour(self._colour)
|
|
|
+ if self.callback:
|
|
|
+ self.callback(self._colour.r, self._colour.g, self._colour.b, self._colour.alpha)
|
|
|
|
|
|
class ObjectPropertyUI(ScrolledPanel):
|
|
|
def __init__(self, parent, editor):
|
|
|
self.editor = editor
|
|
|
+ self.colorPicker = None
|
|
|
ScrolledPanel.__init__(self, parent)
|
|
|
|
|
|
parentSizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
@@ -161,10 +178,57 @@ class ObjectPropertyUI(ScrolledPanel):
|
|
|
self.SetSizer(None)
|
|
|
self.Layout()
|
|
|
self.SetupScrolling(self, scroll_y = True, rate_y = 20)
|
|
|
+
|
|
|
+ def colorPickerCB(self, rr, gg, bb, aa):
|
|
|
+ r = rr / 255.0
|
|
|
+ g = gg / 255.0
|
|
|
+ b = bb / 255.0
|
|
|
+ a = aa / 255.0
|
|
|
+ self.propCR.setValue(r)
|
|
|
+ self.propCG.setValue(g)
|
|
|
+ self.propCB.setValue(b)
|
|
|
+ self.propCA.setValue(a)
|
|
|
+
|
|
|
+ self.editor.objectMgr.updateObjectColor(r, g, b, a)
|
|
|
+
|
|
|
+ def onColorSlider(self, evt):
|
|
|
+ r = float(self.editor.ui.objectPropertyUI.propCR.getValue())
|
|
|
+ g = float(self.editor.ui.objectPropertyUI.propCG.getValue())
|
|
|
+ b = float(self.editor.ui.objectPropertyUI.propCB.getValue())
|
|
|
+ a = float(self.editor.ui.objectPropertyUI.propCA.getValue())
|
|
|
+
|
|
|
+ if self.colorPicker:
|
|
|
+ evtObj = evt.GetEventObject()
|
|
|
+ if evtObj == self.propCR.ui or\
|
|
|
+ evtObj == self.propCR.ui.textValue:
|
|
|
+ self.colorPicker.redSpin.SetValue(r * 255)
|
|
|
+ self.colorPicker.AssignColourValue('r', r * 255, 255, 0)
|
|
|
+ elif evtObj == self.propCG.ui or\
|
|
|
+ evtObj == self.propCG.ui.textValue:
|
|
|
+ self.colorPicker.greenSpin.SetValue(g * 255)
|
|
|
+ self.colorPicker.AssignColourValue('g', g * 255, 255, 0)
|
|
|
+ elif evtObj == self.propCB.ui or\
|
|
|
+ evtObj == self.propCB.ui.textValue:
|
|
|
+ self.colorPicker.blueSpin.SetValue(b * 255)
|
|
|
+ self.colorPicker.AssignColourValue('b', b * 255, 255, 0)
|
|
|
+ else:
|
|
|
+ self.colorPicker._colour.alpha = a * 255
|
|
|
+ self.colorPicker.alphaSpin.SetValue(self.colorPicker._colour.alpha)
|
|
|
+ self.colorPicker.DrawAlpha()
|
|
|
+
|
|
|
+ self.editor.objectMgr.updateObjectColor(r, g, b, a)
|
|
|
+
|
|
|
+ def openColorPicker(self, evt, colourData, alpha):
|
|
|
+ if self.colorPicker:
|
|
|
+ self.colorPicker.Destroy()
|
|
|
+
|
|
|
+ self.colorPicker = ColorPicker(self, colourData, alpha=alpha, callback=self.colorPickerCB)
|
|
|
+ self.colorPicker.GetColourData().SetChooseFull(True)
|
|
|
+ self.colorPicker.Show()
|
|
|
|
|
|
def updateProps(self, obj):
|
|
|
self.clearPropUI()
|
|
|
-
|
|
|
+
|
|
|
self.propPane = wx.Panel(self)
|
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
mainSizer.Add(self.propPane, 1, wx.EXPAND, 0)
|
|
|
@@ -186,14 +250,36 @@ class ObjectPropertyUI(ScrolledPanel):
|
|
|
self.propSX, self.propSY, self.propSZ]
|
|
|
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
- sizer.AddMany([self.propX, self.propY, self.propZ, self.propH, self.propP, self.propR,
|
|
|
- self.propSX, self.propSY, self.propSZ])
|
|
|
+ sizer.AddMany(transformProps)
|
|
|
|
|
|
for transformProp in transformProps:
|
|
|
transformProp.bindFunc(self.editor.objectMgr.onEnterObjectPropUI,
|
|
|
self.editor.objectMgr.onLeaveObjectPropUI,
|
|
|
self.editor.objectMgr.updateObjectTransform)
|
|
|
-
|
|
|
+
|
|
|
+ objNP = obj[OG.OBJ_NP]
|
|
|
+ objNP.setTransparency(1)
|
|
|
+ colorScale = objNP.getColorScale()
|
|
|
+ self.propCR = ObjectPropUISlider(self.propPane, 'CR', colorScale.getX(), 0, 1)
|
|
|
+ self.propCG = ObjectPropUISlider(self.propPane, 'CG', colorScale.getY(), 0, 1)
|
|
|
+ self.propCB = ObjectPropUISlider(self.propPane, 'CB', colorScale.getZ(), 0, 1)
|
|
|
+ self.propCA = ObjectPropUISlider(self.propPane, 'CA', colorScale.getW(), 0, 1)
|
|
|
+ colorProps = [self.propCR, self.propCG, self.propCB, self.propCA]
|
|
|
+
|
|
|
+ for colorProp in colorProps:
|
|
|
+ colorProp.ui.bindFunc(self.onColorSlider)
|
|
|
+
|
|
|
+ sizer.AddMany(colorProps)
|
|
|
+ button = wx.Button(self.propPane, -1, 'Color Picker', (0,0), (140, 20))
|
|
|
+ _colourData = wx.ColourData()
|
|
|
+ _colourData.SetColour(wx.Colour(colorScale.getX() * 255, colorScale.getY() * 255, colorScale.getZ() * 255))
|
|
|
+ button.Bind(wx.EVT_BUTTON, lambda p0=None, p1=_colourData, p2=colorScale.getW() * 255: self.openColorPicker(p0, p1, p2))
|
|
|
+
|
|
|
+ sizer.Add(button)
|
|
|
+
|
|
|
+ if self.colorPicker:
|
|
|
+ self.openColorPicker(None, _colourData, colorScale.getW() * 255)
|
|
|
+
|
|
|
objDef = obj[OG.OBJ_DEF]
|
|
|
|
|
|
if objDef.model is not None:
|