示例#1
0
    def property_changed_cb(unused_effect, gst_element, pspec):
        """Handles the change of a GObject property."""
        if gst_element.get_control_binding(pspec.name):
            Loggable().log("%s controlled, not displaying value", pspec.name)
            return

        widget = element_setting_widget.properties.get(pspec)
        if not widget:
            return

        res, value = element_setting_widget.element.get_child_property(
            pspec.name)
        assert res

        if pspec.name in ("black-color-r", "black-color-g", "black-color-b"):
            update_wheel("black-color-r", "black-color-g", "black-color-b",
                         shadows_wheel, widget, value)
        elif pspec.name in ("gray-color-r", "gray-color-g", "gray-color-b"):
            update_wheel("gray-color-r", "gray-color-g", "gray-color-b",
                         midtones_wheel, widget, value)
        elif pspec.name in ("white-color-r", "white-color-g", "white-color-b"):
            update_wheel("white-color-r", "white-color-g", "white-color-b",
                         highlights_wheel, widget, value)
        else:
            widget.setWidgetValue(value)
示例#2
0
    def property_changed_cb(unused_effect, gst_element, pspec):
        """Handles the change of a GObject property."""
        if gst_element.get_control_binding(pspec.name):
            Loggable().log("%s controlled, not displaying value", pspec.name)
            return

        widget = element_setting_widget.properties.get(pspec)
        if not widget:
            return

        res, value = element_setting_widget.element.get_child_property(
            pspec.name)
        assert res

        if pspec.name in ("shape", ):
            shape_picker.set_active(get_current_shape())
            widget.block_signals()
            try:
                widget.setWidgetValue(value)
            finally:
                widget.unblock_signals()
        elif pspec.name in ("operation", ):
            op_picker.set_active(get_current_op())
            widget.block_signals()
            try:
                widget.setWidgetValue(value)
            finally:
                widget.unblock_signals()
        else:
            widget.setWidgetValue(value)
示例#3
0
    def property_changed_cb(unused_effect, gst_element, pspec):
        """Handles the change of a GObject property."""
        if gst_element.get_control_binding(pspec.name):
            Loggable().log("%s controlled, not displaying value", pspec.name)
            return

        widget = element_setting_widget.properties.get(pspec)
        if not widget:
            return

        res, value = element_setting_widget.element.get_child_property(pspec.name)
        assert res

        if pspec.name in ("target-r", "target-g", "target-b"):
            color_button.set_rgba(get_current_rgba())
            widget.block_signals()
            try:
                widget.setWidgetValue(value)
            finally:
                widget.unblock_signals()
        else:
            widget.setWidgetValue(value)
示例#4
0
def create_alpha_widget(effect_prop_manager, element_setting_widget, element):
    """Creates the UI for the `alpha` effect."""
    builder = setup_from_ui_file(element_setting_widget,
                                 os.path.join(CUSTOM_WIDGETS_DIR, "alpha.ui"))

    color_picker = ColorPickerButton(0, 255, 0)
    color_picker_frame = builder.get_object("color_picker_frame")
    color_picker_frame.add(color_picker)

    # Additional Setup

    # All modes other than custom RGB chroma keying are useless to us.
    # "ALPHA_METHOD_CUSTOM" corresponds to "3"
    Loggable().debug("Setting alpha's method to 3 (custom RGB chroma keying)")
    element.set_child_property("method", 3)

    # Color button and picker has to be connected manually!

    def get_current_rgba():
        """Gets the color used by the effect."""
        color = Gdk.RGBA()
        res, red = element.get_child_property("target-r")
        assert res
        res, green = element.get_child_property("target-g")
        assert res
        res, blue = element.get_child_property("target-b")
        assert res
        color.red = red / 255
        color.green = green / 255
        color.blue = blue / 255
        return color

    def color_button_color_set_cb(color_button):
        """Handles the selection of a color with the color button."""
        color = color_button.get_rgba()
        red = int(color.red * 255)
        green = int(color.green * 255)
        blue = int(color.blue * 255)
        from pitivi.undo.timeline import CommitTimelineFinalizingAction
        pipeline = effect_prop_manager.app.project_manager.current_project.pipeline
        action_log = effect_prop_manager.app.action_log
        with action_log.started(
                "Effect property change",
                finalizing_action=CommitTimelineFinalizingAction(pipeline),
                toplevel=True):
            element.set_child_property("target-r", red)
            element.set_child_property("target-g", green)
            element.set_child_property("target-b", blue)

    color_button = builder.get_object("colorbutton")
    color_button.connect("color-set", color_button_color_set_cb)

    def color_picker_value_changed_cb(unused_color_picker_button):
        """Handles the selection of a color with the color picker button."""
        from pitivi.undo.timeline import CommitTimelineFinalizingAction
        pipeline = effect_prop_manager.app.project_manager.current_project.pipeline
        action_log = effect_prop_manager.app.action_log
        with action_log.started(
                "Color Picker Change",
                finalizing_action=CommitTimelineFinalizingAction(pipeline),
                toplevel=True):
            element.set_child_property("target-r", color_picker.color_r)
            element.set_child_property("target-g", color_picker.color_g)
            element.set_child_property("target-b", color_picker.color_b)

    color_picker.connect("value-changed", color_picker_value_changed_cb)

    def property_changed_cb(unused_effect, gst_element, pspec):
        """Handles the change of a GObject property."""
        if gst_element.get_control_binding(pspec.name):
            Loggable().log("%s controlled, not displaying value", pspec.name)
            return

        widget = element_setting_widget.properties.get(pspec)
        if not widget:
            return

        res, value = element_setting_widget.element.get_child_property(
            pspec.name)
        assert res

        if pspec.name in ("target-r", "target-g", "target-b"):
            color_button.set_rgba(get_current_rgba())
            widget.block_signals()
            try:
                widget.setWidgetValue(value)
            finally:
                widget.unblock_signals()
        else:
            widget.setWidgetValue(value)

    element.connect("deep-notify", property_changed_cb)

    return builder.get_object("base_table")