Reduce overlapping in add-ons screen by making the name column wider and the date column smaller
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9070 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
264a54fd2f
commit
c96b00dc6b
@ -32,6 +32,7 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
|
|||||||
m_fallback_kerning_width = 0;
|
m_fallback_kerning_width = 0;
|
||||||
m_fallback_font_scale = 1.0f;
|
m_fallback_font_scale = 1.0f;
|
||||||
m_scale = 1.0f;
|
m_scale = 1.0f;
|
||||||
|
m_tab_stop = 0.5f;
|
||||||
m_is_hollow_copy = false;
|
m_is_hollow_copy = false;
|
||||||
m_black_border = false;
|
m_black_border = false;
|
||||||
m_shadow = false;
|
m_shadow = false;
|
||||||
@ -479,8 +480,8 @@ void ScalableFont::draw(const core::stringw& text,
|
|||||||
{
|
{
|
||||||
const int where = text.findFirst(L'\t');
|
const int where = text.findFirst(L'\t');
|
||||||
core::stringw substr = text.subString(0, where-1);
|
core::stringw substr = text.subString(0, where-1);
|
||||||
text_dimension = getDimension(text.c_str());
|
text_dimension = getDimension(substr.c_str()) + getDimension(L"XX");
|
||||||
offset.X += (position.getWidth()/2 - text_dimension.Width);
|
offset.X += (position.getWidth()*m_tab_stop - text_dimension.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- collect character locations
|
// ---- collect character locations
|
||||||
@ -493,10 +494,10 @@ void ScalableFont::draw(const core::stringw& text,
|
|||||||
{
|
{
|
||||||
wchar_t c = text[i];
|
wchar_t c = text[i];
|
||||||
|
|
||||||
//hack: one tab character is supported, it moves the cursor to the middle of the area
|
//hack: one tab character is supported, it moves the cursor to the tab stop
|
||||||
if (c == L'\t')
|
if (c == L'\t')
|
||||||
{
|
{
|
||||||
offset.X = position.UpperLeftCorner.X + position.getWidth()/2;
|
offset.X = position.UpperLeftCorner.X + position.getWidth()*m_tab_stop;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,10 @@ class ScalableFont : public IGUIFontBitmap
|
|||||||
|
|
||||||
bool m_is_hollow_copy;
|
bool m_is_hollow_copy;
|
||||||
bool m_rtl;
|
bool m_rtl;
|
||||||
|
|
||||||
|
/** Position in range [0..1] of the single tab stop we support */
|
||||||
|
float m_tab_stop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool m_black_border;
|
bool m_black_border;
|
||||||
@ -136,6 +140,9 @@ public:
|
|||||||
|
|
||||||
void updateRTL();
|
void updateRTL();
|
||||||
|
|
||||||
|
/** \param pos position of the tab stop, in range [0..1] */
|
||||||
|
void setTabStop(float pos) { m_tab_stop = pos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct SFontArea
|
struct SFontArea
|
||||||
|
@ -97,8 +97,15 @@ void ListWidget::add()
|
|||||||
|
|
||||||
if (m_header.size() > 0)
|
if (m_header.size() > 0)
|
||||||
{
|
{
|
||||||
const int col_size = m_w / m_header.size();
|
//const int col_size = m_w / m_header.size();
|
||||||
|
|
||||||
|
int proportion_total = 0;
|
||||||
|
for (unsigned int n=0; n<m_header.size(); n++)
|
||||||
|
{
|
||||||
|
proportion_total += m_header[n].m_proportion;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = m_x;
|
||||||
for (unsigned int n=0; n<m_header.size(); n++)
|
for (unsigned int n=0; n<m_header.size(); n++)
|
||||||
{
|
{
|
||||||
std::ostringstream name;
|
std::ostringstream name;
|
||||||
@ -113,10 +120,12 @@ void ListWidget::add()
|
|||||||
header->m_y = m_y;
|
header->m_y = m_y;
|
||||||
header->m_h = header_height;
|
header->m_h = header_height;
|
||||||
|
|
||||||
header->m_x = m_x + col_size*n;
|
header->m_x = x;
|
||||||
header->m_w = col_size;
|
header->m_w = m_w * float(m_header[n].m_proportion)/float(proportion_total);
|
||||||
|
|
||||||
header->setText( m_header[n] );
|
x += header->m_w;
|
||||||
|
|
||||||
|
header->setText( m_header[n].m_text );
|
||||||
header->m_properties[PROP_ID] = name.str();
|
header->m_properties[PROP_ID] = name.str();
|
||||||
|
|
||||||
header->add();
|
header->add();
|
||||||
|
@ -66,8 +66,20 @@ namespace GUIEngine
|
|||||||
|
|
||||||
ButtonWidget* m_selected_column;
|
ButtonWidget* m_selected_column;
|
||||||
|
|
||||||
|
struct Column
|
||||||
|
{
|
||||||
|
irr::core::stringw m_text;
|
||||||
|
int m_proportion;
|
||||||
|
|
||||||
|
Column(irr::core::stringw text, int proportion)
|
||||||
|
{
|
||||||
|
m_text = text;
|
||||||
|
m_proportion = proportion;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Leave empty for no header */
|
/** Leave empty for no header */
|
||||||
std::vector< irr::core::stringw > m_header;
|
std::vector< Column > m_header;
|
||||||
|
|
||||||
IListWidgetHeaderListener* m_listener;
|
IListWidgetHeaderListener* m_listener;
|
||||||
|
|
||||||
@ -193,8 +205,9 @@ namespace GUIEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** To be called before Widget::add(); columns are persistent across multiple add/remove cycles
|
/** To be called before Widget::add(); columns are persistent across multiple add/remove cycles
|
||||||
|
* \param proportion A column with proportion 2 will be twice as large as a column with proportion 1
|
||||||
*/
|
*/
|
||||||
void addColumn(irr::core::stringw col) { m_header.push_back( col ); }
|
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
|
|
||||||
#include "addons/addons_manager.hpp"
|
#include "addons/addons_manager.hpp"
|
||||||
#include "addons/network_http.hpp"
|
#include "addons/network_http.hpp"
|
||||||
|
#include "guiengine/CGUISpriteBank.h"
|
||||||
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "guiengine/widget.hpp"
|
#include "guiengine/widget.hpp"
|
||||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||||
#include "guiengine/CGUISpriteBank.h"
|
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "states_screens/dialogs/addons_loading.hpp"
|
#include "states_screens/dialogs/addons_loading.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
@ -62,8 +63,8 @@ void AddonsScreen::loadedFromFile()
|
|||||||
|
|
||||||
GUIEngine::ListWidget* w_list =
|
GUIEngine::ListWidget* w_list =
|
||||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||||
w_list->addColumn( _("Add-on name") );
|
w_list->addColumn( _("Add-on name"), 2 );
|
||||||
w_list->addColumn( _("Updated date") );
|
w_list->addColumn( _("Updated date"), 1 );
|
||||||
w_list->setColumnListener(this);
|
w_list->setColumnListener(this);
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
|
|
||||||
@ -74,6 +75,9 @@ void AddonsScreen::init()
|
|||||||
Screen::init();
|
Screen::init();
|
||||||
getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();
|
getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();
|
||||||
|
|
||||||
|
// FIXME: return tab stop to the center when leaving this screen!!
|
||||||
|
GUIEngine::getFont()->setTabStop(0.66f);
|
||||||
|
|
||||||
if(UserConfigParams::logAddons())
|
if(UserConfigParams::logAddons())
|
||||||
std::cout << "[addons] Using directory <" + file_manager->getAddonsDir()
|
std::cout << "[addons] Using directory <" + file_manager->getAddonsDir()
|
||||||
<< ">\n";
|
<< ">\n";
|
||||||
@ -92,6 +96,13 @@ void AddonsScreen::init()
|
|||||||
loadList();
|
loadList();
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void AddonsScreen::tearDown()
|
||||||
|
{
|
||||||
|
GUIEngine::getFont()->setTabStop(0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Loads the list of all addons of the given type. The gui element will be
|
/** Loads the list of all addons of the given type. The gui element will be
|
||||||
* updated.
|
* updated.
|
||||||
|
@ -74,6 +74,7 @@ public:
|
|||||||
virtual void onColumnClicked(int columnId);
|
virtual void onColumnClicked(int columnId);
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
virtual void tearDown();
|
||||||
|
|
||||||
void setLastSelected();
|
void setLastSelected();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user