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

Feature Request: Support for Resizing Nodes in Editor #70

Open
naturally-intelligent opened this issue Jun 28, 2018 · 20 comments
Open

Feature Request: Support for Resizing Nodes in Editor #70

naturally-intelligent opened this issue Jun 28, 2018 · 20 comments

Comments

@naturally-intelligent
Copy link

naturally-intelligent commented Jun 28, 2018

For example in Yarn format, adding another attribute:

position: 75,4
size: 70,50

With a resize hotcorner in the bottom-right on the Node GUI.

Would this be possible?

@blurymind
Copy link
Collaborator

It is technically possible, but it will slightly change the format by adding two new node values- width and height

@addie-lombardo
Copy link
Collaborator

As long as it wouldn't intervene with YarnSpinner I don't see why not.

I do like the idea of having resizing only be possible via one corner 👍

@naturally-intelligent
Copy link
Author

I've tried twice to add this feature myself, but can't figure out the GUI side of it. I tried adding the jQuery Resizable thing but failed. I can change the default size of nodes, which helps. Any tips? What widgets/components should this be using?

@naturally-intelligent
Copy link
Author

Also want to add that this is the only thing that kinda prevents me from embracing Yarn more fully. I yearn to see the full text inside each node. Viewing it as an overview is a lot easier without having to click each node, since my nodes tend to have more text than fits. I just don't understand how existing users can get by seeing a little bit of the text in each node - what are these, nodes for ants?

Also on another note I have built a Godot Yarn importer and will be sharing that code on Github in the future.

@blurymind
Copy link
Collaborator

blurymind commented Sep 7, 2018

@naturally-intelligent if that godot yarn parser works as well as bondage.js , I will make it a priority to add this for you ;)

Right now I am working toward implementing it for gdevelop, because it is possible to actually make the yarn editor a part of gdevelop. Include it as part of gdevelop's Ide - that is of course only if I get it to there and the creator of gdevelop approves the pull heheh :)

@naturally-intelligent
Copy link
Author

Okay, I'll bite! :) Here is the first working version of my Godot Yarn Importer:

https://github.com/naturally-intelligent/godot-yarn-importer

cheers @blurymind

@blurymind
Copy link
Collaborator

@naturally-intelligent All thats left is for someone to implement a usable parser
Here is a link to the tests that your parser must pass:
https://github.com/jhayley/bondage.js/tree/master/tests/yarn_files

My requirement is for a parser :)

@naturally-intelligent
Copy link
Author

Okay, I suppose these are Twine rules? Wait - don't answer that because I think we're getting off topic from the issue. Could you please submit this as an issue here: https://github.com/naturally-intelligent/godot-yarn-importer To continue discussion! thanks

@naturally-intelligent
Copy link
Author

Trying to get this back on topic:

I've tried twice to add this feature myself, but can't figure out the GUI side of it. I tried adding the jQuery Resizable thing but failed. I can change the default size of nodes, which helps. Any tips? What widgets/components should this be using?

@julsam
Copy link
Contributor

julsam commented Sep 25, 2018

So, I've this feature working, but I still have a few bugs to fix before publishing it. And I also have to test it with NWjs (I've been using the electron branch because I'm more familiar with it).

julsam added a commit to julsam/Yarn that referenced this issue Sep 26, 2018
 * Allows node resizing by dragging the bottom right side of a node.
   It forces it's shape to be a square. I've added this limitation
   because it would require too much work on the maths of the connection
   arrows otherwise.
 * Save to file in json, xml and yarn format. Twine doesn't handle
   resizing, so the size is not save in the twee and tw2 format.
 * Loading a file also handle the size if it finds it in json, xml and
   yarn format.
 * Had to change a little the math of the arrows because the size was
   hardcoded.

I've tried opening saved files containing the new 'size' option, and
old versions of Yarn (the one linked in the build section of the readme)
handled it correctly, ignoring the 'size' option and parsing the rest of
the file correctly.
And old saved files without the new 'size' option are also read
correctly, the 'size' option is optional when loading.

Note: the dragging box was already here in the html, but it was commented
out because it was incomplete. The author who added it was planning to
add a 'toggle expand' feature but apparently never did. I reused his
'resize' box and removed the few lines of code related to the
'toggle expand' feature.
@julsam
Copy link
Contributor

julsam commented Sep 26, 2018

@naturally-intelligent Can you give it a try? It's based on the electron branch, because it was easier for me to work on that branch, but porting it to the master branch should be fairly easy and probably won't require a lot of modification.
If you want to try it, but don't want to compile the code yourself with electron, tell me what os you use and I'll make you a build.
Otherwise, wait a few more days so I have time to port it to NWjs.

julsam added a commit to julsam/Yarn that referenced this issue Sep 26, 2018
 * Allows node resizing by dragging the bottom right side of a node.
   It forces it's shape to be a square. I've added this limitation
   because it would require too much work on the maths of the connection
   arrows otherwise.
 * Save to file in json, xml and yarn format. Twine doesn't handle
   resizing, so the size is not save in the twee and tw2 format.
 * Loading a file also handle the size if it finds it in json, xml and
   yarn format.
 * Had to change a little the math of the arrows because the size was
   hardcoded.

I've tried opening saved files containing the new 'size' option, and
old versions of Yarn (the one linked in the build section of the readme)
handled it correctly, ignoring the 'size' option and parsing the rest of
the file correctly.
And old saved files without the new 'size' option are also read
correctly, the 'size' option is optional when loading.

Note: the dragging box was already here in the html, but it was commented
out because it was incomplete. The author who added it was planning to
add a 'toggle expand' feature but apparently never did. I reused his
'resize' box and removed the few lines of code related to the
'toggle expand' feature.
@julsam
Copy link
Contributor

julsam commented Sep 26, 2018

Published the nwjs version (master branch). Let me know if it works for you. I'll make a pull request later.

@julsam
Copy link
Contributor

julsam commented Sep 26, 2018

Also, I should have mentioned it earlier, but the content is still clipped: there's a limitation of 1024 characters in the node.
Depending on the size of your project, you might want to try to put a bigger number.
At the start of node.js, you can change this line:

const ClipNodeTextLength = 1024;

I have no idea how well or bad it will perform.

It would be great if yarn had any config option to customize the editor, but it's sadly not the case.

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Sep 27, 2018

It works! :) I tried it just now. Couldn't try it earlier (was at work). BTW I'm on Linux with nwjs. I upped the ClipNodeTextLength with no speed issues even on my ageing machine. It even saves and loads from a yarn.txt file.

One issue: the resize operation locks the axii to make squares. Can they be unlocked to make rectangles? When I edited the yarn file directly and loaded it with a rectangular shape, they displayed as a rectangle, but once I resized the node it went back to square lock. Also, if possible, the look of the resize button should be a little triangle (like on these github text editor boxes)

@naturally-intelligent
Copy link
Author

Just changing these lines in node.js:

const size = Math.max(width, height);
// resize
self.width(size);
self.height(size);

To this:

// resize
self.width(width);
self.height(height);

Works fine for me!

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Sep 27, 2018

Actually there is a problem with rectangular shapes. The arrow draw logic seems based on expecting a square shape:

wonky-arrows

This could be a can of worms... :|

@julsam
Copy link
Contributor

julsam commented Sep 27, 2018

Yeah, that's why i forced it to be a square.
I'm not sure how it could be fixed, I've tried to work on it yesterday but the math part is honestly a little too complicated for me and would require a complete rework of the arrows drawing logic 🤔

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Sep 27, 2018

In app.js there is an "updateArrows" function around line 797, and a comment on 838 noting that they are taking advantage of the square nodes to draw the lines:

// Get the size of the 2 nodes. It's a square, so width and height are the same.

Accounting for a rectangular shape isn't a trivial change. However, being a game developer and dealing with geometry problems for much of my life it shouldn't be impossible for me. I've probably already done this puzzle at some point. A brief search brings up algorithms like:

https://gamedev.stackexchange.com/questions/111100/intersection-of-a-line-and-a-rectangle

So, I'll be trying to add this change. Is it part of the original scope? I kinda think so, because specifying height and width were never meant to be always equal. Otherwise just have one value. But if it becomes too much of a headache we can abandon the rectangle and stay with squares.

Are there any other issues beyond the arrows that might cause a problem from the rectangle shape?

@julsam
Copy link
Contributor

julsam commented Sep 27, 2018

I'm actually the one that added this comment in my commit ^^ had to do a few changes in the 'updateArrows' function because the size was hardcoded.

I can't think of any issue the rectangular shape would cause. Good luck with it 👍

@blurymind
Copy link
Collaborator

@julsam can you submit this as a pull to the electron branch please :)
I can have a look to see if we can sort out the connection arrows positioning issue.

julsam added a commit to julsam/Yarn that referenced this issue Jan 23, 2019
 * Allows node resizing by dragging the bottom right corner of a node.
   It forces it's shape to be a square. I've added this limitation
   because it would require too much work on the maths of the connection
   arrows otherwise.
 * Save to file in json, xml and yarn format. Twine doesn't handle
   resizing, so the size is not saved in the twee and tw2 format.
 * Loading a file also handle the size if it finds it in json, xml and
   yarn format.
 * Had to change a little the math of the arrows because the size was
   hardcoded.

I've tried opening saved files containing the new 'size' option, and
old versions of Yarn (the one linked in the build section of the readme)
handled it correctly, ignoring the 'size' option and parsing the rest of
the file correctly.
And old saved files without the new 'size' option are also read
correctly, the 'size' option is optional when loading.

Note: the dragging box was already here in the html, but it was commented
out because it was incomplete. The author who added it was planning to
add a 'toggle expand' feature but apparently never did. I reused his
'resize' box and removed the few lines of code related to the
'toggle expand' feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants