Three things I want to code.

Hey guys.

I’m still finding it tedious navigating around large map areas; So I was thinking of adding a few optional control methods. Now I understand these changes won’t be to everyone’s taste, so there’s no need to word me up on that; They will all be optional. But any help on how to implement these would be appreciated:

  1. Edge of screen scrolling: Move the mouse close to the edge and the map scrolls slowly. Move it to the edge and it scrolls quickly. It needs to be smooth so your eyes can follow the board. The mouse scroll is useful, but it jumps around too much to keep your eyes focused on a stack. I think this would be the most useful feature. The other two I can do without. I’ve got a feeling this would require some sort of frame buffering so the re-draw appears smooth?

  2. Mouse wheel zoom: I’m hitting zoom buttons continually when doing logfiles. Mouse zoom would be particularly useful with this next one:

  3. Zoom to selection.

Ben

Thus spake “bsmith”:

I thought we already had edge scrolling. Didn’t we have a lengthy discussion
about how the scrolling should work a few months ago, or am I misremembering?

The last time we talked about using JOGL, we also talked about changing to
dragging to pan the map and putting zoom on the scroll whell. If you’re
willing to do both, then that’s great—it’s code that we need anyway. (I
think we should hide the scroll bars in the JScrollPane, then, too.)

I don’t know what you mean by this one. Please describe further.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I think I follow the requests here and would love to see them added. Although, I did notice that you have the scrolling map with the mouse, for me I’ve only noticed it when you have a piece selected and dragging it though.

Correct me if I’m wrong but I believe with the “Zoom to Selection” he means that if your board is zoomed out however far and you need to look at a specific piece, when you select said piece (token for example) and use the mouse wheel, the screen will zoom and center on the token. :slight_smile:

Hey Joel,

Yes. The code is in there, the map does scroll when dragging a piece to the edge. It’s not working when I run from Eclipse, but that’s another story. (any ideas?)
The edge scrolling does need tweaking; The scroll step-size should increase markedly as you move closer to the edge. It should still scroll when you move the mouse 50 or so pixels outside the Vassal window.

Yeah I found JScrollPane, I guess it’s just a matter of replacing the mouse-wheel listeners.

I’m still deciding on the usefulness of this; But essentially you’re dragging a box and having the screen fill to that selection. So I zoom out to maximum, then drag a box around the area I want to zoom to, and it fills the screen. But yeah, it may not be of much use. The more I think about it, the more useless it is becoming. haha

Ben

Post generated using Mail2Forum (mail2forum.com)

One thing we talked about ages ago was being able to center on an area of map regardless of the border. So if you wanted to center on the top-left hexagon, the map would center there and pad blank space outside the map area. This would be really cool. You could zoom out, right-click a spot, then zoom back in knowing that point would be the center of your screen. Essentially what you’ve outlined below ZOM813, except no need to have a piece selected.

On Thu, Aug 27, 2009 at 1:27 AM, Z0M8I3 <messages@forums.vassalengine.org (messages@forums.vassalengine.org)> wrote:

Post generated using Mail2Forum (mail2forum.com)

Ben, before you get to deep, you might want to check but I think the last idea would clash with the piece window selection tool which is same function (click n drag window).

From: messages-bounces@forums.vassalengine.org [mailto:messages-bounces@forums.vassalengine.org] On Behalf Of Ben Smith
Sent: Wednesday, August 26, 2009 10:52 PM
To: VASSAL Engine Forums Mailing List
Subject: Re: [Developers]Three things I want to code.

Hey Joel,

Yes. The code is in there, the map does scroll when dragging a piece to the edge. It’s not working when I run from Eclipse, but that’s another story. (any ideas?)
The edge scrolling does need tweaking; The scroll step-size should increase markedly as you move closer to the edge. It should still scroll when you move the mouse 50 or so pixels outside the Vassal window.

Yeah I found JScrollPane, I guess it’s just a matter of replacing the mouse-wheel listeners.

I’m still deciding on the usefulness of this; But essentially you’re dragging a box and having the screen fill to that selection. So I zoom out to maximum, then drag a box around the area I want to zoom to, and it fills the screen. But yeah, it may not be of much use. The more I think about it, the more useless it is becoming. haha

Ben

Post generated using Mail2Forum (mail2forum.com)

You’re right Tim, I think mouse zoom and pan should do the trick. I’ll drop that third idea.
[/quote]

Thus spake Ben Smith:

No idea. I’m not an Eclipse user, sorry.

I’m willing to entertain any modifications which you think are an improvement.
The only way to test this is to try it and see how it feels.

Yes, but if you’re going to remove scrolling from the mouse wheel, then
you need to implement map dragging. Otherwise it’s going to become painful
to navigate around the map.

I know what you mean now. Lots of graphics programs have this. Usually it’s
only active when you have the zoom tool selected. Hmm.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake Ben Smith:

That would be easy with JOGL. I’m not quite sure how you’d do it with
what we have now. The problem is that the amount you have to pad around
the map would be half of the width/height of the map view, but the size
of the map view can change as you resize the map window.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Anyone know why drag-scrolling would not be working? It’s driving me nuts. It works fine when I install a distribution, but not when I build the code myself.

Joel, I installed the latest JDK on Debian, then did “make Vengine.jar”; Is this right?

Thus spake “bsmith”:

That’s right. How are you running VASSAL after that?

J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I’m kicking it off with this Joel: java -classpath classes:lib/* VASSAL.launch.ModuleManager “$@”

I’ve got the feeling I’m doing something really stupid. I’ve tried a few different sets of source code; v3_1_9, trunk etc. A couple of different versions of Java.

I may be wrong, but it looks like the code tagged v3_1_9 has dragging code which just doesn’t work.
In the scroller member of Map.java, there is nothing which performs the actual scrolling. When I grabbed the previous revision of Map.java, it worked.

What’s going on here? How did the distribution contain the correct code when the tag doesn’t?

Thus spake “bsmith”:

The methods which control edge scrolling are dragOver(), dragExit(),
and mouseDragged(). They all call scrollAtEdge(), and scroller handles
the timing. So far as I can see, 3.1.9 looks fine.

The map is scrolled by the calls to scrollAtEdge(), which is invoked from
dragOver() and mouseDragged() when drag and mouse move events happen. All
the scroller member does is update the drag coordinates at regular intervals
to make sure that the scrolling is uniform. If we scrolled the map a fixed
distance for every mouse event instead, we wouldn’t get a uniform scrolling
speed, since we can’t control the duration between mouse events. This is
the reason the scroller exists.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

scrollAtEdge() sets the values, but the Animator does the actual physically scrolling by calling the “scroll” method. When I put scroll(dx,dy) into the timing method in animator, it worked. So I dunno, I’m confused. lol But I got it working by inserting something which was in a previous revision of Map.java

Thus spake Ben Smith:

Oh, sorry. You’re right—the Animator does do the actual scrolling.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

The thing is Joel, v3_1_9 and trunk do not seem to have the working code in Map.java for drag scrolling… So where have releases come from? A working copy on your local machine?

I wasted almost a day trying to figure out why drag-scroll wasn’t working in my builds! I’m still confused. Are v3_1_9 and trunk not up-to-date?

Ben,

Yes, it looks that way. As you have noted, the line

scroll(sxdt, sydt);

is missing from Map.scroller.timingEvent() in trunk. It appears to have been accidentally lost from the trunk at the last commit. I have added it back in now. The 3.1 branch appear to be ok.

Joel and I discussed different scrolling methods a few months back and I implemented one as a test that I quite liked. I made the active scroll area wider, and the closer you got to the screen edge, the faster the scrolling went. I found it worked quite well and gave you a lot of control over the scroll speed once you got used to it.

B.


Brent Easton
Analyst/Programmer
University of Western Sydney
Email: b.easton@exemail.com.au


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “bsmith”:

The 3.1.9 tag and and the 3.1. branch have current code for drag scrolling.
I made the 3.1.9 tag immediately after building the 3.1.9 release from the
3.1 branch. The Map.java file that was used in the 3.1.9 release is
identical to the one under the 3.1.9 tag. If you can’t get this to work
from the 3.1 brahcn, then You’re having some other problem.

(Brent, thanks for catching the missing line in Map.java in the trunk.
I must have omitted that when I was resolving a conflict for a merge.)


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

For what it’s worth, I just checked out the Head revision of v3_1_9 and the scroll code isn’t there. Not sure what happened.

It looks like this:

[code] public void timingEvent(float fraction) {
// Constant velocity along each axis, 0.5px/ms
final long t1 = System.currentTimeMillis();
final int dt = (int)((t1 - t0)/2);
t0 = t1;

    // Check whether we have hit an edge
    final Rectangle vrect = scroll.getViewport().getViewRect();

[/code]

It should look more like this, not the absence of “scroll”:

[code] public void timingEvent(float fraction) {
// Follow the parabola x^2
final int delta = 2*(t++);
scroll(sxdelta, sydelta);

    // Check whether we have hit an edge
    final Rectangle vrect = scroll.getViewport().getViewRect();[/code]