Drag Image Within Frame

Blitz3D Forums/Blitz3D Programming/Drag Image Within Frame

_PJ_(Posted 2014) [#1]
The simple idea of dragging an image within a frame where only part of the image may be visible is actually a lot more complex than it seems.

I have something that 'sort of' works, but it's not at all ideal. I t would be best if the handle was only updated when the image was first clicked, and the drawing used imageblockrect or whatever to figure out the exact portion of what's drawn - also, I've confused myself about how the 'handle' is being re-calculated anyway, so it's not scrolling in the correct direction.

Finally, this should also allow for the partial image to be drawn with just the top left corner in the bottom-right of the frame - or the bottom right of image shown in top-left of frame if scrolled to these extremes etc.

I hope this makes sense, and if anyone can help with what I have I'd really appreciate it!

A cut-down version containing just the necessary code is here:

[Edited due to some invalid functions. An image "Test.jpg" is required]




RemiD(Posted 2014) [#2]

The simple idea of dragging an image within a frame where only part of the image may be visible is actually a lot more complex than it seems.


It depends on your approach...

For my GUI i have "windows" and "GUI elements"
Each window is a parent of GUI elements
Each GUI element (button, switch, messagearea, inputtextarea, imagearea, menutitle, menuwindow, etc...) is a child of a window

Each window uses a separate image
Each GUI element uses a separate image

When a GUI element is modified, the image of the window is rebuilt. So a GUI element could be drawn at any position, it will be displayed only if it is within the window. Do you get the idea ?


Kryzon(Posted 2014) [#3]
When I find myself in the same situation as you, I delete my code and rewrite it from scratch.
Most of the time you rewrite something simpler and more functional.




_PJ_(Posted 2014) [#4]
Kryzon, that's excellent!

I agree with the prionciple of starting over and trying to simplify what I want to focus on the core asects, but I'd done that a few times already and seemed to have just confused myself a bit.

It's great that you've gotten the logic and the display nicely separate, very basic clear instructions and the dragging works perfectly.

Thanks so much for your help :)