Skip to content

Commit 83d8eb4

Browse files
authored
parse else/popmenu (#392)
* parse else/popmenu * tweak docs
1 parent 7023f8f commit 83d8eb4

7 files changed

Lines changed: 59 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Features:
1010
* Support `[route float]` for routing floats.
1111
* Support `trunc()` in `expr/expr~`.
1212
* Support `threshold~`.
13-
13+
* Allow `else/popmenu` (converted to `[f ]`).
1414

1515
0.16.2
1616
-----

docs/getting-started/patching.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The following objects are supported:
6060
- Bang (bng)
6161
- Toggle (tgl)
6262
- Knob (knob, else/knob)
63+
- Popmenu (popmenu, else/popmenu)
6364
- Float atom (floatatom)
6465

6566
An intermediate result GUI json is created containing these objects with their location, size and style. More information about [the IR](../reference/ir/heavy_gui_ir.md).

docs/reference/objects/supported.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Here is a list of [unsupported Pd objects](unsupported.md).
4949
| div | |
5050
| exp | |
5151
| expr | except some functions. <sup>3</sup> Does not support symbol input. |
52-
| else/knob | converted to `[f ]` <sup>2</sup> |
5352
| f | |
5453
| float | |
5554
| floatatom | converted to `[f ]` <sup>2</sup> |
@@ -238,8 +237,12 @@ Objects ported from other PD externals
238237

239238
| object | limitations |
240239
| --- | --- |
240+
| else/knob | converted to `[f ]` <sup>1</sup> |
241+
| else/popmenu | converted to `[f ]` <sup>1</sup> |
241242
| pdnam~ | only supports WaveNet models Nano, Feather, Lite, and Standard |
242243

244+
1. Supports setting send/receive configuration, see [Getting Started](../../getting-started/patching.md#gui-objects)
245+
243246
## Supported Abstractions
244247

245248
These are commonly used - or built in - abstractions that consist of compatible vanilla objects.

hvcc/interpreters/pd2gui/PdGUIParser.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from hvcc.types.GUI import (
1414
Size, Coords, Font, LabelShow, LabelPos, Label, Color, Canvas,
1515
Bang, Toggle, VRadio, HRadio, VSlider, HSlider, Knob, Number, Float,
16-
Comment, GUIObjects, Graph, GraphRoot
16+
Comment, Popmenu, GUIObjects, Graph, GraphRoot
1717
)
1818

1919

@@ -181,6 +181,8 @@ def gui_from_canvas(
181181
x = self.add_knob(line)
182182
elif obj_type == "nbx":
183183
x = self.add_number(line)
184+
elif obj_type == "popmenu" or obj_type == "else/popmenu":
185+
x = self.add_popmenu(line)
184186

185187
if x is not None:
186188
objects.append(x)
@@ -655,3 +657,26 @@ def add_float(cls, line: list[str]) -> Optional[Float]:
655657
min=float(line[5]),
656658
max=float(line[6])
657659
)
660+
661+
@classmethod
662+
def add_popmenu(cls, line: list[str]) -> Optional[Popmenu]:
663+
param = cls.filter_params(line[11])
664+
if param is None:
665+
return None
666+
667+
return Popmenu(
668+
position=Coords(
669+
x=int(line[2]),
670+
y=int(line[3])
671+
),
672+
size=Size(
673+
x=int(line[5]),
674+
y=int(line[6])
675+
),
676+
parameter=param,
677+
font_height=int(line[7]),
678+
no_select=line[10],
679+
fg_color=Color(line[9]),
680+
bg_color=Color(line[8]),
681+
options=line[26:],
682+
)

hvcc/interpreters/pd2hv/PdParser.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,17 @@ def finalize_array(array: HeavyObject) -> None:
563563

564564
# add gui send/receive objects
565565
arg_index = {
566-
"nbx": (6, 7),
567-
"vsl": (6, 7),
568-
"hsl": (6, 7),
569-
"vradio": (4, 5),
570-
"hradio": (4, 5),
571-
"bng": (4, 5),
572-
"tgl": (2, 3),
573-
"knob": (5, 6),
574-
"else/knob": (5, 6),
566+
"nbx": (6, 7),
567+
"vsl": (6, 7),
568+
"hsl": (6, 7),
569+
"vradio": (4, 5),
570+
"hradio": (4, 5),
571+
"bng": (4, 5),
572+
"tgl": (2, 3),
573+
"knob": (5, 6),
574+
"else/knob": (5, 6),
575+
"popmenu": (7, 6),
576+
"else/popmenu": (7, 6),
575577
}
576578

577579
if obj_type in arg_index.keys():
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#N canvas 0 149 210 157 10;
2+
#X obj 24 35 inlet;
3+
#X obj 24 57 float 0;
4+
#X obj 24 79 outlet;
5+
#X connect 0 0 1 0;
6+
#X connect 1 0 2 0;

hvcc/types/GUI.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,16 @@ class Float(BaseParam):
170170
max: float
171171

172172

173-
GUIObjects = Union[Bang, Toggle, Radio, Slider, Knob, Number, Float, Comment, Canvas]
173+
class Popmenu(BaseParam):
174+
type: Literal["popmenu"] = "popmenu"
175+
font_height: int
176+
no_select: str
177+
fg_color: Color
178+
bg_color: Color
179+
options: list[str]
180+
181+
182+
GUIObjects = Union[Bang, Toggle, Radio, Slider, Knob, Number, Float, Comment, Canvas, Popmenu]
174183

175184

176185
class Theme(BaseModel):

0 commit comments

Comments
 (0)