Commit 072b9722 authored by Hanspeter Portner's avatar Hanspeter Portner

include submodule eo_ui.lv2.

parent 013da81e
[submodule "eo_ui.lv2"]
path = eo_ui.lv2
url = https://github.com/OpenMusicKontrollers/eo_ui.lv2.git
[submodule "libosc"]
path = libosc
url = https://github.com/OpenMusicKontrollers/libosc.git
......@@ -5,6 +5,7 @@ project(lua.lv2)
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/tlsf-3.0)
include_directories(${PROJECT_SOURCE_DIR}/libosc)
include_directories(${PROJECT_SOURCE_DIR}/eo_ui.lv2)
set(DEST lib/lv2/lua.lv2)
set(LIB_EXT ".so")
......@@ -19,6 +20,10 @@ pkg_search_module(ELM REQUIRED elementary>=1.8)
include_directories(${ELM_INCLUDE_DIRS})
set(LIBS_UI ${LIBS_UI} ${ELM_LDFLAGS})
if((${ELM_VERSION} VERSION_EQUAL "1.13.0") OR (${ELM_VERSION} VERSION_GREATER "1.13.0"))
add_definitions("-DELM_HAS_FAKE")
endif()
option(USE_LUAJIT "use LuaJIT" ON)
if(USE_LUAJIT)
pkg_search_module(LUAJIT REQUIRED luajit>=2.0)
......
Subproject commit 39d881410526f5568c016c5227ef501b3150f6ed
Subproject commit e1eea6fbbfd10bd0f4861b26c7e039d198bb1f44
......@@ -22,6 +22,7 @@
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
@prefix midi: <http://lv2plug.in/ns/ext/midi#> .
@prefix state: <http://lv2plug.in/ns/ext/state#> .
@prefix kx: <http://kxstudio.sf.net/ns/lv2ext/external-ui#> .
@prefix osc: <http://opensoundcontrol.org#> .
@prefix lic: <http://opensource.org/licenses/> .
......@@ -43,8 +44,23 @@ proj:lua
doap:name "Lua Bundle" .
# Common UI
lua:common_eo
a ui:EoUI ;
ui:portNotification [
ui:plugin lua:control ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] , [
ui:plugin lua:midi ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] , [
ui:plugin lua:osc ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] .
lua:common_ui
a ui:X11UI ;
a ui:UI ;
ui:portNotification [
ui:plugin lua:control ;
lv2:symbol "notify" ;
......@@ -59,11 +75,9 @@ lua:common_ui
ui:protocol atom:eventTransfer ;
] ;
lv2:requiredFeature ui:idleInterface ;
lv2:optionalFeature ui:noUserResize ;
lv2:extensionData ui:idleInterface, ui:showInterface .
lua:common_eo
a ui:EoUI ;
lua:common_x11
a ui:X11UI ;
ui:portNotification [
ui:plugin lua:control ;
lv2:symbol "notify" ;
......@@ -76,7 +90,26 @@ lua:common_eo
ui:plugin lua:osc ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] .
] ;
lv2:requiredFeature ui:idleInterface ;
lv2:optionalFeature ui:resize ;
lv2:extensionData ui:idleInterface .
lua:common_kx
a kx:Widget ;
ui:portNotification [
ui:plugin lua:control ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] , [
ui:plugin lua:midi ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] , [
ui:plugin lua:osc ;
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer ;
] ;
lv2:requiredFeature kx:Host .
# Control Plugin
lua:control
......
......@@ -19,9 +19,13 @@
#include <Elementary.h>
#include <lv2_eo_ui.h>
typedef struct _UI UI;
struct _UI {
eo_ui_t eoui;
LV2UI_Write_Function write_function;
LV2UI_Controller controller;
......@@ -33,161 +37,21 @@ struct _UI {
Evas_Object *entry;
};
// Idle interface
static int
idle_cb(LV2UI_Handle handle)
{
UI *ui = handle;
if(!ui)
return -1;
ecore_main_loop_iterate();
return 0;
}
static const LV2UI_Idle_Interface idle_ext = {
.idle = idle_cb
};
// Show Interface
static int
_show_cb(LV2UI_Handle handle)
{
UI *ui = handle;
if(!ui)
return -1;
if(ui->ee)
ecore_evas_show(ui->ee);
return 0;
}
static int
_hide_cb(LV2UI_Handle handle)
{
UI *ui = handle;
if(!ui)
return -1;
if(ui->ee)
ecore_evas_hide(ui->ee);
return 0;
}
static const LV2UI_Show_Interface show_ext = {
.show = _show_cb,
.hide = _hide_cb
};
// Resize Interface
static int
resize_cb(LV2UI_Feature_Handle handle, int w, int h)
{
UI *ui = handle;
if(!ui)
return -1;
ui->w = w;
ui->h = h;
if(ui->ee)
{
ecore_evas_resize(ui->ee, ui->w, ui->h);
evas_object_resize(ui->parent, ui->w, ui->h);
}
evas_object_resize(ui->vbox, ui->w, ui->h);
evas_object_size_hint_min_set(ui->vbox, ui->w, ui->h);
return 0;
}
static void
_delete(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
UI *ui = data;
elm_box_clear(ui->vbox);
//evas_object_del(ui->entry);
}
void
_lua_markup(void *data, Evas_Object *entry, char **txt)
{
//TODO
}
static LV2UI_Handle
instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
const char *bundle_path, LV2UI_Write_Function write_function,
LV2UI_Controller controller, LV2UI_Widget *widget,
const LV2_Feature *const *features)
static Evas_Object *
_content_get(eo_ui_t *eoui)
{
elm_init(1, (char **)&plugin_uri);
if( strcmp(plugin_uri, LUA_CONTROL_URI)
&& strcmp(plugin_uri, LUA_MIDI_URI)
&& strcmp(plugin_uri, LUA_OSC_URI) )
return NULL;
UI *ui = calloc(1, sizeof(UI));
if(!ui)
return NULL;
ui->w = 400;
ui->h = 400;
ui->write_function = write_function;
ui->controller = controller;
void *parent = NULL;
LV2UI_Resize *resize = NULL;
int i, j;
for(i=0; features[i]; i++)
{
if(!strcmp(features[i]->URI, LV2_UI__parent))
parent = features[i]->data;
else if(!strcmp(features[i]->URI, LV2_UI__resize))
resize = (LV2UI_Resize *)features[i]->data;
}
if(descriptor == &lv2_lua_common_ui)
{
ui->ee = ecore_evas_gl_x11_new(NULL, (Ecore_X_Window)parent, 0, 0, ui->w, ui->h);
if(!ui->ee)
ui->ee = ecore_evas_software_x11_new(NULL, (Ecore_X_Window)parent, 0, 0, ui->w, ui->h);
if(!ui->ee)
printf("could not start evas\n");
ui->e = ecore_evas_get(ui->ee);
ecore_evas_show(ui->ee);
ui->parent = evas_object_rectangle_add(ui->e);
evas_object_color_set(ui->parent, 48, 48, 48, 255);
evas_object_resize(ui->parent, ui->w, ui->h);
evas_object_show(ui->parent);
}
else if(descriptor == &lv2_lua_common_eo)
{
ui->ee = NULL;
ui->parent = (Evas_Object *)parent;
ui->e = evas_object_evas_get((Evas_Object *)parent);
}
if(resize)
resize->ui_resize(resize->handle, ui->w, ui->h);
UI *ui = (void *)eoui - offsetof(UI, eoui);
ui->vbox = elm_box_add(ui->parent);
ui->vbox = elm_box_add(eoui->win);
elm_box_horizontal_set(ui->vbox, EINA_FALSE);
elm_box_homogeneous_set(ui->vbox, EINA_FALSE);
elm_box_padding_set(ui->vbox, 0, 10);
evas_object_event_callback_add(ui->vbox, EVAS_CALLBACK_DEL, _delete, ui);
evas_object_size_hint_weight_set(ui->vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ui->vbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_min_set(ui->vbox, ui->w, ui->h);
......@@ -198,7 +62,8 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->entry = elm_entry_add(ui->vbox);
elm_entry_single_line_set(ui->entry, EINA_FALSE);
elm_entry_scrollable_set(ui->entry, EINA_TRUE);
elm_entry_editable_set(ui->entry, EINA_FALSE);
//elm_entry_editable_set(ui->entry, EINA_FALSE);
elm_entry_editable_set(ui->entry, EINA_TRUE);
elm_entry_markup_filter_append(ui->entry, _lua_markup, NULL);
elm_entry_cnp_mode_set(ui->entry, ELM_CNP_MODE_PLAINTEXT);
elm_object_focus_set(ui->entry, EINA_TRUE);
......@@ -215,11 +80,53 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
"<tab/><keyword>end</keyword><br/>"
"<keyword>end</keyword>"
"</code>");
if(ui->ee) // X11 UI
*(Evas_Object **)widget = NULL;
else // Eo UI
*(Evas_Object **)widget = ui->vbox;
return ui->vbox;
}
static LV2UI_Handle
instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
const char *bundle_path, LV2UI_Write_Function write_function,
LV2UI_Controller controller, LV2UI_Widget *widget,
const LV2_Feature *const *features)
{
if( strcmp(plugin_uri, LUA_CONTROL_URI)
&& strcmp(plugin_uri, LUA_MIDI_URI)
&& strcmp(plugin_uri, LUA_OSC_URI) )
return NULL;
eo_ui_driver_t driver;
if(descriptor == &lv2_lua_common_eo)
driver = EO_UI_DRIVER_EO;
else if(descriptor == &lv2_lua_common_ui)
driver = EO_UI_DRIVER_UI;
else if(descriptor == &lv2_lua_common_x11)
driver = EO_UI_DRIVER_X11;
else if(descriptor == &lv2_lua_common_kx)
driver = EO_UI_DRIVER_KX;
else
return NULL;
UI *ui = calloc(1, sizeof(UI));
if(!ui)
return NULL;
eo_ui_t *eoui = &ui->eoui;
eoui->driver = driver;
eoui->content_get = _content_get;
eoui->w = 400,
eoui->h = 400;
ui->write_function = write_function;
ui->controller = controller;
if(eoui_instantiate(eoui, descriptor, plugin_uri, bundle_path, write_function,
controller, widget, features))
{
free(ui);
return NULL;
}
return ui;
}
......@@ -228,23 +135,9 @@ static void
cleanup(LV2UI_Handle handle)
{
UI *ui = handle;
if(ui)
{
if(ui->ee)
{
ecore_evas_hide(ui->ee);
evas_object_del(ui->vbox);
evas_object_del(ui->parent);
ecore_evas_free(ui->ee);
}
free(ui);
}
elm_shutdown();
eoui_cleanup(&ui->eoui);
free(ui);
}
static void
......@@ -258,29 +151,34 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t buffer_size,
//printf("port_event: %u %u %u\n", i, buffer_size, format);
}
static const void *
extension_data(const char *uri)
{
if(!strcmp(uri, LV2_UI__idleInterface))
return &idle_ext;
else if(!strcmp(uri, LV2_UI__showInterface))
return &show_ext;
return NULL;
}
const LV2UI_Descriptor lv2_lua_common_eo = {
.URI = LUA_COMMON_EO_URI,
.instantiate = instantiate,
.cleanup = cleanup,
.port_event = port_event,
.extension_data = eoui_eo_extension_data
};
const LV2UI_Descriptor lv2_lua_common_ui = {
.URI = LUA_COMMON_UI_URI,
.instantiate = instantiate,
.cleanup = cleanup,
.port_event = port_event,
.extension_data = extension_data
.extension_data = eoui_ui_extension_data
};
const LV2UI_Descriptor lv2_lua_common_eo = {
.URI = LUA_COMMON_EO_URI,
const LV2UI_Descriptor lv2_lua_common_x11 = {
.URI = LUA_COMMON_X11_URI,
.instantiate = instantiate,
.cleanup = cleanup,
.port_event = port_event,
.extension_data = eoui_x11_extension_data
};
const LV2UI_Descriptor lv2_lua_common_kx = {
.URI = LUA_COMMON_KX_URI,
.instantiate = instantiate,
.cleanup = cleanup,
.port_event = port_event,
.extension_data = NULL
.extension_data = eoui_kx_extension_data
};
......@@ -43,9 +43,10 @@
#define LUA_URI "http://open-music-kontrollers.ch/lv2/lua"
#define LUA_COMMON_URI LUA_URI"#common"
#define LUA_COMMON_UI_URI LUA_URI"#common_ui"
#define LUA_COMMON_EO_URI LUA_URI"#common_eo"
#define LUA_COMMON_UI_URI LUA_URI"#common_ui"
#define LUA_COMMON_X11_URI LUA_URI"#common_x11"
#define LUA_COMMON_KX_URI LUA_URI"#common_kx"
#define LUA_CONTROL_URI LUA_URI"#control"
#define LUA_MIDI_URI LUA_URI"#midi"
......@@ -55,8 +56,10 @@ extern const LV2_Descriptor lv2_lua_control;
extern const LV2_Descriptor lv2_lua_midi;
extern const LV2_Descriptor lv2_lua_osc;
extern const LV2UI_Descriptor lv2_lua_common_ui;
extern const LV2UI_Descriptor lv2_lua_common_eo;
extern const LV2UI_Descriptor lv2_lua_common_ui;
extern const LV2UI_Descriptor lv2_lua_common_x11;
extern const LV2UI_Descriptor lv2_lua_common_kx;
typedef struct _Lua_VM Lua_VM;
......
......@@ -23,9 +23,13 @@ lv2ui_descriptor(uint32_t index)
switch(index)
{
case 0:
return &lv2_lua_common_ui;
case 1:
return &lv2_lua_common_eo;
case 1:
return &lv2_lua_common_ui;
case 2:
return &lv2_lua_common_x11;
case 3:
return &lv2_lua_common_kx;
default:
return NULL;
}
......
......@@ -14,38 +14,63 @@
# http://www.perlfoundation.org/artistic_license_2_0.
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
@prefix kx: <http://kxstudio.sf.net/ns/lv2ext/external-ui#> .
@prefix lua: <http://open-music-kontrollers.ch/lv2/lua#> .
# to please sord_validate
ui:EoUI
a rdfs:Class, owl:Class ;
rdfs:subClassOf ui:UI .
kx:Widget
a rdfs:Class, owl:Class ;
rdfs:subClassOf ui:UI .
kx:Host
a lv2:Feature .
lua:control
a lv2:Plugin ;
lv2:binary <lua@LIB_EXT@> ;
ui:ui lua:common_ui ;
ui:ui lua:common_eo ;
ui:ui lua:common_ui ;
ui:ui lua:common_x11 ;
ui:ui lua:common_kx ;
rdfs:seeAlso <lua.ttl> .
lua:midi
a lv2:Plugin ;
lv2:binary <lua@LIB_EXT@> ;
ui:ui lua:common_ui ;
ui:ui lua:common_eo ;
ui:ui lua:common_ui ;
ui:ui lua:common_x11 ;
ui:ui lua:common_kx ;
rdfs:seeAlso <lua.ttl> .
lua:osc
a lv2:Plugin ;
lv2:binary <lua@LIB_EXT@> ;
ui:ui lua:common_ui ;
ui:ui lua:common_eo ;
ui:ui lua:common_ui ;
ui:ui lua:common_x11 ;
ui:ui lua:common_kx ;
rdfs:seeAlso <lua.ttl> .
lua:common_eo
a ui:EoUI ;
ui:binary <lua_ui@LIB_EXT@> ;
rdfs:seeAlso <lua.ttl> .
lua:common_ui
a ui:UI ;
ui:binary <lua_ui@LIB_EXT@> ;
rdfs:seeAlso <lua.ttl> .
lua:common_x11
a ui:X11UI ;
ui:binary <lua_ui@LIB_EXT@> ;
rdfs:seeAlso <lua.ttl> .
lua:common_eo
a ui:EoUI ;
lua:common_kx
a kx:Widget ;
ui:binary <lua_ui@LIB_EXT@> ;
rdfs:seeAlso <lua.ttl> .
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment