-
+
diff --git a/src/gui/engine.hpp b/src/gui/engine.hpp
index 81f67a4cb..5105a2e42 100644
--- a/src/gui/engine.hpp
+++ b/src/gui/engine.hpp
@@ -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 (
...
, 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 (), 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.
diff --git a/src/gui/screen_loader.cpp b/src/gui/screen_loader.cpp
index 085336626..526fadb68 100644
--- a/src/gui/screen_loader.cpp
+++ b/src/gui/screen_loader.cpp
@@ -98,6 +98,11 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector& 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;
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index 46c0b8cd0..24f887631 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -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)
{
diff --git a/src/gui/widget.cpp b/src/gui/widget.cpp
index 44ab9a8f3..0cee279fe 100644
--- a/src/gui/widget.cpp
+++ b/src/gui/widget.cpp
@@ -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; nx = x;
ribbon->y = y + (int)(n*row_height);
ribbon->w = w;
diff --git a/src/gui/widget.hpp b/src/gui/widget.hpp
index d92232a04..9701937e2 100644
--- a/src/gui/widget.hpp
+++ b/src/gui/widget.hpp
@@ -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();