Replies: 1 comment 1 reply
-
How about using a proc ::pd::widget::select {obj state} {
set fun [get_widget_proc select $obj]
if { $fun eq {} } {set fun fallback_select }
foreach cnv [::pd::widget::get_canvases $obj] {
::pd::widget::set_current_canvas $obj $cnv
$fun $obj $state
}
}
proc myobject_select {obj state} {
set cnv [::pd::widget::get_current_canvas $obj]
# show selection of $obj on this $cnv
} So the widget implementation doesn't depend on the fact we finally allow drawing on multiple canvases or not, and the widget interfaces don't need the canvas argument. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
when implementing #1765, i became fond of the idea, that "widgets" (the GUI-representation of an object), should be aware of the canvas they live on.
this allows for a basic workflow like:
in practice this looks like this:
i kind of like this, as it doesn't require us to send the canvas along with any command to the object.
there's also the vague idea that an object might appear on more than one canvases (think a numberbox that is displayed as GOP; opening the GOP-subpatch currently blanks the GOP-display on the parent; it would be nice if this was not the case.
what's wrong with this?
after working a bit with this, i'm not entirely sure anymore whether this is really worth it.
alternatives?
we could of course just pass the cnv along when calling a widget's procs from Pd-core:
urgh.
a somewhat nicer way is to still store the object->canvas association on the GUI, but handle this in the wrapper function (that forwards a generic call like
::pd::widget::select $obj 1
to the actual widget implementationmyobject_select
.right now it goes like this:
this could be modified to
(nevermind that this currently iterates over possibly multiple canvases)
this has the advantage that the Core->GUI communication need not carry the canvas along (and is thus more readable).
the drawback is, that there's some asymmetry between the Core->GUI call (
somefun $obj $arg
) and the actual implementation on the GUI (somerealfun $obj $cnv $arg
)thoughts?
Beta Was this translation helpful? Give feedback.
All reactions