ListBox::createSnapshotOfSelectedRows parameters


#1

The parameters to ListBox::createSnapshotOfSelectedRows specify (int& imageX, int& imageY) but it is not clear how it is possible to set the values of imageX and imageY to allow an override to force a custom image to appear centered on the cursor.

First of all the corresponding MouseEvent is not passed into createSnapshotOfSelectedRows, and second of all imageX and imageY are uninitialized variables, communicating no information about the position of the mouse.

So I am confused…what do I set imageX and imageY to in order that the resulting custom drag image is always centered on the mouse?


#2

You do like the most obscure areas of the codebase, don’t you…!

The coordinates return the position within the component at which the returned image was snapped. So if you just made a 10x10 image of the section of the component at (100, 100, 10, 10), it’d return x = 100, y = 100.


#3

This is what I ended up having to do to make the drag image centered on the mouse:

      Image im;
      //...
      const Point<int> lastMouseDown (Desktop::getLastMouseDownPosition());
      Point<int> p = getLocalPoint( 0, lastMouseDown);
      dragX = p.getX() - im.getWidth()/2;
      dragY = p.getY() - im.getHeight()/2;

dragX and dragY are the parameters from createSnapshotOfSelectedRows().

It strikes me as incorrect that I would need to access Desktop::getLastMouseDownPosition(). I wish createSnapshotOfSelectedRows came with a MouseEvent record.


#4

Heh well, you know most programmers hate doing UI work. Look at most open source projects that have a GUI, there is no polish or real effort put into usability (with a few exceptions). I consider the UI to be the “face” of the application, it’s what users see and what they have to deal with, and the quality of the UI is what people have as their first impression. A good UI doesn’t get noticed, it just works and feels right. It’s the bad UIs that get the attention.

This having been said, I always polish my application UI to the greatest extent possible That’s why little things like the drag image, getting the listbox to scroll in whole row increments, paging / mouswheeling in the viewport scrollbar by (visible rows - 1) pixels, hinting for small fonts, having a native menu bar that works as expected, constraining the content component’s size instead of the heavyweight peer, etc… all mean a lot to me. I will not even allow a single pixel to be out of place, part of quality control is taking a screenshot of the application and going over it at 800% magnification in Photoshop, pixel by pixel - this is how I found the problem with curve flattening and rounded rectangles.

I know that listboxes, having robust object passing for drag and drop, etc… are boring compared to fun and exciting things like drawables, component transformations, and iphone compatibility but I’m not trying to be a pain in the ass I just have to fulfill the design criteria.


#5

The method is called “createSnapshotOfSelectedRows”. The clue is in the name. If you decide to overload a method called “createSnapshotOfSelectedRows” but make it do something completely different, then don’t start moaning when the parameters aren’t suitable!