Minor cleanup of GUI2 helper code

This commit is contained in:
Charles Dang 2017-05-04 01:22:55 +11:00
parent 974315f9b7
commit 4b9463a6ff
2 changed files with 15 additions and 22 deletions

View file

@ -16,24 +16,20 @@
#include "gui/widgets/helper.hpp"
#include "color.hpp"
#include "formula/callable.hpp"
#include "formula/string_utils.hpp"
#include "gui/core/log.hpp"
#include "gui/core/point.hpp"
#include "gui/widgets/settings.hpp"
#include "color.hpp"
#include "sdl/rect.hpp"
#include "formula/callable.hpp"
#include "formula/string_utils.hpp"
#include "tstring.hpp"
#include <SDL.h>
namespace gui2
{
namespace
{
static bool initialized_ = false;
}
bool init()
{
@ -44,7 +40,6 @@ bool init()
load_settings();
initialized_ = true;
return initialized_;
}
@ -68,7 +63,7 @@ font::pango_text::FONT_STYLE decode_font_style(const std::string& style)
}
if(font_style_map.find(style) == font_style_map.end()) {
ERR_GUI_G << "Unknown style '" << style << "' using 'normal' instead." << std::endl;
ERR_GUI_G << "Unknown style '" << style << "', using 'normal' instead." << std::endl;
return font::pango_text::STYLE_NORMAL;
}
@ -86,13 +81,13 @@ PangoAlignment decode_text_alignment(const std::string& alignment)
return PANGO_ALIGN_CENTER;
} else if(alignment == "right") {
return PANGO_ALIGN_RIGHT;
} else {
if(!alignment.empty() && alignment != "left") {
ERR_GUI_E << "Invalid text alignment '" << alignment
<< "' falling back to 'left'.\n";
}
return PANGO_ALIGN_LEFT;
}
if(!alignment.empty() && alignment != "left") {
ERR_GUI_E << "Invalid text alignment '" << alignment << "', falling back to 'left'." << std::endl;
}
return PANGO_ALIGN_LEFT;
}
std::string encode_text_alignment(const PangoAlignment alignment)
@ -105,9 +100,9 @@ std::string encode_text_alignment(const PangoAlignment alignment)
case PANGO_ALIGN_CENTER:
return "center";
}
assert(false);
// FIXME: without this "styled_widget reaches end of non-void function" in release
// mode
// FIXME: without this "styled_widget reaches end of non-void function" in release mode
throw "Control should not reach this point.";
}

View file

@ -15,8 +15,8 @@
#ifndef GUI_WIDGETS_HELPER_HPP_INCLUDED
#define GUI_WIDGETS_HELPER_HPP_INCLUDED
#include "font/text.hpp"
#include "color.hpp"
#include "font/text.hpp"
#include <pango/pango-layout.h>
@ -24,7 +24,6 @@
#include <string>
struct SDL_Rect;
class surface;
class t_string;
namespace wfl
@ -34,7 +33,6 @@ class map_formula_callable;
namespace gui2
{
struct point;
/**
@ -58,7 +56,7 @@ SDL_Rect create_rect(const point& origin, const point& size);
/**
* Converts a color string to a color.
*
* @param color A color string see
* @param color A color string see
* http://www.wesnoth.org/wiki/GUIVariable for
* more info.
*
@ -80,7 +78,7 @@ PangoAlignment decode_text_alignment(const std::string& alignment);
/**
* Converts a text alignment to its string representation.
*
* @param alignment An alignment.
* @param alignment An alignment.
*
* @returns An alignment string see
* http://www.wesnoth.org/wiki/GUIVariable for