shoes / shoes3

a tiny graphical app kit for ruby
http://walkabout.mvmanila.com
Other
181 stars 19 forks source link

attach => Shoes::Mouse not documented #114

Open passenger94 opened 9 years ago

passenger94 commented 9 years ago

don't know what was/is the purpose of it ... kinda works but ...

dredknight commented 7 years ago

Check this out. Try it out with the stack and then try the image. Stack behaves a bit better but eventually both suck big time. Why is this happening ? The drawing tool misbehaves big time?

Shoes.app(width: 1000, height: 1000, resizable: false ) do

    @q = stack left: 50, top: 50, width: 100, height: 100 do
        border black
    end
    #@q = image "#{DIR}/static/shoes-icon.png", left: 200, top: 200, width: 50
    button "Put some shoes ON" do
        @q.attach = Shoes::Mouse
    end
end
IanTrudel commented 7 years ago

Something seems wrong. There are times where it seems to detach from the mouse, then moving over the button again and it magically reattach. A little update on your sample to have the cursor centered to the rect.

Shoes.app(width: 1000, height: 1000, resizable: false ) do
   @q = stack left: 50, top: 50, width: 100, height: 100 do
      border black
   end
   #@q = image "#{DIR}/static/shoes-icon.png", left: 200, top: 200, width: 50
   button "Put some shoes ON" do
      @q.left = -@q.width / 2
      @q.top = -@q.height / 2
      @q.attach = Shoes::Mouse
   end
end
dredknight commented 7 years ago

Thanks! I played a bit more with it and got some more info. Test 1 - the attach button (with the method) and the element being attached are in the same layer.

Shoes.app(width: 1000, height: 1000, resizable: false ) do
    flow left: 200, top: 200, width: 500, height: 500 do
    border green, stroke: 5
    @q = stack(left: 50, top: 50, width: 100, height: 100) { border black }
        button "Put some shoes ON", left: 50, top: 50  do
         @q.left = -@q.width / 2
         @q.top = -@q.height / 2
         @q.attach = Shoes::Mouse
    end
   end
end

Test 2 - the attach button (with the method) and the element being attached are in different layers.

Shoes.app(width: 1000, height: 1000, resizable: false ) do
    flow left: 200, top: 200, width: 500, height: 500 do
    border green
    @q = stack(left: 50, top: 50, width: 100, height: 100) { border black }
    end
   button "Put some shoes ON", left: 50, top: 50  do
      @q.left = -@q.width / 2
      @q.top = -@q.height / 2
      @q.attach = Shoes::Mouse
   end
end

Observe how the the attachment breaks at TEST 1 when the mouse leaves the layer (green border). In TEST2 the mouse is outside the layer when attach method is initiated so nothing happens. I believe the way Shoes handle layers is the issue but someone who has access to the C++ underworks can see if it is bug or architecture disadvantage.

IanTrudel commented 7 years ago

You stumbled onto something that not many had adventure. HacketyHack doesn't even use it. Perhaps older version had implemented it better but it did not age well.

Shoes is written in C, not C++. shoes_place_decide is where the action is. The geometry is rather complicated and unlikely to be correct in the case of REL_CURSOR.

The good news is that your examples are helpful. You should try to attach a button directly to the mouse. This feature is clearly broken.

dredknight commented 7 years ago

Ah ok. So do we depricate this one as it is impossible to fix? What you do in #314 is way better for attaching objects to mouse.

IanTrudel commented 7 years ago

Not impossible to fix but it needs some work. This issue should remain open for now. And you could move on something else in the meantime.

What you do in #314 is way better for attaching objects to mouse.

It works really well. Perhaps a basic sample code based on this would be good. Perhaps your wheel with image as a sample (simplified), say displaying clickable static/shoes-icon*.png, if you are interested. Or sample code for Chipmunk. We can pursue this conversation in #317 .

dredknight commented 7 years ago

Will do. Though I will be away till the end of the week.

IanTrudel commented 7 years ago

Have a safe trip @dredknight. Enjoy life!