Skip to content

Commit

Permalink
Use 4 spaces instead of an image hack to indent topic lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Mar 22, 2015
1 parent 446e9b2 commit 534a0f7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Binary file removed images/help/indentation.png
Binary file not shown.
1 change: 0 additions & 1 deletion src/help/help_impl.cpp
Expand Up @@ -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";
Expand Down
1 change: 0 additions & 1 deletion src/help/help_impl.hpp
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/help/help_menu.cpp
Expand Up @@ -89,28 +89,28 @@ 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();
}

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();
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/help/help_menu.hpp
Expand Up @@ -75,7 +75,7 @@ class help_menu : public gui::menu

/// 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);
Expand Down

0 comments on commit 534a0f7

Please sign in to comment.