@@ -9,13 +9,28 @@ DESTDIR = | |||
SED_PREFIX = $(shell echo $(PREFIX) | sed "s/\//\\\\\\\\\//g") | |||
LINK = ln -sf | |||
PYUIC = pyuic4 | |||
PYRCC = pyrcc4 -py3 | |||
LINK = ln -sf | |||
PYUIC ?= pyuic4 | |||
PYRCC ?= pyrcc4 -py3 | |||
# ----------------------------------------------------------------------------------------------------------------------------------------- | |||
HAVE_OPENGL = $(shell pkg-config --exists gl && echo true) | |||
HAVE_QTCORE = $(shell pkg-config --exists QtCore && echo true) | |||
ifneq ($(HAVE_OPENGL),true) | |||
all: | |||
@echo Error: Missing OpenGL or pkg-config, cannot build | |||
@exit 1 | |||
else | |||
ifneq ($(HAVE_QTCORE),true) | |||
all: | |||
@echo Error: Missing QtCore, cannot build | |||
@exit 1 | |||
else | |||
all: CPP RES UI WIDGETS | |||
endif | |||
endif | |||
# ----------------------------------------------------------------------------------------------------------------------------------------- | |||
# C++ code | |||
@@ -62,15 +77,22 @@ RES = source/resources_rc.py | |||
RES: $(RES) | |||
source/resources_rc.py: resources/resources.qrc | |||
source/%_rc.py: resources/%.qrc | |||
$(PYRCC) $< -o $@ | |||
# ----------------------------------------------------------------------------------------------------------------------------------------- | |||
# UI code | |||
UIs = source/ui_carla.py source/ui_carla_control.py \ | |||
source/ui_carla_about.py source/ui_carla_database.py source/ui_carla_edit.py source/ui_carla_parameter.py source/ui_carla_plugin.py \ | |||
source/ui_carla_refresh.py source/ui_carla_settings.py \ | |||
UIs = \ | |||
source/ui_carla.py \ | |||
source/ui_carla_control.py \ | |||
source/ui_carla_about.py \ | |||
source/ui_carla_database.py \ | |||
source/ui_carla_edit.py \ | |||
source/ui_carla_parameter.py \ | |||
source/ui_carla_plugin.py \ | |||
source/ui_carla_refresh.py \ | |||
source/ui_carla_settings.py \ | |||
source/ui_inputdialog_value.py | |||
UI: $(UIs) | |||
@@ -105,7 +127,7 @@ clean: | |||
rm -f $(RES) | |||
rm -f $(UIs) | |||
rm -f $(WIDGETS) | |||
rm -f *~ source/*~ source/*.pyc source/ui_*.py source/resources_rc.py | |||
rm -f *~ source/*~ source/*.pyc source/*_rc.py source/ui_*.py | |||
# ----------------------------------------------------------------------------------------------------------------------------------------- | |||
@@ -126,7 +148,7 @@ install: | |||
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ | |||
install -d $(DESTDIR)$(PREFIX)/share/carla/ | |||
# Install script files and binaries | |||
# Install script files | |||
install -m 755 \ | |||
data/carla \ | |||
data/carla-control \ | |||
@@ -137,24 +159,24 @@ install: | |||
install -m 644 data/*.desktop $(DESTDIR)$(PREFIX)/share/applications/ | |||
# Install icons, 16x16 | |||
install -m 644 resources/16x16/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/ | |||
install -m 644 resources/16x16/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/ | |||
install -m 644 resources/16x16/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/ | |||
install -m 644 resources/16x16/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/ | |||
# Install icons, 48x48 | |||
install -m 644 resources/48x48/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/ | |||
install -m 644 resources/48x48/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/ | |||
install -m 644 resources/48x48/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/ | |||
install -m 644 resources/48x48/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/ | |||
# Install icons, 128x128 | |||
install -m 644 resources/128x128/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/ | |||
install -m 644 resources/128x128/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/ | |||
install -m 644 resources/128x128/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/ | |||
install -m 644 resources/128x128/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/ | |||
# Install icons, 256x256 | |||
install -m 644 resources/256x256/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/ | |||
install -m 644 resources/256x256/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/ | |||
install -m 644 resources/256x256/carla.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/ | |||
install -m 644 resources/256x256/carla-control.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/ | |||
# Install icons, scalable | |||
install -m 644 resources/scalable/carla.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ | |||
install -m 644 resources/scalable/carla-control.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ | |||
install -m 644 resources/scalable/carla.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ | |||
install -m 644 resources/scalable/carla-control.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ | |||
# Install binary data | |||
install -m 755 \ | |||
@@ -53,7 +53,6 @@ BUILD_CXX_FLAGS += -DVESTIGE_HEADER | |||
# -------------------------------------------------------------- | |||
HAVE_JACK = $(shell pkg-config --exists jack && echo true) | |||
HAVE_OPENGL = $(shell pkg-config --exists gl && echo true) | |||
HAVE_AF_DEPS = $(shell pkg-config --exists libavcodec libavformat sndfile && echo true) | |||
HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml && echo true) | |||
@@ -63,10 +62,6 @@ HAVE_JACK_LATENCY = $(shell pkg-config --atleast-version=0.121.0 jack && echo tr | |||
HAVE_JACK2 = $(shell pkg-config --atleast-version=1.9.0 jack && echo true) | |||
endif | |||
ifeq ($(CARLA_PLUGIN_SUPPORT),true) | |||
HAVE_SUIL = $(shell pkg-config --exists suil-0 && echo true) | |||
endif | |||
ifeq ($(CARLA_SAMPLERS_SUPPORT),true) | |||
HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true) | |||
HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true) | |||
@@ -1971,18 +1971,21 @@ CarlaPlugin::ScopedProcessLocker::~ScopedProcessLocker() | |||
// ------------------------------------------------------------------- | |||
// CarlaPluginGUI | |||
CarlaPluginGUI::CarlaPluginGUI(QWidget* const parent, Callback* const callback) | |||
: QMainWindow(parent), | |||
kCallback(callback), | |||
fContainer(this) | |||
{ | |||
carla_debug("CarlaPluginGUI::CarlaPluginGUI(%p, %p)", parent, callback); | |||
CarlaPluginGUI::CarlaPluginGUI(DGL::App* const app, Callback* const callback) | |||
//CarlaPluginGUI::CarlaPluginGUI(QWidget* const parent, Callback* const callback) | |||
: DGL::Window(app), | |||
kCallback(callback)/*, | |||
fContainer(this)*/ | |||
{ | |||
carla_debug("CarlaPluginGUI::CarlaPluginGUI(%p, %p)", app, callback); | |||
CARLA_ASSERT(app != nullptr); | |||
CARLA_ASSERT(callback != nullptr); | |||
setCentralWidget(&fContainer); | |||
adjustSize(); | |||
//setCentralWidget(&fContainer); | |||
//adjustSize(); | |||
QMainWindow::setVisible(false); | |||
//QMainWindow::setVisible(false); | |||
hide(); | |||
} | |||
CarlaPluginGUI::~CarlaPluginGUI() | |||
@@ -1990,28 +1993,30 @@ CarlaPluginGUI::~CarlaPluginGUI() | |||
carla_debug("CarlaPluginGUI::~CarlaPluginGUI()"); | |||
} | |||
#if 0 | |||
WId CarlaPluginGUI::getWinId() const | |||
{ | |||
carla_debug("CarlaPluginGUI::getWinId()"); | |||
return fContainer.winId(); | |||
} | |||
#endif | |||
void CarlaPluginGUI::closeEvent(QCloseEvent* const event) | |||
{ | |||
carla_debug("CarlaPluginGUI::closeEvent(%p)", event); | |||
CARLA_ASSERT(event != nullptr); | |||
if (! event->spontaneous()) | |||
{ | |||
event->ignore(); | |||
return; | |||
} | |||
if (kCallback != nullptr) | |||
kCallback->guiClosedCallback(); | |||
QMainWindow::closeEvent(event); | |||
} | |||
// void CarlaPluginGUI::closeEvent(QCloseEvent* const event) | |||
// { | |||
// carla_debug("CarlaPluginGUI::closeEvent(%p)", event); | |||
// CARLA_ASSERT(event != nullptr); | |||
// | |||
// if (! event->spontaneous()) | |||
// { | |||
// event->ignore(); | |||
// return; | |||
// } | |||
// | |||
// if (kCallback != nullptr) | |||
// kCallback->guiClosedCallback(); | |||
// | |||
// QMainWindow::closeEvent(event); | |||
// } | |||
// ------------------------------------------------------------------- | |||
@@ -28,16 +28,18 @@ | |||
#include "CarlaMIDI.h" | |||
#include "RtList.hpp" | |||
#include "dgl/App.hpp" | |||
#include "dgl/Window.hpp" | |||
#include <QtGui/QMainWindow> | |||
//#include <QtGui/QMainWindow> | |||
#ifdef Q_WS_X11 | |||
# include <QtGui/QX11EmbedContainer> | |||
typedef QX11EmbedContainer GuiContainer; | |||
#else | |||
# include <QtGui/QWidget> | |||
typedef QWidget GuiContainer; | |||
#endif | |||
//#ifdef Q_WS_X11 | |||
//# include <QtGui/QX11EmbedContainer> | |||
//typedef QX11EmbedContainer GuiContainer; | |||
//#else | |||
//# include <QtGui/QWidget> | |||
//typedef QWidget GuiContainer; | |||
//#endif | |||
#define CARLA_DECLARE_NON_COPY_STRUCT(structName) \ | |||
structName(structName&) = delete; \ | |||
@@ -395,7 +397,7 @@ struct ExternalMidiNote { | |||
// ----------------------------------------------------------------------- | |||
class CarlaPluginGUI : public QMainWindow | |||
class CarlaPluginGUI : public DGL::Window//QMainWindow | |||
{ | |||
public: | |||
class Callback | |||
@@ -405,17 +407,18 @@ public: | |||
virtual void guiClosedCallback() = 0; | |||
}; | |||
CarlaPluginGUI(QWidget* const parent, Callback* const callback); | |||
CarlaPluginGUI(DGL::App* const app, Callback* const callback); | |||
//CarlaPluginGUI(QWidget* const parent, Callback* const callback); | |||
~CarlaPluginGUI(); | |||
WId getWinId() const; | |||
//WId getWinId() const; | |||
protected: | |||
void closeEvent(QCloseEvent* const event); | |||
//protected: | |||
//void closeEvent(QCloseEvent* const event); | |||
private: | |||
Callback* const kCallback; | |||
GuiContainer fContainer; | |||
//GuiContainer fContainer; | |||
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginGUI) | |||
}; | |||
@@ -426,6 +429,7 @@ struct CarlaPluginProtectedData { | |||
CarlaEngine* const engine; | |||
CarlaEngineClient* client; | |||
CarlaPluginGUI* gui; | |||
DGL::App app; | |||
bool active; | |||
bool activeBefore; | |||
@@ -578,7 +582,7 @@ struct CarlaPluginProtectedData { | |||
if (gui != nullptr) | |||
return; | |||
gui = new CarlaPluginGUI(nullptr, callback); | |||
gui = new CarlaPluginGUI(&app, callback); | |||
} | |||
void destroyUiIfNeeded() | |||
@@ -586,7 +590,7 @@ struct CarlaPluginProtectedData { | |||
if (gui == nullptr) | |||
return; | |||
gui->close(); | |||
gui->hide(); | |||
delete gui; | |||
gui = nullptr; | |||
} | |||
@@ -8,8 +8,10 @@ include ../Makefile.mk | |||
# -------------------------------------------------------------- | |||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore QtGui) | |||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore QtGui) | |||
BUILD_CXX_FLAGS += -I../../libs/distrho | |||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore gl) | |||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore gl) | |||
ifeq ($(HAVE_SUIL),true) | |||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags suil-0) | |||
@@ -361,7 +361,7 @@ public: | |||
#ifdef Q_WS_X11 | |||
//value = (intptr_t)QX11Info::display(); | |||
#endif | |||
void* const ptr = (void*)kData->gui->getWinId(); | |||
void* const ptr = (void*)kData->gui->getWindowId(); | |||
if (dispatcher(effEditOpen, 0, value, ptr, 0.0f) != 0) | |||
{ | |||
@@ -376,11 +376,11 @@ public: | |||
if (width > 0 && height > 0) | |||
{ | |||
kData->gui->setFixedSize(width, height); | |||
kData->gui->setSize(width, height); | |||
} | |||
} | |||
kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); | |||
kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName).toUtf8().constData()); | |||
kData->gui->show(); | |||
} | |||
else | |||
@@ -403,6 +403,8 @@ public: | |||
void idleGui() | |||
{ | |||
kData->app.idle(); | |||
#ifdef VESTIGE_HEADER | |||
if (fEffect != nullptr /*&& effect->ptr1*/) | |||
#else | |||
@@ -413,7 +415,10 @@ public: | |||
dispatcher(effIdle, 0, 0, nullptr, 0.0f); | |||
if (! fGui.isOsc && fGui.isVisible) | |||
{ | |||
dispatcher(effEditIdle, 0, 0, nullptr, 0.0f); | |||
kData->gui->idle(); | |||
} | |||
} | |||
CarlaPlugin::idleGui(); | |||
@@ -34,11 +34,11 @@ endif | |||
# Plugin bridges | |||
BUILD_PLUGIN_FLAGS = $(BUILD_CXX_FLAGS) -DBUILD_BRIDGE_PLUGIN -DBRIDGE_PLUGIN | |||
BUILD_PLUGIN_FLAGS += -DWANT_JACK -I../backend/engine -I../backend/plugin -I../libs | |||
BUILD_PLUGIN_FLAGS += -DWANT_JACK -I../backend/engine -I../backend/plugin -I../libs -I../libs/distrho | |||
BUILD_PLUGIN_FLAGS += $(shell pkg-config --cflags jack) $(QT_UI_FLAGS) | |||
LINK_PLUGIN_FLAGS = $(LINK_FLAGS) | |||
LINK_PLUGIN_FLAGS += $(QT_UI_LIBS) | |||
LINK_PLUGIN_FLAGS += $(QT_UI_LIBS) -lopengl32 -lgdi32 | |||
NATIVE_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) | |||
NATIVE_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) $(shell pkg-config --libs jack) -ldl | |||
@@ -393,6 +393,7 @@ OBJS_WIN32 += \ | |||
# libs | |||
OBJS_WIN32 += \ | |||
../libs/dgl.a \ | |||
../libs/lilv_win32.a \ | |||
../libs/rtmempool_win32.a | |||
@@ -21,7 +21,7 @@ | |||
#include "CarlaBackendUtils.hpp" | |||
#include <QtXml/QDomNode> | |||
#include <vector> | |||
#include <QtCore/QVector> | |||
CARLA_BACKEND_START_NAMESPACE | |||
@@ -73,8 +73,8 @@ struct StateCustomData { | |||
} | |||
}; | |||
typedef std::vector<StateParameter*> StateParameterVector; | |||
typedef std::vector<StateCustomData*> StateCustomDataVector; | |||
typedef QVector<StateParameter*> StateParameterVector; | |||
typedef QVector<StateCustomData*> StateCustomDataVector; | |||
struct SaveState { | |||
const char* type; | |||
@@ -1,20 +1,20 @@ | |||
#!/usr/bin/env python | |||
#!/usr/bin/env python3 | |||
# -*- coding: utf-8 -*- | |||
# Custom Mini Canvas Preview, a custom Qt4 widget | |||
# Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com> | |||
# | |||
# This program is free software; you can redistribute it and/or modify | |||
# it under the terms of the GNU General Public License as published by | |||
# the Free Software Foundation; either version 2 of the License, or | |||
# any later version. | |||
# This program is free software; you can redistribute it and/or | |||
# modify it under the terms of the GNU General Public License as | |||
# published by the Free Software Foundation; either version 2 of | |||
# the License, or any later version. | |||
# | |||
# This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | |||
# | |||
# For a full copy of the GNU General Public License see the COPYING file | |||
# For a full copy of the GNU General Public License see the GPL.txt file | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Imports (Global) | |||
@@ -45,8 +45,8 @@ class CanvasPreviewFrame(QFrame): | |||
self.fScale = 1.0 | |||
self.fScene = None | |||
self.fRealParent = None | |||
self.fFakeWidth = 0 | |||
self.fFakeHeight = 0 | |||
self.fFakeWidth = 0.0 | |||
self.fFakeHeight = 0.0 | |||
self.fRenderSource = self.getRenderSource() | |||
self.fRenderTarget = QRectF(0, 0, 0, 0) | |||
@@ -72,18 +72,18 @@ class CanvasPreviewFrame(QFrame): | |||
self.fRealParent = parent | |||
def getRenderSource(self): | |||
xPadding = (self.width() - self.fFakeWidth) / 2 | |||
yPadding = (self.height() - self.fFakeHeight) / 2 | |||
xPadding = (float(self.width()) - self.fFakeWidth) / 2.0 | |||
yPadding = (float(self.height()) - self.fFakeHeight) / 2.0 | |||
return QRectF(xPadding, yPadding, self.fFakeWidth, self.fFakeHeight) | |||
def setViewPosX(self, xp): | |||
x = xp * self.fFakeWidth | |||
x = self.fFakeWidth*xp | |||
xRatio = (x / self.fFakeWidth) * self.fViewRect[iWidth] / self.fScale | |||
self.fViewRect[iX] = x - xRatio + self.fRenderSource.x() | |||
self.update() | |||
def setViewPosY(self, yp): | |||
y = yp * self.fFakeHeight | |||
y = self.fFakeHeight*yp | |||
yRatio = (y / self.fFakeHeight) * self.fViewRect[iHeight] / self.fScale | |||
self.fViewRect[iY] = y - yRatio + self.fRenderSource.y() | |||
self.update() | |||
@@ -103,9 +103,9 @@ class CanvasPreviewFrame(QFrame): | |||
self.fViewBrush = QBrush(brushColor) | |||
self.fViewPen = QPen(penColor, 1) | |||
def handleMouseEvent(self, event_x, event_y): | |||
x = float(event_x) - self.fRenderSource.x() - (self.fViewRect[iWidth] / self.fScale / 2) | |||
y = float(event_y) - self.fRenderSource.y() - (self.fViewRect[iHeight] / self.fScale / 2) | |||
def handleMouseEvent(self, eventX, eventY): | |||
x = float(eventX) - self.fRenderSource.x() - (self.fViewRect[iWidth] / self.fScale / 2) | |||
y = float(eventY) - self.fRenderSource.y() - (self.fViewRect[iHeight] / self.fScale / 2) | |||
maxWidth = self.fViewRect[iWidth] / self.fScale | |||
maxHeight = self.fViewRect[iHeight] / self.fScale | |||
@@ -35,8 +35,8 @@ class LEDButton(QPushButton): | |||
def __init__(self, parent): | |||
QPushButton.__init__(self, parent) | |||
self.m_pixmap = QPixmap() | |||
self.m_pixmapRect = QRectF(0, 0, 0, 0) | |||
self.fPixmap = QPixmap() | |||
self.fPixmapRect = QRectF(0, 0, 0, 0) | |||
self.setCheckable(True) | |||
self.setText("") | |||
@@ -44,7 +44,7 @@ class LEDButton(QPushButton): | |||
self.setColor(self.BLUE) | |||
def setColor(self, color): | |||
self.m_color = color | |||
self.fColor = color | |||
if color in (self.BLUE, self.GREEN, self.RED, self.YELLOW): | |||
size = 14 | |||
@@ -56,37 +56,34 @@ class LEDButton(QPushButton): | |||
self.setPixmapSize(size) | |||
def setPixmapSize(self, size): | |||
self.m_pixmapRect = QRectF(0, 0, size, size) | |||
self.fPixmapRect = QRectF(0, 0, size, size) | |||
self.setMinimumWidth(size) | |||
self.setMaximumWidth(size) | |||
self.setMinimumHeight(size) | |||
self.setMaximumHeight(size) | |||
self.setMinimumSize(size, size) | |||
self.setMaximumSize(size, size) | |||
def paintEvent(self, event): | |||
painter = QPainter(self) | |||
event.accept() | |||
if self.isChecked(): | |||
if self.m_color == self.BLUE: | |||
self.m_pixmap.load(":/bitmaps/led_blue.png") | |||
elif self.m_color == self.GREEN: | |||
self.m_pixmap.load(":/bitmaps/led_green.png") | |||
elif self.m_color == self.RED: | |||
self.m_pixmap.load(":/bitmaps/led_red.png") | |||
elif self.m_color == self.YELLOW: | |||
self.m_pixmap.load(":/bitmaps/led_yellow.png") | |||
elif self.m_color == self.BIG_RED: | |||
self.m_pixmap.load(":/bitmaps/led-big_on.png") | |||
if self.fColor == self.BLUE: | |||
self.fPixmap.load(":/bitmaps/led_blue.png") | |||
elif self.fColor == self.GREEN: | |||
self.fPixmap.load(":/bitmaps/led_green.png") | |||
elif self.fColor == self.RED: | |||
self.fPixmap.load(":/bitmaps/led_red.png") | |||
elif self.fColor == self.YELLOW: | |||
self.fPixmap.load(":/bitmaps/led_yellow.png") | |||
elif self.fColor == self.BIG_RED: | |||
self.fPixmap.load(":/bitmaps/led-big_on.png") | |||
else: | |||
return | |||
else: | |||
if self.m_color in (self.BLUE, self.GREEN, self.RED, self.YELLOW): | |||
self.m_pixmap.load(":/bitmaps/led_off.png") | |||
elif self.m_color == self.BIG_RED: | |||
self.m_pixmap.load(":/bitmaps/led-big_off.png") | |||
if self.fColor in (self.BLUE, self.GREEN, self.RED, self.YELLOW): | |||
self.fPixmap.load(":/bitmaps/led_off.png") | |||
elif self.fColor == self.BIG_RED: | |||
self.fPixmap.load(":/bitmaps/led-big_off.png") | |||
else: | |||
return | |||
painter.drawPixmap(self.m_pixmapRect, self.m_pixmap, self.m_pixmapRect) | |||
event.accept() | |||
painter.drawPixmap(self.fPixmapRect, self.fPixmap, self.fPixmapRect) |
@@ -53,10 +53,8 @@ class PixmapButton(QPushButton): | |||
def setPixmapSize(self, size): | |||
self.fPixmapRect = QRectF(0, 0, size, size) | |||
self.setMinimumWidth(size) | |||
self.setMaximumWidth(size) | |||
self.setMinimumHeight(size) | |||
self.setMaximumHeight(size) | |||
self.setMinimumSize(size, size) | |||
self.setMaximumSize(size, size) | |||
def enterEvent(self, event): | |||
self.fIsHovered = True | |||
@@ -68,6 +66,7 @@ class PixmapButton(QPushButton): | |||
def paintEvent(self, event): | |||
painter = QPainter(self) | |||
event.accept() | |||
if not self.isEnabled(): | |||
painter.setOpacity(0.2) | |||
@@ -78,5 +77,3 @@ class PixmapButton(QPushButton): | |||
painter.drawPixmap(self.fPixmapRect, self.fPixmapHover, self.fPixmapRect) | |||
else: | |||
painter.drawPixmap(self.fPixmapRect, self.fPixmapNormal, self.fPixmapRect) | |||
event.accept() |
@@ -45,95 +45,95 @@ class PixmapDial(QDial): | |||
def __init__(self, parent): | |||
QDial.__init__(self, parent) | |||
self.m_pixmap = QPixmap(":/bitmaps/dial_01d.png") | |||
self.m_pixmapNum = "01" | |||
self.m_customPaint = self.CUSTOM_PAINT_NULL | |||
self.fPixmap = QPixmap(":/bitmaps/dial_01d.png") | |||
self.fPixmapNum = "01" | |||
self.fCustomPaint = self.CUSTOM_PAINT_NULL | |||
self.m_hovered = False | |||
self.m_hoverStep = self.HOVER_MIN | |||
self.fHovered = False | |||
self.fHoverStep = self.HOVER_MIN | |||
if self.m_pixmap.width() > self.m_pixmap.height(): | |||
self.m_orientation = self.HORIZONTAL | |||
if self.fPixmap.width() > self.fPixmap.height(): | |||
self.fOrientation = self.HORIZONTAL | |||
else: | |||
self.m_orientation = self.VERTICAL | |||
self.fOrientation = self.VERTICAL | |||
self.m_label = "" | |||
self.m_labelPos = QPointF(0.0, 0.0) | |||
self.m_labelFont = QFont() | |||
self.m_labelFont.setPointSize(6) | |||
self.m_labelWidth = 0 | |||
self.m_labelHeight = 0 | |||
self.m_labelGradient = QLinearGradient(0, 0, 0, 1) | |||
self.fLabel = "" | |||
self.fLabelPos = QPointF(0.0, 0.0) | |||
self.fLabelFont = QFont() | |||
self.fLabelFont.setPointSize(6) | |||
self.fLabelWidth = 0 | |||
self.fLabelHeight = 0 | |||
self.fLabelGradient = QLinearGradient(0, 0, 0, 1) | |||
if self.palette().window().color().lightness() > 100: | |||
# Light background | |||
c = self.palette().dark().color() | |||
self.m_color1 = c | |||
self.m_color2 = QColor(c.red(), c.green(), c.blue(), 0) | |||
self.m_colorT = [self.palette().buttonText().color(), self.palette().mid().color()] | |||
self.fColor1 = c | |||
self.fColor2 = QColor(c.red(), c.green(), c.blue(), 0) | |||
self.fColorT = [self.palette().buttonText().color(), self.palette().mid().color()] | |||
else: | |||
# Dark background | |||
self.m_color1 = QColor(0, 0, 0, 255) | |||
self.m_color2 = QColor(0, 0, 0, 0) | |||
self.m_colorT = [Qt.white, Qt.darkGray] | |||
self.fColor1 = QColor(0, 0, 0, 255) | |||
self.fColor2 = QColor(0, 0, 0, 0) | |||
self.fColorT = [Qt.white, Qt.darkGray] | |||
self.updateSizes() | |||
def getSize(self): | |||
return self.p_size | |||
return self.fSize | |||
def setCustomPaint(self, paint): | |||
self.m_customPaint = paint | |||
self.m_labelPos.setY(self.p_size + self.m_labelHeight/2) | |||
self.fCustomPaint = paint | |||
self.fLabelPos.setY(self.fSize + self.fLabelHeight/2) | |||
self.update() | |||
def setEnabled(self, enabled): | |||
if self.isEnabled() != enabled: | |||
self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmapNum, "" if enabled else "d")) | |||
self.fPixmap.load(":/bitmaps/dial_%s%s.png" % (self.fPixmapNum, "" if enabled else "d")) | |||
self.updateSizes() | |||
self.update() | |||
QDial.setEnabled(self, enabled) | |||
def setLabel(self, label): | |||
self.m_label = label | |||
self.fLabel = label | |||
self.m_labelWidth = QFontMetrics(self.m_labelFont).width(label) | |||
self.m_labelHeight = QFontMetrics(self.m_labelFont).height() | |||
self.fLabelWidth = QFontMetrics(self.fLabelFont).width(label) | |||
self.fLabelHeight = QFontMetrics(self.fLabelFont).height() | |||
self.m_labelPos.setX(float(self.p_size)/2 - float(self.m_labelWidth)/2) | |||
self.m_labelPos.setY(self.p_size + self.m_labelHeight) | |||
self.fLabelPos.setX(float(self.fSize)/2 - float(self.fLabelWidth)/2) | |||
self.fLabelPos.setY(self.fSize + self.fLabelHeight) | |||
self.m_labelGradient.setColorAt(0.0, self.m_color1) | |||
self.m_labelGradient.setColorAt(0.6, self.m_color1) | |||
self.m_labelGradient.setColorAt(1.0, self.m_color2) | |||
self.fLabelGradient.setColorAt(0.0, self.fColor1) | |||
self.fLabelGradient.setColorAt(0.6, self.fColor1) | |||
self.fLabelGradient.setColorAt(1.0, self.fColor2) | |||
self.m_labelGradient.setStart(0, float(self.p_size)/2) | |||
self.m_labelGradient.setFinalStop(0, self.p_size + self.m_labelHeight + 5) | |||
self.fLabelGradient.setStart(0, float(self.fSize)/2) | |||
self.fLabelGradient.setFinalStop(0, self.fSize + self.fLabelHeight + 5) | |||
self.m_labelGradient_rect = QRectF(float(self.p_size)/8, float(self.p_size)/2, float(self.p_size)*6/8, self.p_size+self.m_labelHeight+5) | |||
self.fLabelGradientRect = QRectF(float(self.fSize)/8, float(self.fSize)/2, float(self.fSize)*6/8, self.fSize+self.fLabelHeight+5) | |||
self.update() | |||
def setPixmap(self, pixmapId): | |||
self.m_pixmapNum = "%02i" % pixmapId | |||
self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmapNum, "" if self.isEnabled() else "d")) | |||
self.fPixmapNum = "%02i" % pixmapId | |||
self.fPixmap.load(":/bitmaps/dial_%s%s.png" % (self.fPixmapNum, "" if self.isEnabled() else "d")) | |||
if self.m_pixmap.width() > self.m_pixmap.height(): | |||
self.m_orientation = self.HORIZONTAL | |||
if self.fPixmap.width() > self.fPixmap.height(): | |||
self.fOrientation = self.HORIZONTAL | |||
else: | |||
self.m_orientation = self.VERTICAL | |||
self.fOrientation = self.VERTICAL | |||
self.updateSizes() | |||
self.update() | |||
def minimumSizeHint(self): | |||
return QSize(self.p_size, self.p_size) | |||
return QSize(self.fSize, self.fSize) | |||
def sizeHint(self): | |||
return QSize(self.p_size, self.p_size) | |||
return QSize(self.fSize, self.fSize) | |||
def updateSizes(self): | |||
self.p_width = self.m_pixmap.width() | |||
self.p_height = self.m_pixmap.height() | |||
self.p_width = self.fPixmap.width() | |||
self.p_height = self.fPixmap.height() | |||
if self.p_width < 1: | |||
self.p_width = 1 | |||
@@ -141,41 +141,41 @@ class PixmapDial(QDial): | |||
if self.p_height < 1: | |||
self.p_height = 1 | |||
if self.m_orientation == self.HORIZONTAL: | |||
self.p_size = self.p_height | |||
if self.fOrientation == self.HORIZONTAL: | |||
self.fSize = self.p_height | |||
self.p_count = self.p_width / self.p_height | |||
else: | |||
self.p_size = self.p_width | |||
self.fSize = self.p_width | |||
self.p_count = self.p_height / self.p_width | |||
self.setMinimumSize(self.p_size, self.p_size + self.m_labelHeight + 5) | |||
self.setMaximumSize(self.p_size, self.p_size + self.m_labelHeight + 5) | |||
self.setMinimumSize(self.fSize, self.fSize + self.fLabelHeight + 5) | |||
self.setMaximumSize(self.fSize, self.fSize + self.fLabelHeight + 5) | |||
def enterEvent(self, event): | |||
self.m_hovered = True | |||
if self.m_hoverStep == self.HOVER_MIN: | |||
self.m_hoverStep += 1 | |||
self.fHovered = True | |||
if self.fHoverStep == self.HOVER_MIN: | |||
self.fHoverStep += 1 | |||
QDial.enterEvent(self, event) | |||
def leaveEvent(self, event): | |||
self.m_hovered = False | |||
if self.m_hoverStep == self.HOVER_MAX: | |||
self.m_hoverStep -= 1 | |||
self.fHovered = False | |||
if self.fHoverStep == self.HOVER_MAX: | |||
self.fHoverStep -= 1 | |||
QDial.leaveEvent(self, event) | |||
def paintEvent(self, event): | |||
painter = QPainter(self) | |||
painter.setRenderHint(QPainter.Antialiasing, True) | |||
if self.m_label: | |||
if self.m_customPaint == self.CUSTOM_PAINT_NULL: | |||
painter.setPen(self.m_color2) | |||
painter.setBrush(self.m_labelGradient) | |||
painter.drawRect(self.m_labelGradient_rect) | |||
if self.fLabel: | |||
if self.fCustomPaint == self.CUSTOM_PAINT_NULL: | |||
painter.setPen(self.fColor2) | |||
painter.setBrush(self.fLabelGradient) | |||
painter.drawRect(self.fLabelGradientRect) | |||
painter.setFont(self.m_labelFont) | |||
painter.setPen(self.m_colorT[0 if self.isEnabled() else 1]) | |||
painter.drawText(self.m_labelPos, self.m_label) | |||
painter.setFont(self.fLabelFont) | |||
painter.setPen(self.fColorT[0 if self.isEnabled() else 1]) | |||
painter.drawText(self.fLabelPos, self.fLabel) | |||
if self.isEnabled(): | |||
current = float(self.value() - self.minimum()) | |||
@@ -185,25 +185,25 @@ class PixmapDial(QDial): | |||
return | |||
value = current / divider | |||
target = QRectF(0.0, 0.0, self.p_size, self.p_size) | |||
target = QRectF(0.0, 0.0, self.fSize, self.fSize) | |||
per = int((self.p_count - 1) * value) | |||
if self.m_orientation == self.HORIZONTAL: | |||
xpos = self.p_size * per | |||
if self.fOrientation == self.HORIZONTAL: | |||
xpos = self.fSize * per | |||
ypos = 0.0 | |||
else: | |||
xpos = 0.0 | |||
ypos = self.p_size * per | |||
ypos = self.fSize * per | |||
source = QRectF(xpos, ypos, self.p_size, self.p_size) | |||
painter.drawPixmap(target, self.m_pixmap, source) | |||
source = QRectF(xpos, ypos, self.fSize, self.fSize) | |||
painter.drawPixmap(target, self.fPixmap, source) | |||
# Custom knobs (Dry/Wet and Volume) | |||
if self.m_customPaint in (self.CUSTOM_PAINT_CARLA_WET, self.CUSTOM_PAINT_CARLA_VOL): | |||
if self.fCustomPaint in (self.CUSTOM_PAINT_CARLA_WET, self.CUSTOM_PAINT_CARLA_VOL): | |||
# knob color | |||
colorGreen = QColor(0x5D, 0xE7, 0x3D, 191 + self.m_hoverStep*7) | |||
colorBlue = QColor(0x3E, 0xB8, 0xBE, 191 + self.m_hoverStep*7) | |||
colorGreen = QColor(0x5D, 0xE7, 0x3D, 191 + self.fHoverStep*7) | |||
colorBlue = QColor(0x3E, 0xB8, 0xBE, 191 + self.fHoverStep*7) | |||
# draw small circle | |||
ballRect = QRectF(8.0, 8.0, 15.0, 15.0) | |||
@@ -218,7 +218,7 @@ class PixmapDial(QDial): | |||
startAngle = 216*16 | |||
spanAngle = -252*16*value | |||
if self.m_customPaint == self.CUSTOM_PAINT_CARLA_WET: | |||
if self.fCustomPaint == self.CUSTOM_PAINT_CARLA_WET: | |||
painter.setBrush(colorBlue) | |||
painter.setPen(QPen(colorBlue, 0)) | |||
painter.drawEllipse(QRectF(ballPoint.x(), ballPoint.y(), 2.2, 2.2)) | |||
@@ -244,9 +244,9 @@ class PixmapDial(QDial): | |||
painter.drawArc(4.0, 4.0, 26.0, 26.0, startAngle, spanAngle) | |||
# Custom knobs (L and R) | |||
elif self.m_customPaint in (self.CUSTOM_PAINT_CARLA_L, self.CUSTOM_PAINT_CARLA_R): | |||
elif self.fCustomPaint in (self.CUSTOM_PAINT_CARLA_L, self.CUSTOM_PAINT_CARLA_R): | |||
# knob color | |||
color = QColor(0xAD + self.m_hoverStep*5, 0xD5 + self.m_hoverStep*4, 0x4B + self.m_hoverStep*5) | |||
color = QColor(0xAD + self.fHoverStep*5, 0xD5 + self.fHoverStep*4, 0x4B + self.fHoverStep*5) | |||
# draw small circle | |||
ballRect = QRectF(7.0, 8.0, 11.0, 12.0) | |||
@@ -262,10 +262,10 @@ class PixmapDial(QDial): | |||
painter.drawEllipse(QRectF(ballPoint.x(), ballPoint.y(), 2.0, 2.0)) | |||
# draw arc | |||
if self.m_customPaint == self.CUSTOM_PAINT_CARLA_L: | |||
if self.fCustomPaint == self.CUSTOM_PAINT_CARLA_L: | |||
startAngle = 216*16 | |||
spanAngle = -252.0*16*value | |||
elif self.m_customPaint == self.CUSTOM_PAINT_CARLA_R: | |||
elif self.fCustomPaint == self.CUSTOM_PAINT_CARLA_R: | |||
startAngle = 324.0*16 | |||
spanAngle = 252.0*16*(1.0-value) | |||
else: | |||
@@ -274,13 +274,13 @@ class PixmapDial(QDial): | |||
painter.setPen(QPen(color, 2)) | |||
painter.drawArc(3.5, 4.5, 22.0, 22.0, startAngle, spanAngle) | |||
if self.HOVER_MIN < self.m_hoverStep < self.HOVER_MAX: | |||
self.m_hoverStep += 1 if self.m_hovered else -1 | |||
if self.HOVER_MIN < self.fHoverStep < self.HOVER_MAX: | |||
self.fHoverStep += 1 if self.fHovered else -1 | |||
QTimer.singleShot(20, self, SLOT("update()")) | |||
else: | |||
target = QRectF(0.0, 0.0, self.p_size, self.p_size) | |||
painter.drawPixmap(target, self.m_pixmap, target) | |||
target = QRectF(0.0, 0.0, self.fSize, self.fSize) | |||
painter.drawPixmap(target, self.fPixmap, target) | |||
event.accept() | |||