16 #define GETTEXT_DOMAIN "wesnoth-lib"
18 #include "widgets/button.hpp"
32 #include <boost/algorithm/string/predicate.hpp>
35 #define ERR_DP LOG_STREAM(err, log_display)
43 const bool auto_join, std::string overlay_image,
int font_size)
46 image_(nullptr), pressedImage_(nullptr), activeImage_(nullptr), pressedActiveImage_(nullptr),
47 disabledImage_(nullptr), pressedDisabledImage_(nullptr),
48 overlayImage_(nullptr), overlayPressedImage_(nullptr), overlayActiveImage_(nullptr),
49 state_(
NORMAL), pressed_(false),
50 spacing_(spacing), base_height_(0), base_width_(0),
51 button_image_name_(), button_overlay_image_name_(overlay_image),
52 button_image_path_suffix_(),
54 horizontal_padding_(font_size_),
55 checkbox_horizontal_padding_(font_size_ / 2),
56 vertical_padding_(font_size_ / 2)
58 if (button_image_name.empty()) {
86 std::string size_postfix;
178 std::string err_msg =
"error initializing button images! file name: ";
250 if (
state_ != new_state) {
312 SDL_Rect clipArea = loc;
313 const int texty = loc.y + loc.h / 2 -
textRect_.h / 2 + offset;
368 clipArea.x += offset;
369 clipArea.y += offset;
370 clipArea.w -= 2*offset;
371 clipArea.h -= 2*offset;
413 const std::vector<std::string>::const_iterator
i = std::find_if(items.begin(),items.end(),
is_valid_image);
414 if(
i != items.end()) {
425 if (
hit(event.x, event.y)) {
459 if (
hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT) {
487 if (!(
hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT))
548 case SDL_MOUSEBUTTONDOWN:
551 case SDL_MOUSEBUTTONUP:
554 case SDL_MOUSEMOTION:
562 if (start_state !=
state_) {
Wrapper class to encapsulate creation and management of an SDL_Texture.
int w() const
The draw-space width of the texture, in pixels.
void reset()
Releases ownership of the managed texture and resets the ptr to null.
int h() const
The draw-space height of the texture, in pixels.
Drawing functions, for drawing things on the screen.
Declarations for File-IO.
std::string label
What to show in the filter's drop-down list.
Standard logging facilities (interface).
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
static bool file_exists(const bfs::path &fpath)
const color_t BUTTON_COLOR
rect pango_draw_text(bool actually_draw, const rect &area, int size, const color_t &color, const std::string &text, int x, int y, bool use_tooltips, pango_text::FONT_STYLE style)
Draws text on the screen.
const std::string checkbox_release
const std::string button_press
const int default_font_size
static bool is_valid_image(const std::string &str)
Functions to load and save images from/to disk.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
constexpr const SDL_Rect empty_rect
void play_UI_sound(const std::string &files)
std::vector< std::string > split(const config_attribute_value &val)
Contains the SDL_Rect helper code.
Transitional API for porting SDL_ttf-based code to Pango.
The basic class for representing 8-bit RGB or RGBA colour values.
Base class for all the errors encountered by the engine.
bool contains(int x, int y) const
Whether the given point lies within the rectangle.
char const COLUMN_SEPARATOR