Help - Search - Members - Calendar
Full Version: Extending Titleformatting
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
jonpb
I would like to add a Titleformatting variable i.e. %blah%. I have been looking at the SDK code and trying to find examples but I can't find any examples and the documentation on this is pretty sparse in the doxygen docs.

This is what I deciphered, I might be completely off-base, but here goes:

Deriving from titleformat_hook seems to be what I need to do. It has the following abstract overrides:
process_field
process_function

The way I understand (imagine) this is that a 'field' is what is enclosed in % characters, in this case 'blah'. The function gets called when %blah% in encountered during Titleformatting parsing. If this correct, I imagine that the parser has a facility to register titleformat_hooks. It loops through the registered hooks everytime it parses out a 'field', calling process_field until one returns true, at that point it calls that titleformat_hook's process_function and breaks out of the loop. If all this is correct, then I get it, but I cannot find a mechanism to register the hook, nor can I find a factory (which I would assume internally does the registering) to instantiate my hook.

Thanks for any help.
Frank Bicking
You have to derive from metadb_display_hook (metadb.h).

CODE
class blah : public metadb_display_hook
{
public:
bool process_field(metadb_handle * p_handle, titleformat_text_out * p_out, const char * p_name, t_size p_name_length, bool & p_found_flag)
{
if (!stricmp_utf8(p_name, "blah"))
{
p_out->write(titleformat_inputtypes::meta, "content of blah");
p_found_flag = true;
return true;
}
return false;
}

bool process_function(metadb_handle * p_handle, titleformat_text_out * p_out,const char * p_name, t_size p_name_length, titleformat_hook_function_params * p_params, bool & p_found_flag) { return false; }
};

static service_factory_single_t<blah> g_blah;

titleformat_hooks are used in order to insert fields and functions which are not available throughout the whole program, but only when you run a certain titleformat_object of your component. A popular example is the "set_style" function in Columns UI.
jonpb
Excellent, thank you very much! I knew it would be simple. Peter's code is some of the best I have seen.
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.