Modify

Ticket #6895 (closed enhancement: fixed)

Opened 8 months ago

Last modified 2 months ago

[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

6895.patch (3.6 KB) - added by simon04 8 months ago.
mappaintstyles.png (15.4 KB) - added by simon04 8 months ago.
6895_v2.patch (4.5 KB) - added by simon04 3 months ago.

Change History

Changed 8 months ago by simon04

Changed 8 months ago by simon04

comment:1 Changed 8 months ago by simon04

  • Description modified (diff)

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.

Changed 3 months ago by simon04

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:9 Changed 3 months ago by akks

Is it possible to toggle styles by toolbar buttons?

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:

fix #6895 - Add Map Paint Styles to View menu

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 :-) )

Last edited 2 months ago by akks (previous) (diff)

comment:13 Changed 2 months ago by simon04

  • Status changed from reopened to closed
  • Resolution set to fixed

In 5088/josm:

fix #6895 - improve MapPaintMenu (add "Preference", keep menu open after clicking checkbox) - thanks: http://tips4java.wordpress.com/2010/09/12/keeping-menus-open/

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

Replying to simon04:

Replying to bastiK:

Works great, what about a toolbar button?

You suggest to have that button by default?

Not sure yet, maybe later.

(Adding the button(s) manually should already work.)

Individual styles work (without toggle effect), but not the top level styles menu entry.

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 :-).

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.