add 'bounds' arg to .plotTree; make .plotTree a single instance window; add ServerTreeView class#6294
Conversation
|
Thank you! The important thing in all the changes was that we still have an option to have several of them if needed (e.g. for multi-screen setups). s.meter –> But we have no |
telephon
left a comment
There was a problem hiding this comment.
We should have a possibility to have several views if needed.
|
@telephon I think what you want is the behaviour of making a new window like Comment
|
.plotTree a single instance window and add ServerTreeView
change the display text for the link::Search#asRect::
- revise the new method for the ServerTreeView class - add plotTreeView method for the ServerTreeView class - revise (simplify) the plotTree method for the Server class - revise (simplify)the plotTreeView method for the Server class
Add ServerTreeView feature with full backwards compatibility - ServerTreeView - .plotTree - .plotTreeView
If there is already a s.plotTree, the following code preserves the precious position. 1. `s.plotTree` // evaluate this. 2. change the position of 1. 3. `s.plotTree` // evaluating this will only show the window, the position and size will not be changed.
telephon
left a comment
There was a problem hiding this comment.
looks already quite good, thank you! There are still some little things to do, but it is getting there...
|
One more idea, to make multiple views even more useful: instead of passing the argument Within the code, you can then call E.g. g = Group.new(s);
g.asTarget // the group itself
g.asTarget.server // the server
// server asTarget returns the default group
s.asTarget
// maybe, for passing a server, we want to get the parent
group = if(target.isKindOf(Server)) { s.defaultGroup.parent } { target.asTarget };
// then you could also write
ServerNodeTree.new; // monitors the default server and the full tree
ServerNodeTree.new(42); // monitors group 42
Ndef(\x, { SinOsc.ar(Rand(200, 800)) * 0.1 });
Ndef(\x).fadeTime = 3;
Tdef(\x, { loop { 1.wait; Ndef(\x).send } }).play;
ServerNodeTree.new(Ndef(\x));
etc.
|
- updated according to review request - new: if no server argument is given, the default server is used.
telephon
left a comment
There was a problem hiding this comment.
thank you very much, it is already very good! I made a few more comments.
- updated according to the review - corrected background colour for start-stop
|
@telephon
It is also a great idea. But what do you mean by this?
|
telephon
left a comment
There was a problem hiding this comment.
Re-reading the code, I found that there are a few things to do, I hope this is fine for you.
- move the whole class definition to a separate file. "ServerPlusGui" implies that these are extensions only
- for now, maybe let's drop the feature of passing a parent? This can be added later. Let's just make a new window always and just pass the bounds. The current way of handling the parent is brittle. Or do you see a reason that we need that right now?
- the updater thing is still not correct, this may have been wrong already in the code you copied from the server, I am not sure. The updater is supposed to be a Routine, resulting from the fork, but currently it is just a function. So
updateFunc.stopnever works! Line 162 should beupdater = fork { ...without the extra function brackets. Then, still the stopping on cmdPeriod needs to be fixed. If you need support on that I'll help, but this is getting long so I'll stop here.
- Update after review - Correct loop behaviour to avoid errors after - closing s.plotTree and a window containing `ServerTreeView`, and - starting server and quitting server
- correct `updateFunc` and `updater`
|
Thank you for your review!
Please let me know the name of the new file and where it is located. What I think is
Do you mean the parent argument in Following your recommendation, I have moved some parts of
Um... anyway, `.stop' has worked (and sorry for not taking a closer look at the part nor writing it by myself!):
|
|
Sorry for not coming back to this, I was busy with outher things. Will continue later, if this is ok. |
restore whitespaces
I have split |
|
I have moved adding bound argument to |
.plotTree a single instance window and add ServerTreeView.plotTree; make .plotTree a single instance window; add ServerTreeView class
There was a problem hiding this comment.
Just a little change. The original code (not yours!) was a bit convoluted already, so in the future maybe we can improve that. For now, fine.
The size correction stuff should perhaps be done once and correctly, so we don't have to rethink it each time. You could remove it here and add it later.
|
This is the current status of this PR: |
(from: #6294 (comment)) I have removed that {
bounds = bounds ? this.plotTreeWindow.bounds;
bounds = bounds.minSize(395@386); // `395@386` was Size(395, 386) in the previous commit.
plotTreeWindow.bounds_(bounds).front;
};However, the
Given this (demo video), I am considering the best course of action:
I would appreciate your insight on this matter. |
|
Now, |
|
sorry, it's been a while. I think this would be the right way to do it: plotTree { |interval=0.5, bounds|
if(plotTreeWindow.isNil) {
bounds = bounds ?? { Rect(128, 64, 400, 400) };
bounds = bounds.minSize(395@386);
plotTreeWindow = Window(name.asString ++ " Node Tree", bounds, scroll:true);
plotTreeWindow.onClose = { plotTreeWindow = nil };
this.plotTreeView(interval, plotTreeWindow, { defer { plotTreeWindow.close } });
} {
if(bounds.notNil) {
bounds = bounds.minSize(395@386);
plotTreeWindow.bounds_(bounds)
};
};
plotTreeWindow.front;
}What do you think? |
|
Yes, it is good, Thanks! |
|
The new structure is good. Trying this, @prko I found that we have lost a few things in this new system which should be added in.
The node ids for groups are not visible anymore, and also the nesting structure. Would you like to help by adding it back in? |
|
Thank you for bringing this to my attention, and I sincerely apologise for any inconvenience I caused. I believe I have identified the issue and resolved it in #6834. I have also attached a demonstration video for your reference. Please do let me know if there is anything else that requires further refinement or updates. |
…6294, * fix "Rect collision issue with too many nodes" (#6834) * make `.plotTree' a single instance window * add new class ServerTreeView and SCDoc * Update ServerPlusGUI.sc - revise the new method for the ServerTreeView class - add plotTreeView method for the ServerTreeView class - revise (simplify) the plotTree method for the Server class - revise (simplify)the plotTreeView method for the Server class * Update ServerPlusGUI.sc Add ServerTreeView feature with full backwards compatibility - ServerTreeView - .plotTree - .plotTreeView * s.plotTree behaviour change If there is already a s.plotTree, the following code preserves the precious position. 1. `s.plotTree` // evaluate this. 2. change the position of 1. 3. `s.plotTree` // evaluating this will only show the window, the position and size will not be changed. * Update ServerPlusGUI.sc - updated according to review request - new: if no server argument is given, the default server is used. * Update ServerPlusGUI.sc - updated according to the review - corrected background colour for start-stop * Update ServerPlusGUI.sc - Update after review - Correct loop behaviour to avoid errors after - closing s.plotTree and a window containing `ServerTreeView`, and - starting server and quitting server * Update ServerPlusGUI.sc - correct `updateFunc` and `updater` * reflect reviews and fixes bugs 1. Changes the way the rectangle is drawn to prevent collisions when there are many nodes. I initially tried to solve this problem by using a factor, but this approach was not very successful. I left this as a comment. The new implementation is not perfect, but it is an improvement on both the previous commit method and the abandoned approach. 2. It restricts multiple executions of the updater in a ServerTreeView. Starting again from the same ServerTreeView instance will be ignored and a warning will be displayed. 3. It adds a warning when multiple .plotTree calls are made. 4. Additional text is added to the current warning when the .plotTree function closes due to the server not running. TO DO: Allow the user to create multiple instances of ServerTreeView, including .plotTree. However, there is currently only one updater and one OSCFunc. Therefore, each instance cannot have its own interval, and stopping an instance does not update the label correctly. In fact, updating the node tree may occur when at least one ServerTreeView instance is running. This issue is documented in the example section of the ServerTreeView.schelp file. To resolve this issue, we need to discuss the various possible solutions. * ServerTreeView: rework updating logic; cleanup --------- Co-authored-by: Marcin Pączkowski <[email protected]>


Purpose and Motivation
Currently
s.plotTreecreates new windows whenever the shortcut is pressed ors.plotTreeis evaluated. This behaviour is strange because the following server-related windows are singleton windowss.meters.freqscopes.scope.With this PR,
s.plotTreemakes only one singleton window.I thought this was a bug, but someone may see it as a new feature.
Merge Note
When this PR is approved or merged, #6282 should be checked to see if it has already been approved or merged.
Types of changes
To-do list