Ticket #6895 (closed enhancement: fixed)
[Patch] Add Map Paint Styles to View menu
| Reported by: | simon04 | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Component: | Core |
| Version: | Keywords: | style menu toolbar | |
| Cc: |
Description (last modified by bastiK) (diff)
In order to achieve #6731, I'd like to add all available Map Paint Styles to the View menu. Available styles can be toggled through the menu, which removes the necessity to view/hide the toggle dialog when this is seldom needed.
What I couldn't manage to get working is to add the new menu entry "Map Paint Styles" to the toolbar for a quicker access. The problem I encountered is that I cannot inherit from JMenu (for submenu entries) and JosmAction (for registration for toolbar) simultaneously. I hope anyone knows how to solve this :-).
Attachments
Change History
comment:2 follow-up: ↓ 3 Changed 8 months ago by Don-vip
Create another action that simply displays the menu ? (with the menu being a public final field of Main class)
comment:3 in reply to: ↑ 2 Changed 8 months ago by simon04
Replying to Don-vip:
Create another action that simply displays the menu ?
Could you sketch that in more detail, please? Which code goes to the actionPerformed method?
comment:4 Changed 7 months ago by bastiK
- Description modified (diff)
Why not copy TaggingPresets code? This seems to work the way you want.
comment:5 in reply to: ↑ description Changed 7 months ago by bastiK
Replying to simon04:
In order to achieve #6731, I'd like to add all available Map Paint Styles to the View menu. Available styles can be toggled through the menu, which removes the necessity to view/hide the toggle dialog when this is seldom needed.
One problem I always had with Map Paint Styles in the Menu is that you cannot easily switch between 2 "alpha styles". First, you have to deactivate the current style and then activate the new one (or the other way around). This adds up to 6 mouse clicks compared to 4 clicks with toggle dialog (including activating and deactivating it). But as a toolbar button it would be more efficient, I'd suggest to have it in the toolbar by default.
The problem could be solved by adding a property "alpha" to the style, which means it is normally not used at the same time as another alpha style. These styles would have a radio button in front and not a checkbox. I postponed this idea because currently it works well and offers more freedom to the user.
comment:6 Changed 5 months ago by stoecker
- Owner changed from team to simon04
- Status changed from new to needinfo
What is the status of this?
comment:7 Changed 5 months ago by simon04
- Owner changed from simon04 to team
- Status changed from needinfo to new
No progress from my side. I'm happy if someone else can fix the remaining issue.
comment:8 Changed 3 months ago by simon04
- Summary changed from [Patch needs rework] Add Map Paint Styles to View menu to [Patch] Add Map Paint Styles to View menu
Attached new version. Seems to be working fine while testing, please take a look at the code.
Drawback: When adding a new style via preferences, removing it again, and adding it a second time, a
Registered toolbar action mappaint/Surface overwritten: org.openstreetmap.josm.gui.mappaint.MapPaintMenu$MapPaintAction gets org.openstreetmap.josm.gui.mappaint.MapPaintMenu$MapPaintAction
is printed to the console. To avoid this, does it make sense to add the following method?
Main.toolbar.register(Action action, boolean ignoreOverwriting)
comment:10 Changed 3 months ago by simon04
Yes.
comment:11 Changed 2 months ago by simon04
- Status changed from new to closed
- Resolution set to fixed
In 5086/josm:
comment:12 Changed 2 months ago by akks
- Status changed from closed to reopened
- Resolution fixed deleted
Is looks good!
Maybe it can be useful to add configuration button after style list. Then this menu item can fully replace toggle dialog for non-experts (moving up/down in the list is more expert thing).
(please re-close if wontfix :-) )
comment:13 Changed 2 months ago by simon04
- Status changed from reopened to closed
- Resolution set to fixed
In 5088/josm:
comment:14 Changed 2 months ago by bastiK
Please put
// License: GPL. For details, see LICENSE file.
at the top of each new file.
(Quote "You are free to use and/or modify any or all code posted on the Java Tips Weblog without restriction.")
comment:15 follow-up: ↓ 16 Changed 2 months ago by bastiK
Works great, what about a toolbar button?
comment:16 in reply to: ↑ 15 ; follow-up: ↓ 17 Changed 2 months ago by simon04
Replying to bastiK:
Works great, what about a toolbar button?
You suggest to have that button by default? (Adding the button(s) manually should already work.)
comment:17 in reply to: ↑ 16 Changed 2 months ago by bastiK
comment:18 in reply to: ↑ description Changed 2 months ago by simon04
I guess, I forgot the remaining issue when considering this ticket for the second time. So this is still to be done …
Replying to simon04:
What I couldn't manage to get working is to add the new menu entry "Map Paint Styles" to the toolbar for a quicker access. The problem I encountered is that I cannot inherit from JMenu (for submenu entries) and JosmAction (for registration for toolbar) simultaneously. I hope anyone knows how to solve this :-).



