15 #define GETTEXT_DOMAIN "wesnoth-lib" 32 #define ERR_DP LOG_STREAM(err, log_display) 33 #define ERR_G LOG_STREAM(err, lg::general) 70 SDL_GetMouseState(&mousex, &mousey);
72 pb_event.type = SDL_MOUSEMOTION;
73 pb_event.motion.state = 0;
74 pb_event.motion.x = mousex;
75 pb_event.motion.y = mousey;
76 pb_event.motion.xrel = 0;
77 pb_event.motion.yrel = 0;
78 SDL_PushEvent(&pb_event);
83 std::vector<button*>* buttons,
button* help_button) :
88 help_button_(help_button),
90 auto_restore_(auto_restore),
92 top_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-top.png")),
93 bot_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-bottom.png")),
94 left_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-left.png")),
95 right_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-right.png")),
96 top_left_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-topleft.png")),
97 bot_left_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-botleft.png")),
98 top_right_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-topright.png")),
99 bot_right_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-botright.png")),
100 bg_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-background.png")),
101 have_border_(top_ != nullptr && bot_ != nullptr && left_ != nullptr && right_ != nullptr),
116 return layout(rect.x, rect.y, rect.w, rect.h);
136 if (event.type == SDL_WINDOWEVENT) {
137 switch (event.window.event) {
138 case SDL_WINDOWEVENT_RESIZED:
139 case SDL_WINDOWEVENT_RESTORED:
140 case SDL_WINDOWEVENT_SHOWN:
141 case SDL_WINDOWEVENT_EXPOSED:
154 (*it)->set_dirty(
true);
167 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
168 padding = std::max<int>((**b).height() +
ButtonVPadding, padding);
184 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
203 w = std::max(w, std::max(
dim_.
title.w, static_cast<int>(buttons_width)));
209 bounds.x +=
left_->w;
211 bounds.w -=
left_->w;
224 }
else if(x + w > bounds.w) {
229 }
else if(y + h > bounds.h) {
257 if(top_image !=
nullptr) {
263 if(bot_image !=
nullptr) {
269 if(left_image !=
nullptr) {
275 if(right_image !=
nullptr) {
314 SDL_Rect src {0,0,0,0};
351 #ifdef OK_BUTTON_ON_RIGHT 354 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
355 (**b).set_location(buttons_area.x, buttons_area.y);
surface get_image(const image::locator &i_locator, TYPE type)
Caches and returns an image.
static const style preview_style
static const style default_style
void set_dirty(bool dirty=true)
const color_t TITLE_COLOR
bool is_in_dialog()
Is a dialog open?
std::vector< button * > * buttons_
surface_restorer * restorer_
static CVideo & get_singleton()
dialog_frame(CVideo &video, const std::string &title="", const style &dialog_style=default_style, bool auto_restore=true, std::vector< button *> *buttons=nullptr, button *help_button=nullptr)
surface scale_surface(const surface &surf, int w, int h)
Scale a surface using alpha-weighted modified bilinear filtering Note: causes artifacts with alpha gr...
void blit_surface(int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr)
Draws a surface directly onto the screen framebuffer.
surface get_surface_portion(const surface &src, SDL_Rect &area)
Get a portion of the screen.
surface & getSurface()
Returns a reference to the framebuffer.
const style & dialog_style_
int bottom_padding() const
dimension_measurements layout(int x, int y, int w, int h)
SDL_Rect draw_title(CVideo *video)
virtual void handle_event(const SDL_Event &)
surface blur_surface(const surface &surf, int depth)
Cross-fades a surface.
int get_max_height(int size)
static const int title_border_w
static lg::log_domain log_display("display")
static const style titlescreen_style
dimension_measurements dim_
void handle_window_event(const SDL_Event &event)
Contains the SDL_Rect helper code.
constexpr const SDL_Rect empty_rect
SDL_Rect draw_text(surface &dst, const SDL_Rect &area, int size, const color_t &color, const std::string &txt, int x, int y, bool use_tooltips, int style)
Function to draw text on a surface.
Functions to load and save images from/to disk.
Standard logging facilities (interface).
static const int title_border_h
static void reverse(lua_State *L, StkId from, StkId to)
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
SDL_Rect screen_area(bool as_pixels=true) const
Returns the current window renderer area, either in pixels or screen coordinates. ...
static const style message_style
std::string::const_iterator iterator