Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight drag and drop destination #3705

Closed
DorpsGek opened this issue Mar 19, 2010 · 9 comments
Closed

Highlight drag and drop destination #3705

DorpsGek opened this issue Mar 19, 2010 · 9 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

sbr opened the ticket and wrote:

This patch aims to make more obvious the destination where you're dragging an object:
- in the order gui: show an arrow between the two orders a dragged one will be inserted.
- in the group gui: show an arrow indicating in which group a dragged vehicle will be added.
- in the train depot gui: insert an empty space between the two wagons a dragged one will be inserted.

The first patch ('00add-drag-event-handler') add a new window event handler: OnMouseDrag(Point, int).
This handler is called when the mouse move while dragging an object.

The '01' patches need '00' to be applied but are independent.

The '02' patch should be applied on top of '01dragged-vehicle-in-group'. It add two arrows in the space separator drawn by '01dragged-vehicle-in-group'. This patch makes the depot-gui highlight consistent with the two other highlights. However I'm think it's not really needed nor graphically successful.

If a new window event handler isn't desired, code inside 'OnMouseDrag()' can be moved to 'OnMouseLoop()'and protected by the tests condition of 'window.cpp:HandleMouseDrag()'.

Please find attached a picture showing patches in action and the patches against r19465.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/3705
@DorpsGek
Copy link
Member Author

Alberth wrote:

Basic idea seems fine, as is the introduction of the OnMouseDrag() callback.

The actual highlighting in the windows however is not very convincing. In the order gui and the group gui, the additional > looks a lot like a normal gui element, in the screen shot you cannot see it 'jumping out', attracting the attention of the user. The depot gui has the same problem, the arrows are mostly invisible.

If you can improve the highlighting that would be great.

Furthermore, please make sure you follow coding style. Several lines have white space at the end of the line. Also, all functions should have doxygen docs, 'case' statements are seperated from each other by an empty lines, and one statement at a line.
Last but not least, the > in the order gui is glitchy, when inserting before the top-row, the > is drawn outside the matrix widget border.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8032

@DorpsGek
Copy link
Member Author

sbr wrote:

Thanks for reviewing this patch; I'll take more care of the coding style.

I've a new proposal for the group highlighting: filling the cell background and writing the text in white when dragged over.
That's consistent with toolbar and dropdown widgets if filled in black. However for the group gui, I find black a little bit aggressive.

Attached are three version of the group gui, highlighted with black, _colour_gradient[COLOUR_GREY][3] and _colour_gradient[COLOUR_GREY][7].

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8073

@DorpsGek
Copy link
Member Author

Alberth wrote:

I forgot to mention this the previous time:
When looking into code style, also check the multi-line comments. In the OpenTTD style, every line starts with a * . Thank you!

With respect to your new proposal:
I agree that giving the background a different colour is a nice solution. Highlighting the text I am less sure of. If you drag&drop in the same list (eg re-order the active newgrfs in the newgrf gui), another entry in the same list is also highlighted, which may cause confusion.

The black highlighted background seems quite ugly, so I'd use one of the other two.
If you also highlight the text, the darker background seems better since it gives more contrast. If you leave the text black, the lighter background may be better (again since it gives more contrast). You probably need to program it, and experiment a little to find the best solution.

Highlighting may give problems in the new NewGRF gui with its black background, but I am thinking to change that anyway. :)
Looking forward to your patches.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8074

@DorpsGek
Copy link
Member Author

sbr wrote:

I choose to test highlighting with a light gray rectangle without changing the text colour. If the object is dragged over itself (or over its group) nothing is drawn.

In the group gui, the cell is highlighted.
In the order gui, a line is drawn between the orders were the dragged one will be inserted.
In the depot gui, an highlighted space is inserted in the train where the wagon will be inserted. It's size depends of the width of the dragged wagon.

I'm not yet convinced by the order gui highlighting; I'll try to find something better.

Concerning the new NewGRF gui, maybe it can be highlighted with the blue currently used to mark the selected file.
The code used to move orders might be "borrowed" to allow the reordering of loaded NewGRF files. I've already thought of it but had not took time to do it.

About the codestyle, I think most of the errors are fixed (at least your python script doesn't complain anymore).

The code logic didn't change; the handler patch and its usages in the other patches are nearly the same since the first version. I think it's now for me more a matter of finding the right look for the highlight.

Please find a new screenshot and updated patches against r19880.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8082

@DorpsGek
Copy link
Member Author

sbr wrote:

I proposed a patch to enable NewGRF active files drag-and-drop in #3854.
I also made a patch that highlight the destination of the dragged NewGRF files.

Please find attached a patch against r19884.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8083

@DorpsGek
Copy link
Member Author

Alberth wrote:

I just pushed the general infra structure, and the depot and order gui highlighting to trunk (I made some changes to the latter).
The group gui contains some errors in my view. In a gui without any groups (that is, only the 'ungrouped' and 'all' groups), I get a highlight when dragging a train from the right one of both groups, yet nothing actually changes.
Note that doing this with a train that is in some group, does cause a change, so in that situation, the highlighting is correct.

Patches were good, except lines getting split always get an indent of two tabs at the second line, and you use a non-ascii character for ".." which does not seem necessary.

Thanks for your work.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8085

@DorpsGek
Copy link
Member Author

Krille wrote:

I like the already committed changes, however there are a few issues.

Concerning the orders window:
When aborting dragging of an order with the Esc key then the highlighting isn't cleared. This also happens for the (rather constructed) case of pressing a key which opens a toolbar while dragging.

Not caused by these changes, but somewhat annoying: You can't drag the selected order. For trains it will only change the stop location and do nothing for the other vehicle types. It should change the stop location only on mouse up. If there's no mouse up but the mouse is moved then it should start dragging. Is that possible? Buttons generally already react on mouse down, so there's no way to abort a misdirected click. That could also be improved.

Concerning the depot window:
There's no highlighting when dragging a wagon to an empty row. This may create the impression that the wagon couldn't be dragged there.

For dual headed engines the position after the rear head is highlighted but on drop the wagon actually gets placed before the head.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment8097

@DorpsGek
Copy link
Member Author

michi_cc closed the ticket.

Reason for closing: Implemented

Final parts in r24125.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705

@DorpsGek
Copy link
Member Author

Krille wrote:

Well, there are some points left from my previous comment and some new points:

Concerning the group window:
Dragging a vehicle to an empty space in the group list creates a new group, but there's no highlighting.

Dragging a grouped vehicle to the "All vehicles" group will remove it from the group, but there's no highlighting.

Dragging a grouped vehicle to the group it's already in is a no-op, but there is highlighting.

Concerning the orders window:
Not caused by these changes, but somewhat annoying: You can't drag the selected order. For trains it will only change the stop location and do nothing for the other vehicle types. It should change the stop location only on mouse up. If there's no mouse up but the mouse is moved then it should start dragging. Is that possible? Buttons generally already react on mouse down, so there's no way to abort a misdirected click. That could also be improved.

Concerning the depot window:
There's no highlighting when dragging a wagon to an empty row. This may create the impression that the wagon couldn't be dragged there.

For dual headed engines the position after the rear head is highlighted but on drop the wagon actually gets placed before the head.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3705#comment11100

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant