jamievicary / globular

Globular
37 stars 9 forks source link

Clicking on the target of an invertible cell should try to apply that cell in reverse #84

Open kim-em opened 7 years ago

kim-em commented 7 years ago

When an invertible cell is displayed in the signature as a pair of images (showing the source and target) we can click on the source to attempt to rewrite using the cell.

We should be able to click on the target to attempt to rewrite using the inverse.

jamievicary commented 7 years ago

Hi Scott, this is exactly how it should currently operate. Can you upload a workspace with a description of how to replicate your issue?

By the way, it does even more than this in general: depending on the context of the click, it can attach not only the cell X or its inverse X', but also their inserters 1-->X.X' and 1-->X'.X, the inserters' inverses and inserters, and so on, conductively.

On 3 Aug 2017 11:49 pm, "Scott Morrison" notifications@github.com wrote:

When an invertible cell is displayed in the signature as a pair of images (showing the source and target) we can click on the source to attempt to rewrite using the cell.

We should be able to click on the target to attempt to rewrite using the inverse.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jamievicary/globular/issues/84, or mute the thread https://github.com/notifications/unsubscribe-auth/AKHHHiXyBG9UIryQVYUB9i0Mx1GSqmcCks5sUk6UgaJpZM4OtFPs .

kim-em commented 7 years ago

See http://globular.science/1708.003. The abstract describes how to reproduce the behaviour.

I'm talking about clicking the target as displayed inside the signature box, in order to list all the ways to apply that invertible cell in reverse, not about clicking on an instance of the target somewhere in the diagram, which, as you say, works fine.

kim-em commented 7 years ago

(btw --- if you agree that this would be a helpful enhancement, I'm happy to try to implement it. I am enthusiastic to tinker with Globular under the hood.)

kim-em commented 7 years ago

Perhaps this issue is even too specific --- I would suggest that if a cell is invertible, clicking on it in the signature should

A) If it is displayed as a single image, attempt to apply it either forwards or backwards. B) If it is displayed as a pair of images, attempt to apply forwards if the user clicked on the source or attempt to apply backwards if the user clicked on the target.

I've been trying to read to code --- I'm pretty sure the relevant code starts at line 773 of Globular-Project.js, but so far I can't voodoo tweak it to behave as I want!

jamievicary commented 7 years ago

That's definitely the right area of the code.

Regarding (A): Line 773 selects both icons, div_icon and div_icon_2, and gives them the same click event. So the first thing you'd want to change is to change this to assign different code to div_icon and div_icon_2. For div_icon, I suppose the code would be the same as currently given. For div_icon_2, I think you'd want to attach the inverse. If generator.id is the name of the generator, then I think generator.id.toggle_inverse() is the name of its inverse. Of course, you'd need to run a check first that the generator is marked as invertible.

jamievicary commented 7 years ago

Regarding (B): I think detecting clicks on different areas of a single small thumbnail will be confusing, because it will be too hard to click precisely enough, and hard for the user to understand what's going on. EDIT: I don't think you were actually suggesting this.

jamievicary commented 7 years ago

Regarding (A) again: I'm now not sure that this mechanic makes sense. At the moment, when you click on any picture of a generator G, it tries to attach it along all boundaries, both forwards and backwards; that is, composing along t(G), s(G), tt(G), ss(G), etc. So I don't think it's intuitive that clicking the icon of s(G) should list all ways of attaching G, and clicking the icon of t(G) should list all ways of attaching G^{-1}.

kim-em commented 7 years ago

Hmm... There's some confusion here, I'm not sure where.

I think you may have misread my cases (A) and (B).

Regarding (A) --- currently, when you click on the picture of a generator G, as far as I can see while it might be attached along t(G), s(G), tt(G), ss(G), etc, it is never the case that G^{-1} gets attached! This is what I would like to see happen. (I think we have been using 'forwards' and 'backwards' in slightly different senses.)

Regarding (B) --- I wasn't suggesting differentiating between clicks in different areas of a single thumbnail, but rather between the two thumbnails (that display if "Single image" is not selected). Instead I was proposing that clicking on the source image of the thumbnail (i.e. the left of the pair of images) would attempt to attach G (whether along the source or target), and clicking on the target image of the thumbnail would attempt to attach G^{-1}.

I think the suggestion in case (A) is the more important one, and I'd be happy in case (B) even if clicking on either of the two thumbnails attempted to attach either G or G^{-1}.

Does that make sense?

It turns out I'd attempted exactly the change to the javascript that you suggested above in the meantime, but I haven't gotten it to work. When I clicked on div_icon_2, it successfully showed me the "preview" view, indicating it really was looking for ways to attach G^{-1}, but upon selecting one of those ways nothing happened, and I can't quite tell why. I suspect I don't understand what is happening on line 799 and following.

jamievicary commented 7 years ago

Hi, I somehow switched (A) and (B) in my comments. Do they make more sense if you correct for that?

kim-em commented 7 years ago

Yes. I'll agree now with what you said about my (B) (which you'd referred to as (A)) --- it probably doesn't make sense to have different behaviour for clicking on the two different thumbnails.

Nevertheless, I'm pretty sure that clicking on an invertible cell G in the signature never considers the possibility of attaching G^{-1}, and this should be fixed. Perhaps I should just close this one and write a new issue that states this clearly.

jamievicary commented 7 years ago

Let me just say again more clearly what I fluffed up trying to say before.

Context for my comments below: when you say "apply forwards" and "apply backwards", I'm interpreting that as "attach G" and "attach G^{-1}" respectively. If this is not what you mean, let's discuss it more.

For case (A): I agree that if you click the single image representing an invertible generator G, it should attempt to attach both G and G^{-1} in all possible ways.

For case (B): I think you're suggesting that clicking on the source or target of G should trigger the attachment of G or G^{-1}, respectively. I think this is misleading, because there is no obvious correspondence between what you're clicking, and what it's doing.

kim-em commented 7 years ago

Comments crossed --- I think we agree!

jamievicary commented 7 years ago

Yes, I definitely agree for your case (A).

For now, let's just make it so that for an invertible generator, clicking any cell image --- either a single image, or the source or target when there are two images --- attempts to attach both the generator and its inverse, in all possible ways.