aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jalv.c27
-rw-r--r--src/jalv_console.c6
-rw-r--r--src/jalv_gtk2.c13
-rw-r--r--src/jalv_internal.h7
-rw-r--r--src/jalv_qt4.cpp13
-rw-r--r--wscript4
6 files changed, 69 insertions, 1 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 3f25734..5f4e80a 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -34,6 +34,9 @@
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
+#ifdef HAVE_LV2_UI_RESIZE
+# include "lv2/lv2plug.in/ns/ext/ui-resize/ui-resize.h"
+#endif
#include "lilv/lilv.h"
@@ -67,9 +70,27 @@ static LV2_URI_Map_Feature uri_map = { NULL, &uri_to_id };
static const LV2_Feature uri_map_feature = { NS_EXT "uri-map", &uri_map };
static LV2_Feature instance_feature = { NS_EXT "instance-access", NULL };
+#ifdef HAVE_LV2_UI_RESIZE
+static int
+lv2_ui_resize(LV2_UI_Resize_Feature_Data data, int width, int height)
+{
+ Jalv* jalv = (Jalv*)data;
+ jalv->ui_width = width;
+ jalv->ui_height = height;
+ return jalv_ui_resize(jalv, width, height);
+}
+
+LV2_UI_Resize_Feature ui_resize = { NULL, &lv2_ui_resize };
+static const LV2_Feature ui_resize_feature = { NS_EXT "ui-resize#UIResize", &ui_resize };
+
+const LV2_Feature* features[4] = {
+ &uri_map_feature, &instance_feature, &ui_resize_feature
+};
+#else
const LV2_Feature* features[3] = {
&uri_map_feature, &instance_feature, NULL
};
+#endif
/** Abort and exit on error */
static void
@@ -431,6 +452,12 @@ main(int argc, char** argv)
"http://lv2plug.in/ns/ext/event",
"http://lv2plug.in/ns/ext/midi#MidiEvent");
+#ifdef HAVE_LV2_UI_RESIZE
+ ui_resize.data = &host;
+ host.ui_width = -1;
+ host.ui_height = -1;
+#endif
+
sem_init(&exit_sem, 0, 0);
host.done = &exit_sem;
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 6c0addd..29ac146 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -36,6 +36,12 @@ print_usage(const char* name, bool error)
}
int
+jalv_ui_resize(Jalv* jalv, int width, int height)
+{
+ return 0;
+}
+
+int
jalv_init(int* argc, char*** argv, JalvOptions* opts)
{
int a = 1;
diff --git a/src/jalv_gtk2.c b/src/jalv_gtk2.c
index d1a4a00..fae3f6a 100644
--- a/src/jalv_gtk2.c
+++ b/src/jalv_gtk2.c
@@ -86,6 +86,17 @@ on_quit_activate(GtkWidget* widget,
gtk_widget_destroy(window);
}
+int
+jalv_ui_resize(Jalv* jalv, int width, int height)
+{
+ if (jalv->ui_instance) {
+ GtkWidget* widget = (GtkWidget*)suil_instance_get_widget(jalv->ui_instance);
+ if (widget) {
+ gtk_widget_set_size_request(GTK_WIDGET(widget), width, height);
+ }
+ }
+ return 0;
+}
int
jalv_open_ui(Jalv* jalv,
@@ -130,6 +141,8 @@ jalv_open_ui(Jalv* jalv,
g_timeout_add(1000 / JALV_UI_UPDATE_HZ,
(GSourceFunc)jalv_emit_ui_events, jalv);
+
+ jalv_ui_resize(jalv, jalv->ui_width, jalv->ui_height);
} else {
GtkWidget* button = gtk_button_new_with_label("Close");
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 9a36f9a..9b2946c 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -75,6 +75,10 @@ typedef struct {
JalvOptions opts; /**< Command-line options */
const char* prog_name; /**< Program name (argv[0]) */
LilvWorld* world; /**< Lilv World */
+#ifdef HAVE_LV2_UI_RESIZE
+ int ui_width; /**< Requested UI width */
+ int ui_height; /**< Requested UI height */
+#endif
SerdReader* reader; /**< RDF reader (for persistence) */
SerdWriter* writer; /**< RDF writer (for persistence) */
struct Property* props; /**< Restored state properties */
@@ -127,6 +131,9 @@ jalv_open_ui(Jalv* jalv,
bool
jalv_emit_ui_events(Jalv* jalv);
+int
+jalv_ui_resize(Jalv* jalv, int width, int height);
+
void
jalv_save(Jalv* jalv, const char* dir);
diff --git a/src/jalv_qt4.cpp b/src/jalv_qt4.cpp
index 7673165..a765770 100644
--- a/src/jalv_qt4.cpp
+++ b/src/jalv_qt4.cpp
@@ -39,6 +39,18 @@ jalv_native_ui_type(Jalv* jalv)
"http://lv2plug.in/ns/extensions/ui#Qt4UI");
}
+int
+jalv_ui_resize(Jalv* jalv, int width, int height)
+{
+ if (jalv->ui_instance && width > 0 && height > 0) {
+ QWidget* widget = (QWidget*)suil_instance_get_widget(jalv->ui_instance);
+ if (widget) {
+ widget->resize(width, height);
+ }
+ }
+ return 0;
+}
+
class Timer : public QTimer {
public:
Timer(Jalv* j) : jalv(j) {}
@@ -58,6 +70,7 @@ jalv_open_ui(Jalv* jalv,
if (instance) {
QWidget* widget = (QWidget*)suil_instance_get_widget(instance);
widget->show();
+ jalv_ui_resize(jalv, jalv->ui_width, jalv->ui_height);
} else {
QPushButton* button = new QPushButton("Close");
button->show();
diff --git a/wscript b/wscript
index d7c7a25..b75fc80 100644
--- a/wscript
+++ b/wscript
@@ -30,7 +30,7 @@ def options(opt):
def configure(conf):
conf.load('compiler_c')
conf.load('compiler_cxx')
- conf.line_just = 44
+ conf.line_just = 46
autowaf.configure(conf)
autowaf.display_header('Jalv Configuration')
@@ -55,6 +55,8 @@ def configure(conf):
uselib_store='LV2_URI_MAP')
autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-persist',
uselib_store='LV2_PERSIST', mandatory=False)
+ autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-ui-resize',
+ uselib_store='LV2_UI_RESIZE', mandatory=False)
if not Options.options.no_jack_session:
autowaf.define(conf, 'JALV_JACK_SESSION', 1)