Skip to content

Commit

Permalink
A few more C++ frontend details, stub for plugin list dialog
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Oct 23, 2022
1 parent de6833a commit 680c46c
Show file tree
Hide file tree
Showing 18 changed files with 283 additions and 60 deletions.
1 change: 0 additions & 1 deletion bin/carla.lv2/resources

This file was deleted.

3 changes: 2 additions & 1 deletion source/frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ QMs = $(patsubst %,translations/carla_%.qm,$(I18N_LANGUAGES))
CPP_FILES = \
carla_frontend.cpp \
dialogs/aboutjucedialog.cpp \
dialogs/jackappdialog.cpp
dialogs/jackappdialog.cpp \
pluginlist/pluginlistdialog.cpp

OBJS = $(CPP_FILES:%=$(OBJDIR)/%.o)

Expand Down
32 changes: 23 additions & 9 deletions source/frontend/carla_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Imports (ctypes)

from ctypes import (
c_char_p, c_void_p, cast,
c_bool, c_char_p, c_int, c_void_p, cast,
cdll, Structure,
POINTER
)
Expand Down Expand Up @@ -53,25 +53,39 @@ class JackApplicationDialogResults(Structure):
("labelSetup", c_char_p)
]

class PluginListDialogResults(Structure):
_fields_ = [
("btype", c_int),
("ptype", c_int),
("binary", c_char_p),
("label", c_char_p)
]

# ------------------------------------------------------------------------------------------------------------
# Carla Frontend object using a DLL

class CarlaFrontendLib():
def __init__(self, filename):
self.lib = cdll.LoadLibrary(filename)

self.lib.carla_frontend_createAndExecAboutJuceW.argtypes = (c_void_p,)
self.lib.carla_frontend_createAndExecAboutJuceW.restype = None
self.lib.carla_frontend_createAndExecAboutJuceDialog.argtypes = (c_void_p,)
self.lib.carla_frontend_createAndExecAboutJuceDialog.restype = None

self.lib.carla_frontend_createAndExecJackApplicationW.argtypes = (c_void_p, c_char_p)
self.lib.carla_frontend_createAndExecJackApplicationW.restype = POINTER(JackApplicationDialogResults)
self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)

self.lib.carla_frontend_createAndExecPluginListDialog.argtypes = (c_void_p, c_bool)
self.lib.carla_frontend_createAndExecPluginListDialog.restype = POINTER(JackApplicationDialogResults)

# --------------------------------------------------------------------------------------------------------

def createAndExecAboutJuceW(self, parent):
self.lib.carla_frontend_createAndExecAboutJuceW(unwrapinstance(parent))
def createAndExecAboutJuceDialog(self, parent):
self.lib.carla_frontend_createAndExecAboutJuceDialog(unwrapinstance(parent))

def createAndExecJackAppDialog(self, parent, projectFilename):
return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent), projectFilename.encode("utf-8")))

def createAndExecJackApplicationW(self, parent, projectFilename):
return structToDictOrNull(self.lib.carla_frontend_createAndExecJackApplicationW(unwrapinstance(parent), projectFilename.encode("utf-8")))
def createAndExecPluginListDialog(self, parent, useSystemIcons):
self.lib.carla_frontend_createAndExecPluginListDialog(unwrapinstance(parent), useSystemIcons)

# ------------------------------------------------------------------------------------------------------------
15 changes: 10 additions & 5 deletions source/frontend/carla_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from carla_widgets import *

from patchcanvas import patchcanvas
from pluginlist import PluginDatabaseW
from pluginlist import PluginListDialog
from widgets.digitalpeakmeter import DigitalPeakMeter
from widgets.pixmapkeyboard import PixmapKeyboardHArea

Expand Down Expand Up @@ -1208,9 +1208,14 @@ def removeAllPlugins(self):
# Plugins (menu actions)

def showAddPluginDialog(self):
#ret = gCarla.felib.createAndExecPluginListDialog(self.fParentOrSelf,
#self.fSavedSettings[CARLA_KEY_MAIN_SYSTEM_ICONS])
#print(ret)
#return

if self.fPluginDatabaseDialog is None:
self.fPluginDatabaseDialog = PluginDatabaseW(self.fParentOrSelf, self.host,
self.fSavedSettings[CARLA_KEY_MAIN_SYSTEM_ICONS])
self.fPluginDatabaseDialog = PluginListDialog(self.fParentOrSelf, self.host,
self.fSavedSettings[CARLA_KEY_MAIN_SYSTEM_ICONS])
dialog = self.fPluginDatabaseDialog
dialog.hasLoadedLv2Plugins = self.fHasLoadedLv2Plugins

Expand All @@ -1236,7 +1241,7 @@ def showAddPluginDialog(self):
return (btype, ptype, filename, label, uniqueId, extraPtr)

def showAddJackAppDialog(self):
ret = gCarla.felib.createAndExecJackApplicationW(self.fParentOrSelf, self.fProjectFilename)
ret = gCarla.felib.createAndExecJackAppDialog(self.fParentOrSelf, self.fProjectFilename)

if not ret:
return
Expand Down Expand Up @@ -2109,7 +2114,7 @@ def slot_aboutCarla(self):

@pyqtSlot()
def slot_aboutJuce(self):
gCarla.felib.createAndExecAboutJuceW(self.fParentOrSelf)
gCarla.felib.createAndExecAboutJuceDialog(self.fParentOrSelf)

@pyqtSlot()
def slot_aboutQt(self):
Expand Down
6 changes: 6 additions & 0 deletions source/frontend/dialogs/.kdev_include_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/usr/include/x86_64-linux-gnu/qt5
../utils/
../../backend/
../../includes/
../../modules/
../../utils/
4 changes: 2 additions & 2 deletions source/frontend/dialogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.

from .aboutjucedialog import AboutJuceW
from .jackappdialog import JackApplicationW
from .aboutjucedialog import AboutJuceDialog
from .jackappdialog import JackAppDialog
10 changes: 5 additions & 5 deletions source/frontend/dialogs/aboutjucedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// --------------------------------------------------------------------------------------------------------------------
// Jack Application Dialog

struct AboutJuceW::Self {
struct AboutJuceDialog::Self {
Ui_AboutJuceDialog ui;

Self() {}
Expand All @@ -52,7 +52,7 @@ struct AboutJuceW::Self {
}
};

AboutJuceW::AboutJuceW(QWidget* const parent)
AboutJuceDialog::AboutJuceDialog(QWidget* const parent)
: QDialog(parent),
self(Self::create())
{
Expand Down Expand Up @@ -81,16 +81,16 @@ AboutJuceW::AboutJuceW(QWidget* const parent)
#endif
}

AboutJuceW::~AboutJuceW()
AboutJuceDialog::~AboutJuceDialog()
{
delete &self;
}

// --------------------------------------------------------------------------------------------------------------------

void carla_frontend_createAndExecAboutJuceW(void* const parent)
void carla_frontend_createAndExecAboutJuceDialog(void* const parent)
{
AboutJuceW(reinterpret_cast<QWidget*>(parent)).exec();
AboutJuceDialog(reinterpret_cast<QWidget*>(parent)).exec();
}

// --------------------------------------------------------------------------------------------------------------------
10 changes: 6 additions & 4 deletions source/frontend/dialogs/aboutjucedialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#pragma once

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy"
Expand All @@ -38,23 +40,23 @@
// --------------------------------------------------------------------------------------------------------------------
// About JUCE dialog

class AboutJuceW : public QDialog
class AboutJuceDialog : public QDialog
{
struct Self;
Self& self;

// ----------------------------------------------------------------------------------------------------------------

public:
explicit AboutJuceW(QWidget* parent);
~AboutJuceW() override;
explicit AboutJuceDialog(QWidget* parent);
~AboutJuceDialog() override;
};

// --------------------------------------------------------------------------------------------------------------------

extern "C" {

CARLA_API void carla_frontend_createAndExecAboutJuceW(void* parent);
CARLA_API void carla_frontend_createAndExecAboutJuceDialog(void* parent);

}

Expand Down
4 changes: 2 additions & 2 deletions source/frontend/dialogs/aboutjucedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# ------------------------------------------------------------------------------------------------------------
# About JUCE dialog

class AboutJuceW(QDialog):
class AboutJuceDialog(QDialog):
def __init__(self, parent):
QDialog.__init__(self, parent)
self.ui = Ui_AboutJuceDialog()
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self, parent):
# gCarla.utils = CarlaUtils(os.path.dirname(__file__) + "/../../../bin/libcarla_utils.dylib")

_app = QApplication(sys.argv)
_gui = AboutJuceW(None)
_gui = AboutJuceDialog(None)
_gui.exec_()

# ---------------------------------------------------------------------------------------------------------------------
34 changes: 17 additions & 17 deletions source/frontend/dialogs/jackappdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum {
UI_SESSION_NSM = 2,
};

struct JackApplicationW::Self {
struct JackAppDialog::Self {
Ui_JackAppDialog ui;
const QString fProjectFilename;

Expand All @@ -66,7 +66,7 @@ struct JackApplicationW::Self {
}
};

JackApplicationW::JackApplicationW(QWidget* const parent, const char* const projectFilename)
JackAppDialog::JackAppDialog(QWidget* const parent, const char* const projectFilename)
: QDialog(parent),
self(Self::create(projectFilename))
{
Expand Down Expand Up @@ -94,22 +94,22 @@ JackApplicationW::JackApplicationW(QWidget* const parent, const char* const proj
// Set-up connections

connect(this, &QDialog::finished,
this, &JackApplicationW::slot_saveSettings);
this, &JackAppDialog::slot_saveSettings);
connect(self.ui.cb_session_mgr, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &JackApplicationW::slot_sessionManagerChanged);
this, &JackAppDialog::slot_sessionManagerChanged);
connect(self.ui.le_command, &QLineEdit::textChanged,
this, &JackApplicationW::slot_commandChanged);
this, &JackAppDialog::slot_commandChanged);
}

JackApplicationW::~JackApplicationW()
JackAppDialog::~JackAppDialog()
{
delete &self;
}

// -----------------------------------------------------------------------------------------------------------------
// public methods

JackApplicationW::CommandAndFlags JackApplicationW::getCommandAndFlags() const
JackAppDialog::CommandAndFlags JackAppDialog::getCommandAndFlags() const
{
const QString command = self.ui.le_command->text();
QString name = self.ui.le_name->text();
Expand Down Expand Up @@ -159,7 +159,7 @@ JackApplicationW::CommandAndFlags JackApplicationW::getCommandAndFlags() const
// -----------------------------------------------------------------------------------------------------------------
// private methods

void JackApplicationW::checkIfButtonBoxShouldBeEnabled(const int index, const QCarlaString& command)
void JackAppDialog::checkIfButtonBoxShouldBeEnabled(const int index, const QCarlaString& command)
{
bool enabled = command.isNotEmpty();
QCarlaString showErr;
Expand Down Expand Up @@ -190,7 +190,7 @@ void JackApplicationW::checkIfButtonBoxShouldBeEnabled(const int index, const QC
button->setEnabled(enabled);
}

void JackApplicationW::loadSettings()
void JackAppDialog::loadSettings()
{
const QSafeSettings settings("falkTX", "CarlaAddJackApp");

Expand Down Expand Up @@ -221,17 +221,17 @@ void JackApplicationW::loadSettings()
// -----------------------------------------------------------------------------------------------------------------
// private slots

void JackApplicationW::slot_commandChanged(const QString& command)
void JackAppDialog::slot_commandChanged(const QString& command)
{
checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr->currentIndex(), command);
}

void JackApplicationW::slot_sessionManagerChanged(const int index)
void JackAppDialog::slot_sessionManagerChanged(const int index)
{
checkIfButtonBoxShouldBeEnabled(index, self.ui.le_command->text());
}

void JackApplicationW::slot_saveSettings()
void JackAppDialog::slot_saveSettings()
{
QSafeSettings settings("falkTX", "CarlaAddJackApp");
settings.setValue("Command", self.ui.le_command->text());
Expand All @@ -248,18 +248,18 @@ void JackApplicationW::slot_saveSettings()

// --------------------------------------------------------------------------------------------------------------------

JackApplicationDialogResults* carla_frontend_createAndExecJackApplicationW(void* const parent, const char* const projectFilename)
JackAppDialogResults* carla_frontend_createAndExecJackAppDialog(void* const parent, const char* const projectFilename)
{
JackApplicationW gui(reinterpret_cast<QWidget*>(parent), projectFilename);
JackAppDialog gui(reinterpret_cast<QWidget*>(parent), projectFilename);

if (gui.exec())
{
static JackApplicationDialogResults ret = {};
static JackAppDialogResults ret = {};
static CarlaString retCommand;
static CarlaString retName;
static CarlaString retLabelSetup;

const JackApplicationW::CommandAndFlags cafs = gui.getCommandAndFlags();
const JackAppDialog::CommandAndFlags cafs = gui.getCommandAndFlags();
retCommand = cafs.command.toUtf8().constData();
retName = cafs.name.toUtf8().constData();
retLabelSetup = cafs.labelSetup.toUtf8().constData();
Expand All @@ -284,7 +284,7 @@ int main(int argc, char* argv[])
{
QApplication app(argc, argv);

if (JackApplicationDialogResults* const res = carla_frontend_createAndExecJackApplicationW(nullptr, ""))
if (JackAppDialogResults* const res = carla_frontend_createAndExecJackAppDialog(nullptr, ""))
{
printf("Results:\n");
printf("\tCommand: %s\n", res->command);
Expand Down
12 changes: 7 additions & 5 deletions source/frontend/dialogs/jackappdialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#pragma once

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy"
Expand All @@ -38,16 +40,16 @@
// --------------------------------------------------------------------------------------------------------------------
// Jack Application Dialog

class JackApplicationW : public QDialog
class JackAppDialog : public QDialog
{
struct Self;
Self& self;

// ----------------------------------------------------------------------------------------------------------------

public:
explicit JackApplicationW(QWidget* parent, const char* projectFilename);
~JackApplicationW() override;
explicit JackAppDialog(QWidget* parent, const char* projectFilename);
~JackAppDialog() override;

// ----------------------------------------------------------------------------------------------------------------
// public methods
Expand Down Expand Up @@ -79,13 +81,13 @@ private slots:

extern "C" {

struct JackApplicationDialogResults {
struct JackAppDialogResults {
const char* command;
const char* name;
const char* labelSetup;
};

CARLA_API JackApplicationDialogResults* carla_frontend_createAndExecJackApplicationW(void* parent, const char* projectFilename);
CARLA_API JackAppDialogResults* carla_frontend_createAndExecJackAppDialog(void* parent, const char* projectFilename);

}

Expand Down
Loading

0 comments on commit 680c46c

Please sign in to comment.