Multi-pages GUI
In some situations, it may be needed to separate the content of the script GUI onto several pages. Either for purely visual presentation purposes, or, more importantly because some pages content depend on some configuration of GUI elements in the previous pages. In other words, multi-page GUI is more or less like a "wizard" that you can find in GUIs.
An examples usage of multi-page GUI can found in the Memory Bus decoder.
The first page lets you select data width and control width of the memory bus:
The next page's content (data bus definition) depends on the data bus width defined in first step:
The same goes for the subsequent pages of the memory bus protocol decoder.
Implementing multi-page GUI
To declare that your GUI supports multiple pages (either it is a protocol decoder GUI, a pattern generator GUI, or a signal builder), you have to add one of these entry functions:
function on_get_n_pages_gui_decoder()
{
return 3; //Number of pages
}
function on_get_n_pages_gui_trigger()
{
return 3; //Number of pages
}
function on_get_n_pages_gui_signal_builder()
{
return 3; //Number of pages
}
function on_get_n_pages_gui_pattern_generator()
{
return 3; //Number of pages
}
Of course, each one of these functions should return the correct number of pages.
Then, once the number of pages is defined you need to implement page_id
parameter in the draw_gui function.
For the sake of simplicity, let's focus on decoder GUI, the page_id
is add to the entry function as in the example below:
function on_draw_gui_decoder(page_id)
{
switch(page_id)
{
case 0:
// Define GUI of page 1 here
break;
case 1:
// Read GUI information from page 1
// Define GUI of page 2 here
break;
case 2:
// Read GUI information from page 1 and 2
// Define GUI of page 3 here
break;
}
}
Similarly, the GUI evaluation entry function should be modified as in the following example:
function on_eval_gui_decoder(page_id)
{
switch(page_id)
{
case 0:
// Evaluation page 1 of the GUI
return true;
break;
case 1:
// Evaluation page 2 of the GUI
return true;
break;
case 2:
// Evaluation page 3 of the GUI
return true;
break;
}
}
In case one or several GUIs don't need multi-page feature, you can just omit the on_get_n_pages...()
function, or make it return 1. In that case, you can also discard the page_id
parameter.
Please refer to the Memory Bus decoder script for a complete working example of multi-page GUI.