Use 4 spaces instead of an image hack to indent topic lists

This commit is contained in:
Charles Dang 2015-03-22 23:30:51 +11:00
parent 446e9b2fe7
commit 534a0f7ffb
5 changed files with 8 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

View file

@ -83,7 +83,6 @@ const unsigned max_history = 100;
const std::string topic_img = "help/topic.png";
const std::string closed_section_img = "help/closed_section.png";
const std::string open_section_img = "help/open_section.png";
const std::string indentation_img = "help/indentation.png";
// The topic to open by default when opening the help dialog.
const std::string default_show_topic = "..introduction";
const std::string unknown_unit_topic = ".unknown_unit";

View file

@ -333,7 +333,6 @@ extern const unsigned max_history;
extern const std::string topic_img;
extern const std::string closed_section_img;
extern const std::string open_section_img;
extern const std::string indentation_img;
// The topic to open by default when opening the help dialog.
extern const std::string default_show_topic;
extern const std::string unknown_unit_topic;

View file

@ -89,20 +89,20 @@ void help_menu::update_visible_items(const section &sec, unsigned level)
}
}
std::string help_menu::indented_icon(const std::string& icon, const unsigned level) {
std::string help_menu::indent_list(const std::string& icon, const unsigned level) {
std::stringstream to_show;
for (unsigned i = 1; i < level; ++i) {
to_show << IMAGE_PREFIX << indentation_img << IMG_TEXT_SEPARATOR;
for (unsigned i = 1; i < level; ++i) {
to_show << " "; // Indent 4 spaces
}
to_show << IMAGE_PREFIX << icon;
to_show << IMG_TEXT_SEPARATOR << IMAGE_PREFIX << icon;
return to_show.str();
}
std::string help_menu::get_string_to_show(const section &sec, const unsigned level)
{
std::stringstream to_show;
to_show << indented_icon(expanded(sec) ? open_section_img : closed_section_img, level)
to_show << indent_list(expanded(sec) ? open_section_img : closed_section_img, level)
<< IMG_TEXT_SEPARATOR << sec.title;
return to_show.str();
}
@ -110,7 +110,7 @@ std::string help_menu::get_string_to_show(const section &sec, const unsigned lev
std::string help_menu::get_string_to_show(const topic &topic, const unsigned level)
{
std::stringstream to_show;
to_show << indented_icon(topic_img, level)
to_show << indent_list(topic_img, level)
<< IMG_TEXT_SEPARATOR << topic.title;
return to_show.str();
}
@ -172,7 +172,7 @@ int help_menu::process()
const std::string icon_img = expanded(*sec) ? open_section_img : closed_section_img;
// we remove the right thickness (ne present between icon and text)
int text_start = style_->item_size(indented_icon(icon_img, sec->level)).w - style_->get_thickness();
int text_start = style_->item_size(indent_list(icon_img, sec->level)).w - style_->get_thickness();
// NOTE: if you want to forbid click to the left of the icon
// also check x >= text_start-image_width(icon_img)

View file

@ -75,7 +75,7 @@ private:
/// Return the string to use as the prefix for the icon part of the
/// menu-string at the specified level.
std::string indented_icon(const std::string &icon, const unsigned level);
std::string indent_list(const std::string &icon, const unsigned level);
/// Return the string to use as the menu-string for sections at the
/// specified level.
std::string get_string_to_show(const section &sec, const unsigned level);