Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make .plotTree a single instance window and add ServerTreeView #6294

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

prko
Copy link
Contributor

@prko prko commented May 5, 2024

Purpose and Motivation

Currently s.plotTree creates new windows whenever the shortcut is pressed or s.plotTree is evaluated. This behaviour is strange because the following server-related windows are singleton windows

  • s.meter
  • s.freqscope
  • s.scope.

With this PR, s.plotTree makes 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

  • Bug fix or
  • New feature

To-do list

  • Code is tested
  • All tests are passing
  • Updated documentation
  • This PR is ready for review

@telephon
Copy link
Member

telephon commented May 5, 2024

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 –> ServerMeter
s.freqscope -> FreqScope
s.scope –> Stethoscope

But we have no ServerTreeView. This would be good.
Otherwise, we have no way to have multiple plotTree for one server if we need it.

Copy link
Member

@telephon telephon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a possibility to have several views if needed.

@prko
Copy link
Contributor Author

prko commented May 5, 2024

@telephon
Thank you for your comments. This is a good idea!
I have added the feature you mentioned and the corresponding help documentation.
Will this be enough? Please let me know if I should revise the added methods and documentation or add more methods.

I think what you want is the behaviour of making a new window like ServerMeter and Stethoscope. See the Comment below.

ServerTreeView.new(s)
ServerTreeView(s)
ServerTreeView(s, Rect(300, 600, 300, 600)) // // arguments: server, bounds
ServerTreeView(s, Rect(300, 600, 300, 600), 1) // arguments: server, bounds, interval

Comment

  • ServerMeter and Stethoscope make always a new window:
    ServerMeter.new(s, 4, 2)
    // Evaluating this code twice will display two separate ServerMeter windows.
    
    Stethoscope.new 
    // Evaluating this code twice will display two separate Stethoscope windows.
    
  • FreqScope makes only one window:
    FreqScope.new(400, 200, 0, server: s)
    // Evaluating this code twice will display only one FreqScope window.
    

@prko prko changed the title make `.plotTree' a single instance window make .plotTree a single instance window and add ServerTreeView May 5, 2024
change the display text for the link::Search#asRect::
prko added 2 commits May 7, 2024 00:41
- help file
- remove closeAll
- close method fix
- fix the wrong return.
- 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
@JordanHendersonMusic JordanHendersonMusic added the comp: class library SC class library label May 7, 2024
prko added 2 commits May 9, 2024 01:02
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.
@prko prko requested a review from telephon May 16, 2024 01:43
Copy link
Member

@telephon telephon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks already quite good, thank you! There are still some little things to do, but it is getting there...

@telephon
Copy link
Member

telephon commented May 17, 2024

One more idea, to make multiple views even more useful: instead of passing the argument server, you could call it target. Then, the view could monitor any group in the node tree.

Within the code, you can then call asTarget to get the group, and asTarget.server to get the server.

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.
Copy link
Member

@telephon telephon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@prko
Copy link
Contributor Author

prko commented May 20, 2024

@telephon
Could you see my comments to the following two comments of yours?


One more idea, to make multiple views even more useful: instead of passing the argument server, you could call it target. Then, the view could monitor any group in the node tree.

Within the code, you can then call asTarget to get the group, and asTarget.server to get the server.


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));

It is also a great idea. But what do you mean by this?

  • Create a new class ServerNodeTree? (I think this may be what you want)
  • Implement this idea in this PR?

};
viewParent = window;
window.view.hasHorizontalScroller_(false).background_(Color.grey(0.9));
if(window.view.respondsTo(\hasHorizontalScroller_)) { window.view.hasHorizontalScroller_(false) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about it – perhaps we don't need the test. Doesn't the view of a window always respond to hasHorizontalScroller_ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@telephon telephon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.stop never works! Line 162 should be updater = 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.

prko added 2 commits May 20, 2024 20:22
- 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`
@prko
Copy link
Contributor Author

prko commented May 20, 2024

Thank you for your review!

move the whole class definition to a separate file. "ServerPlusGui" implies that these are extensions only

Please let me know the name of the new file and where it is located. What I think is ServerTreeView.sc in the same folder as ServerPlusGui.sc. Is my thinking correct?

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?

Do you mean the parent argument in ServerTreeView.new and ServerTreeView.makeWindow? They come from .plotTreeView:

plotTreeView {|interval=0.5, parent, actionIfFail|

Following your recommendation, I have moved some parts of .plotTreeView to ServerTreeView.new and ServerTreeView.makeWindow, and the parent argument has also been copied. Can you explain the brittleness of the parent handling? I will make it more robust.

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.stop never works! Line 162 should be updater = fork { ... without the extra function brackets.

Um... anyway, `.stop' has worked (and sorry for not taking a closer look at the part nor writing it by myself!):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: class library SC class library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants