Пример #1
0
 def __init__(self, parent=None):
     super(SelectButton, self).__init__(parent)
     self.defaultBGColor = QtGui.QPalette().color(self.backgroundRole())
     self.setBorderColor(self.defaultBGColor)
     p = self.palette()
     p.setColor(self.foregroundRole(), QtGui.QColor(000, 000, 000, 000))
     p.setColor(self.backgroundRole(), QtGui.QColor(000, 000, 000, 000))
     self.setPalette(p)
Пример #2
0
 def paintSelected(self, paint=False):
     if paint:
         p = self.palette()
         p.setColor(self.foregroundRole(), QtGui.QColor(255, 255, 255, 255))
         self.setPalette(p)
         self.setBorderColor(QtGui.QColor(255, 255, 255, 255))
     else:
         p = self.palette()
         p.setColor(self.foregroundRole(),
                    QtGui.QColor(000, 000, 000, 0o10))
         self.setPalette(p)
         self.setBorderColor(self.defaultBGColor)
Пример #3
0
def random_color(min_val=.01, max_val=.6):
    r = random.uniform(min_val, max_val)
    g = random.uniform(min_val, max_val)
    b = random.uniform(min_val, max_val)
    color = QtGui.QColor()

    color.setRgbF(r, g, b)

    return color
Пример #4
0
class LabeledFrame(QtWidgets.QFrame):

    margin = 8
    padding = 8
    color_over = QtGui.QColor(255, 255, 255, 255)
    borderColor = QtGui.QColor(172, 168, 167, 255)
    resized = None

    def __init__(self, parent=None):
        super(LabeledFrame, self).__init__(parent)
        self.innerFrame = QtWidgets.QFrame(parent=self)
        self.innerFrame.setStyleSheet("""
            border: 1px solid #aca8a7;
            border-radius: 4px;
            padding: 10px;
            margin: 10px;
        """)

        self.label = QtWidgets.QLabel(parent=self)
        self.label.setStyleSheet("""
            color: #bbbbbb;
        """)

    def calcTextLength(self, text):
        return len(text) * 16

    def paintEvent(self, event):
        if not self.resized:

            w = self.width()
            h = self.height()
            self.innerFrame.setGeometry(0, 0, w, h)

            text = self.property("text") or ""
            textWidth = self.calcTextLength(text)
            self.label.setText(text)
            self.label.setGeometry((w - textWidth) / 2.0, 0, textWidth, 25)
            self.label.setAlignment(QtCore.Qt.AlignHCenter
                                    | QtCore.Qt.AlignVCenter)

            self.resized = True
Пример #5
0
    def set_color_status(self):
        '''Set the color to red/green based on node existence status
        '''
        color = QtGui.QColor()

        # Exists case
        if self.node_exists():
            # pale green
            color.setRgb(152, 251, 152)

        # Does not exists case
        else:
            # orange
            color.setRgb(255, 165, 0)

        brush = self.foreground()
        brush.setColor(color)
        self.setForeground(brush)
Пример #6
0
    def auto_color_axis_slot(self):
        for itm in self.selectedItems():
            attr_config = itm.data(QtCore.Qt.UserRole)
            f_name = attr_config["fullName"]
            colors = [[0.8, 0.0, 0.1], [0.0, 0.57, 0.0], [0.0, 0.0, 0.75]]

            color = QtGui.QColor()
            if f_name.endswith("X"):
                color.setRgbF(*colors[0])
            elif f_name.endswith("Y"):
                color.setRgbF(*colors[1])
            elif f_name.endswith("Z"):
                color.setRgbF(*colors[2])
            else:
                continue

            itm.setBackground(color)
            attr_config["color"] = color.getRgbF()
            itm.setData(QtCore.Qt.UserRole, attr_config)
Пример #7
0
class SelectBtn_CIk(SelectButton):
    color = QtGui.QColor(192, 64, 192, 255)
Пример #8
0
    def config_table(self):

        def value_update(attr_config, *args):
            """Update the attribute from the  channel value

            Args:
                ch (QWidget): The channel widget
                atttr_config (dict): attribute configuration data
                *args: the current value
            """
            if self.trigger_value_update:
                try:
                    cmds.setAttr(self.namespace_sync(attr_config["fullName"]),
                                 args[0])

                    # refresh button color while value update
                    for i in xrange(self.rowCount()):
                        item = self.item(i, 0)
                        attr = item.data(QtCore.Qt.UserRole)
                        if (self.namespace_sync(attr["fullName"])
                                == self.namespace_sync(
                                    attr_config["fullName"])):
                            button = self.cellWidget(i, 1)
                            refresh_key_button_color(
                                button,
                                self.namespace_sync(attr_config["fullName"]))
                            break
                except RuntimeError:
                    fname = self.namespace_sync(attr_config["fullName"])
                    pm.displayWarning("Channel {} not Found.".format(fname)
                                      + " Maybe the channel master"
                                      + " contains not existing channels. "
                                      + "Review Channel Master configuration")

        def open_undo_chunk():
            cmds.undoInfo(openChunk=True)

        def close_undo_chunk():
            cmds.undoInfo(closeChunk=True)

        if not self.chan_config:
            return

        i = 0
        for ch in self.chan_config["channels"]:
            at = self.chan_config["channels_data"][ch]
            at_name = self.namespace_sync(at["fullName"])
            try:
                val = cmds.getAttr(at_name)
            except ValueError:
                pm.displayWarning(
                    "{} not found. Maybe wrong NameSpace?".format(at_name))
                continue
            if at["type"] in cmu.ATTR_SLIDER_TYPES:
                if at["type"] == "long":
                    Type = "int"
                else:
                    Type = "float"
                ch_ctl = pyflow_widgets.pyf_Slider(self,
                                                   Type=Type,
                                                   defaultValue=val,
                                                   sliderRange=(at["min"],
                                                                at["max"]))

                ch_ctl.valueChanged.connect(
                    partial(value_update, at))
                ch_ctl.sliderPressed.connect(open_undo_chunk)
                ch_ctl.sliderReleased.connect(close_undo_chunk)

            elif at["type"] == "bool":

                ch_ctl = QtWidgets.QWidget()
                layout = QtWidgets.QHBoxLayout(ch_ctl)
                cbox = QtWidgets.QCheckBox()
                cbox.setStyleSheet(CHECKBOX_STYLE)
                ch_ctl.setStyleSheet(CHECKBOX_STYLE)
                layout.addWidget(cbox)
                layout.setAlignment(QtCore.Qt.AlignCenter)
                layout.setContentsMargins(0, 0, 0, 0)
                ch_ctl.setLayout(layout)
                if val:
                    cbox.setChecked(True)

                cbox.toggled.connect(
                    partial(value_update, at))

            elif at["type"] == "enum":

                # we handle special naming for separators
                if at["niceName"] == "__________":
                    continue
                else:
                    ch_ctl = QtWidgets.QComboBox()
                    ch_ctl.addItems(at["items"])
                    ch_ctl.setCurrentIndex(val)

                    ch_ctl.currentIndexChanged.connect(
                        partial(value_update, at))

            label_item = QtWidgets.QTableWidgetItem(at["niceName"] + "  ")
            if at["color"]:
                color = QtGui.QColor()
                color.setRgbF(*at["color"])
                label_item.setBackground(color)
            label_item.setData(QtCore.Qt.UserRole, at)
            label_item.setTextAlignment(QtCore.Qt.AlignRight)
            label_item.setToolTip(self.namespace_sync(at["fullName"]))
            label_item.setFlags(label_item.flags() ^ QtCore.Qt.ItemIsEditable)

            key_button = self.create_key_button(at)

            self.insertRow(i)
            self.setRowHeight(i, 17)
            self.setItem(i, 0, label_item)
            self.setCellWidget(i, 1, key_button)
            self.setCellWidget(i, 2, ch_ctl)

            self.track_widgets.append([key_button, ch_ctl])

            i += 1
Пример #9
0
 def clear_color_slot(self):
     items = self.selectedItems()
     if items:
         for itm in items:
             itm.setBackground(QtGui.QColor(43, 43, 43))
Пример #10
0
import struct

from mgear.vendor.Qt import QtGui, QtCore, QtWidgets


FLOAT_SLIDER_DRAG_STEPS = [100.0, 10.0, 1.0, 0.1, 0.01, 0.001]
INT_SLIDER_DRAG_STEPS = [100.0, 10.0, 1.0]

maxint = 2 ** (struct.Struct('i').size * 8 - 1) - 1

FLOAT_RANGE_MIN = 0.1 + (-maxint - 1.0)
FLOAT_RANGE_MAX = maxint + 0.1
INT_RANGE_MIN = -maxint + 0
INT_RANGE_MAX = maxint + 0

MainColor = QtGui.QColor(60, 60, 60)

ATTR_SLIDER_TYPES = ["int", "float", "double", "doubleLinear", "doubleAngle"]


class Colors:
    AbsoluteBlack = QtGui.QColor(0, 0, 0, 255)
    DarkGray = QtGui.QColor(60, 60, 60)
    DirtyPen = QtGui.QColor(250, 250, 250, 200)
    Gray = QtGui.QColor(110, 110, 110)
    Green = QtGui.QColor(96, 169, 23, 255)
    NodeBackgrounds = QtGui.QColor(40, 40, 40, 200)
    NodeNameRectBlue = QtGui.QColor(28, 74, 149, 200)
    NodeNameRectGreen = QtGui.QColor(74, 124, 39, 200)
    NodeSelectedPenColor = QtGui.QColor(200, 200, 200, 150)
    Red = QtGui.QColor(255, 0, 0, 255)
Пример #11
0
class SelectBtn_darkGreen(SelectButton):
    color = QtGui.QColor(0, 100, 0, 255)
Пример #12
0
class SelectBtn_green(SelectButton):
    color = QtGui.QColor(0, 192, 0, 255)
Пример #13
0
class SelectBtn_yellow(SelectButton):
    color = QtGui.QColor(255, 192, 0, 255)
Пример #14
0
class SelectBtn_LIk(SelectButton):
    color = QtGui.QColor(192, 128, 0, 255)
Пример #15
0
class SelectBtn_LFk(SelectButton):
    color = QtGui.QColor(192, 0, 0, 255)
Пример #16
0
class SelectBtn_CFk(SelectButton):
    color = QtGui.QColor(128, 0, 128, 255)
Пример #17
0
class SelectBtn_RIk(SelectButton):
    color = QtGui.QColor(0, 128, 192, 255)
Пример #18
0
class Colors:
    AbsoluteBlack = QtGui.QColor(0, 0, 0, 255)
    DarkGray = QtGui.QColor(60, 60, 60)
    DirtyPen = QtGui.QColor(250, 250, 250, 200)
    Gray = QtGui.QColor(110, 110, 110)
    Green = QtGui.QColor(96, 169, 23, 255)
    NodeBackgrounds = QtGui.QColor(40, 40, 40, 200)
    NodeNameRectBlue = QtGui.QColor(28, 74, 149, 200)
    NodeNameRectGreen = QtGui.QColor(74, 124, 39, 200)
    NodeSelectedPenColor = QtGui.QColor(200, 200, 200, 150)
    Red = QtGui.QColor(255, 0, 0, 255)
    White = QtGui.QColor(255, 255, 255, 200)
    Yellow = QtGui.QColor(255, 211, 25)
    Orange = QtGui.QColor(209, 84, 0)
Пример #19
0
 def set_overlay_background(self, color=QtGui.QColor(20, 20, 20, 90)):
     palette = QtGui.QPalette(self.parent().palette())
     palette.setColor(palette.Background, color)
     self.setPalette(palette)
     self.setAutoFillBackground(True)
Пример #20
0
class SelectButton(QtWidgets.QWidget):
    over = False
    color_over = QtGui.QColor(255, 255, 255, 255)

    def __init__(self, parent=None):
        super(SelectButton, self).__init__(parent)
        self.defaultBGColor = QtGui.QPalette().color(self.backgroundRole())
        self.setBorderColor(self.defaultBGColor)
        p = self.palette()
        p.setColor(self.foregroundRole(), QtGui.QColor(000, 000, 000, 000))
        p.setColor(self.backgroundRole(), QtGui.QColor(000, 000, 000, 000))
        self.setPalette(p)

    def enterEvent(self, event):
        self.over = True
        QtWidgets.QToolTip.showText(QtGui.QCursor.pos(),
                                    str(self.property("object")))
        self.repaint()
        self.update()

    def leaveEvent(self, event):
        self.over = False
        self.repaint()
        self.update()

    def rectangleSelection(self, event, firstLoop):
        if firstLoop:
            key_modifier = event.modifiers()
        else:
            if event.modifiers():
                key_modifier = event.modifiers()
            else:
                key_modifier = (QtCore.Qt.ControlModifier
                                | QtCore.Qt.ShiftModifier)
        model = utils.getModel(self)
        object = str(self.property("object")).split(",")

        mouse_button = event.button()
        utils.selectObj(model, object, mouse_button, key_modifier)

    def mousePressEvent(self, event):

        model = utils.getModel(self)
        object = str(self.property("object")).split(",")
        mouse_button = event.button()
        key_modifier = event.modifiers()

        utils.selectObj(model, object, mouse_button, key_modifier)

    def paintEvent(self, event):
        painter = QtGui.QPainter()
        painter.begin(self)
        if self.over:
            painter.setBrush(self.color_over)
        else:
            painter.setBrush(self.color)
        self.drawShape(painter)
        painter.end()

    def paintSelected(self, paint=False):
        if paint:
            p = self.palette()
            p.setColor(self.foregroundRole(), QtGui.QColor(255, 255, 255, 255))
            self.setPalette(p)
            self.setBorderColor(QtGui.QColor(255, 255, 255, 255))
        else:
            p = self.palette()
            p.setColor(self.foregroundRole(),
                       QtGui.QColor(000, 000, 000, 0o10))
            self.setPalette(p)
            self.setBorderColor(self.defaultBGColor)

    def setBorderColor(self, color):
        self.borderColor = color

    def drawPathWithBorder(self, painter, path, borderWidth):
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        pen = QtGui.QPen(self.borderColor, borderWidth)
        painter.setPen(pen)
        painter.fillPath(path, QtCore.Qt.red)
        painter.drawPath(path)