Help - Search - Members - Calendar
Full Version: slash -inside- menu item?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
hartwork
is there a way to include slashes ("/") inside a menu item? by default slashes is interpreted as folders.

let's say i'd want to have an item like [Playback]->[Mute/Unmute] - how do i create this?
kode54
You can use the caption "Playback/Mute or unmute" or "Playback/Toggle mute." It doesn't really matter, as you can override what is actually displayed in the menu.

You can also override the caption differently, depending on the state. So, instead of using a checkmark, you can show "Mute" or "Unmute." If you are implementing this as a DSP, you can also use a static reference counter, incremented the first time on_data is called and decremented in the destructor only if on_data was called. Of course, then you'd be duplicating the functionality of foo_dsp_mute. :B
hartwork
That means i cannot have a slash inside an entry?
kode54
Er, what? The value returned by enum_item is only used for configuration, unless you don't bother to override get_display_data.
hartwork
QUOTE(kode54 @ Feb 27 2004, 09:58 PM)
Er, what? The value returned by enum_item is only used for configuration, unless you don't bother to override get_display_data.

that was the important hint! thanx!

my final code (will convert all pipes in a menu item to slashes):
CODE
virtual bool get_display_data( unsigned n, const ptr_list_base<metadb_handle> & data,string_base & out, unsigned & displayflags, const GUID & caller )
{
 if( n < 0 || n > get_num_items() || !is_available( n ) ) return false;
 
 string8 temp;
 enum_item( n, temp );

 // Find last slash
 const char * ptr = strrchr( temp, '/' );
 if( ptr )
 {
  ptr++;
 }
 else
 {
  ptr = temp;
 }

 // Pipe to slash
 temp.replace_char( '|','/' );

 out.set_string(ptr);

 displayflags = ( is_checked( n ) ? FLAG_CHECKED : 0) | ( is_disabled( n ) ? FLAG_DISABLED_GRAYED : 0 );
 return true;
}
kode54
You know, you could just have get_display_data return independent constants. After all, it is called every time a menu containing one or more of your items is popped open.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.