Skip to content

Commit 46bbcea

Browse files
committed
Fix plugdata compilation
1 parent 7271374 commit 46bbcea

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

pdlua.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static void pdlua_select(t_gobj *z, t_glist *glist, int state)
10701070
text_widgetbehavior.w_selectfn(z, glist, state);
10711071
}
10721072
}
1073-
#else
1073+
#elif !defined(PLUGDATA)
10741074
static void pdlua_select(t_gobj *z, t_glist *glist, int state)
10751075
{
10761076
t_pdlua *x = (t_pdlua *)z;
@@ -1591,7 +1591,9 @@ static int pdlua_class_new(lua_State *L)
15911591
// text_widgetbehavior won't give the right object tag with a freshly
15921592
// created gop for some reason.
15931593
// For pure-data, we need to trigger a repaint when an object gets selected to update the border colour
1594+
#ifndef PLUGDATA
15941595
pdlua_widgetbehavior.w_selectfn = pdlua_select;
1596+
#endif
15951597
pdlua_widgetbehavior.w_deletefn = pdlua_delete;
15961598
pdlua_widgetbehavior.w_clickfn = pdlua_click;
15971599
pdlua_widgetbehavior.w_visfn = pdlua_vis;

pdlua/examples/props.pd_lua

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function properties:initialize(sel, atoms)
88

99
self.checkbox1 = 1
1010
self.checkbox2 = 0
11-
self.color = {155,155,155}
11+
self.bgcolor = {155,155,155}
12+
self.fgcolor = {100,100,100}
1213

1314
self.textinput1 = "Hello"
1415
self.textinput2 = "World"
@@ -27,28 +28,41 @@ function properties:properties(p)
2728
p:add_check("Check Box 2", "updatecheckbox2", self.checkbox2)
2829

2930
-- Text inputs
30-
p:new_frame("First textinput", 2)
31+
p:new_frame("First textinput", 3)
3132
p:add_text("Check text 1", "updatetext1", self.textinput1)
3233
p:add_text("Check text 2", "updatetext2", self.textinput2)
34+
p:add_text("Check", "updatetext2", self.textinput2)
3335

3436
-- Color picker
35-
p:new_frame("My Color Picker", 1)
36-
p:add_color("Background", "updatecolorbg", self.color)
37+
p:new_frame("My Color Picker", 3)
38+
p:add_color("Background", "updatecolorbg", self.bgcolor)
39+
p:add_color("Foreground", "updatecolorfg", self.fgcolor)
40+
p:add_color("Text", "updatecolorfg", {50, 50, 50})
3741

3842
-- Number boxes
39-
p:new_frame("Numbers", 2)
43+
p:new_frame("Numbers", 3)
4044
p:add_float("Float", "updatefloat", self.float, 0, 1)
4145
p:add_int("Int", "updateint", self.int, 1, 16)
46+
p:add_int("Int", "updateint", self.int, 1, 16)
4247

4348
-- Combobox
44-
p:new_frame("Combo", 1)
49+
p:new_frame("Combo", 3)
4550
p:add_combo("Waveform", "updatecombo", self.combo, { "Sine", "Square", "Saw", "Triangle" })
51+
p:add_combo("Letter", "updateletter", 1, { "A", "B", "C", "D" })
52+
p:add_color("Foreground", "updatecolorfg", self.fgcolor)
4653
end
4754

4855
function properties:updatecolorbg(args)
49-
self.color[1] = args[1]
50-
self.color[2] = args[2]
51-
self.color[3] = args[3]
56+
self.bgcolor[1] = args[1]
57+
self.bgcolor[2] = args[2]
58+
self.bgcolor[3] = args[3]
59+
self:repaint(1)
60+
end
61+
62+
function properties:updatecolorfg(args)
63+
self.fgcolor[1] = args[1]
64+
self.fgcolor[2] = args[2]
65+
self.fgcolor[3] = args[3]
5266
self:repaint(1)
5367
end
5468

@@ -87,7 +101,14 @@ function properties:updatecombo(combosel)
87101
pd.post("combo is now " .. self.combo);
88102
end
89103

104+
function properties:updateletter(letter)
105+
pd.post("letter is now " .. letter);
106+
end
107+
90108
function properties:paint(g)
91-
g:set_color(table.unpack(self.color))
109+
g:set_color(table.unpack(self.bgcolor))
92110
g:fill_all()
111+
112+
g:set_color(table.unpack(self.fgcolor))
113+
g:fill_rect(20, 20, 100, 100)
93114
end

0 commit comments

Comments
 (0)