added scrolling ribbon component
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3416 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b262fd7f96
commit
8bc4ed83e9
@ -35,7 +35,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<spacer height="50" width="10"/>
|
||||
<spacer proportion="1" width="10"/>
|
||||
|
||||
|
||||
<div width="75%" height="40" layout="horizontal-row" >
|
||||
@ -45,7 +45,7 @@
|
||||
<label proportion="1" height="100%" text="Fullscreen"/>
|
||||
</div>
|
||||
|
||||
<ribbon_grid id="resolutions" proportion="4" text="all" width="100%" square_items="false" align="center" child_width="128" child_height="128" />
|
||||
<scrollable_ribbon id="resolutions" proportion="2" text="all" width="100%" square_items="false" align="center" child_width="128" child_height="128" />
|
||||
|
||||
<button id="apply_resolution" width="20%" height="30" text="Apply video changes" />
|
||||
|
||||
|
@ -48,7 +48,7 @@ WTYPE_DIV "div"
|
||||
A container. Does not do much on itself, but is useful to lay out children automatically. Divs can be nested.
|
||||
Supports property PROP_LAYOUT. Of spawn type (<div>...</div>, place children within)
|
||||
|
||||
WTYPE_RIBBON_GRID "ribbon_grid"
|
||||
WTYPE_RIBBON_GRID "ribbon_grid", "scrollable_ribbon"
|
||||
Shows a scrollable grid of icons. NOT of spawn type (<ribbon_grid .../>), contents must be programmatically set at runtime.
|
||||
Property PROP_SQUARE can be set to tell the engine if the ribbon's contents are rectangular or not (this will
|
||||
affect the type of highlighting used). Supports an optional label at the bottom if PROP_TEXT is set.
|
||||
@ -57,6 +57,8 @@ An interesting aspect of PROP_CHILD_WIDTH and PROP_CHILD_HEIGHT is that you can
|
||||
you want (so you can e.g. save textures to a power-of-two size like 256x256, but then show it in 4:3 ratio).
|
||||
Gives a special meaning to the text parameter. A value of "bottom" means to display the name of the selected icon at the bottom.
|
||||
A value of "all" means that each icon shall have its name under it.
|
||||
The "scrollable_ribbon" subtype is a single-line scrollable ribbon; it uses the ribbon-grid implementation since it already
|
||||
supports scrolling so no need to duplicated...
|
||||
|
||||
WTYPE_MODEL_VIEW "model"
|
||||
Displays a model. Currently incomplete. Contents must be set programmatically.
|
||||
|
@ -98,6 +98,11 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector<Widget>& append_t
|
||||
type = WTYPE_RIBBON_GRID;
|
||||
append_to.push_back(new RibbonGridWidget());
|
||||
}
|
||||
else if (!strcmp("scrollable_ribbon", xml->getNodeName()))
|
||||
{
|
||||
type = WTYPE_RIBBON_GRID;
|
||||
append_to.push_back(new RibbonGridWidget(1));
|
||||
}
|
||||
else if (!strcmp("model", xml->getNodeName()))
|
||||
{
|
||||
type = WTYPE_MODEL_VIEW;
|
||||
|
@ -587,7 +587,8 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
}
|
||||
else if(type == WTYPE_GAUGE)
|
||||
{
|
||||
drawGaugeFill(rect, widget, focused);
|
||||
if(!pressed)
|
||||
drawGaugeFill(rect, widget, focused);
|
||||
}
|
||||
else if(type == WTYPE_CHECKBOX)
|
||||
{
|
||||
|
@ -545,11 +545,11 @@ void RibbonWidget::add()
|
||||
float global_zoom = 1;
|
||||
|
||||
const int min_free_space = 50;
|
||||
if(free_h_space < min_free_space) // buttons are too big to fit :( zoom out
|
||||
{
|
||||
//if(free_h_space < min_free_space) // buttons are too big to fit :( zoom out
|
||||
//{
|
||||
global_zoom = (float)w / (float)( w - free_h_space + min_free_space );
|
||||
free_h_space = (int)(w - total_needed_space*global_zoom);
|
||||
}
|
||||
//}
|
||||
|
||||
const int one_button_space = (int)round((float)w / (float)subbuttons_amount);
|
||||
|
||||
@ -789,13 +789,15 @@ void SpinnerWidget::setValue(const int new_value)
|
||||
#pragma mark Ribbon Grid Widget
|
||||
#endif
|
||||
|
||||
RibbonGridWidget::RibbonGridWidget()
|
||||
RibbonGridWidget::RibbonGridWidget(const int max_rows)
|
||||
{
|
||||
m_scroll_offset = 0;
|
||||
m_needed_cols = 0;
|
||||
m_col_amount = 0;
|
||||
m_has_label = false;
|
||||
|
||||
m_max_rows = max_rows;
|
||||
|
||||
m_left_widget = NULL;
|
||||
m_right_widget = NULL;
|
||||
}
|
||||
@ -823,19 +825,22 @@ void RibbonGridWidget::add()
|
||||
// decide how many rows and column we can show in the available space
|
||||
int row_amount = (int)round((h-label_height) / (float)child_height);
|
||||
//if(row_amount < 2) row_amount = 2;
|
||||
if(row_amount > 4) row_amount = 4;
|
||||
if(row_amount > m_max_rows) row_amount = m_max_rows;
|
||||
|
||||
const float row_height = (float)(h - label_height)/(float)row_amount;
|
||||
|
||||
// FIXME - that code seems to work but it's a bit obscure why
|
||||
float ratio_zoom = (float)child_height / (float)row_height;
|
||||
if(ratio_zoom > 1) ratio_zoom = 1 / ratio_zoom;
|
||||
m_col_amount = (int)round( w / ratio_zoom / ( child_width + 20 ) );
|
||||
if(m_col_amount < 5) m_col_amount = 5;
|
||||
float ratio_zoom = (float)row_height / (float)(child_height - label_height);
|
||||
m_col_amount = (int)round( w / ( child_width*ratio_zoom ) );
|
||||
|
||||
// std::cout << "w=" << w << " child_width=" << child_width << " ratio_zoom="<< ratio_zoom << " m_col_amount=" << m_col_amount << std::endl;
|
||||
|
||||
//if(m_col_amount < 5) m_col_amount = 5;
|
||||
|
||||
// add rows
|
||||
for(int n=0; n<row_amount; n++)
|
||||
{
|
||||
RibbonWidget* ribbon = new RibbonWidget(RIBBON_TOOLBAR);
|
||||
// RibbonWidget* ribbon = new RibbonWidget(RIBBON_COMBO);
|
||||
ribbon->x = x;
|
||||
ribbon->y = y + (int)(n*row_height);
|
||||
ribbon->w = w;
|
||||
|
@ -282,6 +282,7 @@ namespace GUIEngine
|
||||
int m_scroll_offset;
|
||||
int m_needed_cols;
|
||||
int m_col_amount;
|
||||
int m_max_rows;
|
||||
|
||||
bool m_has_label;
|
||||
|
||||
@ -289,7 +290,7 @@ namespace GUIEngine
|
||||
Widget* m_left_widget;
|
||||
Widget* m_right_widget;
|
||||
public:
|
||||
RibbonGridWidget();
|
||||
RibbonGridWidget(const int max_rows=4);
|
||||
|
||||
void add();
|
||||
bool rightPressed();
|
||||
|
Loading…
x
Reference in New Issue
Block a user