more cleanup of deps against display
This commit is contained in:
parent
5f6343ee6e
commit
04ba5d8068
15 changed files with 40 additions and 31 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "display.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "video.hpp"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "dialogs.hpp"
|
||||
#include "font.hpp"
|
||||
#include "game_config.hpp"
|
||||
|
@ -758,7 +759,7 @@ void connect::layout_children(const SDL_Rect& rect)
|
|||
bottom-left_button->height()-gui::ButtonVPadding);
|
||||
|
||||
// Title and labels
|
||||
gui::draw_dialog_title(left,top,&disp().video(),_("Game Lobby"));
|
||||
gui::draw_dialog_title(left,top,&video(),_("Game Lobby"));
|
||||
|
||||
type_title_label_.set_location((left+30)+(launch_.width()/2)-(type_title_label_.width()/2),top+35);
|
||||
faction_title_label_.set_location((left+145)+(launch_.width()/2)-(faction_title_label_.width()/2),top+35);
|
||||
|
|
|
@ -123,9 +123,9 @@ surface get_video_surface()
|
|||
return frameBuffer;
|
||||
}
|
||||
|
||||
SDL_Rect screen_area()
|
||||
const SDL_Rect& screen_area()
|
||||
{
|
||||
const SDL_Rect res = {0,0,frameBuffer->w,frameBuffer->h};
|
||||
static const SDL_Rect res = {0,0,frameBuffer->w,frameBuffer->h};
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
surface display_format_alpha(surface surf);
|
||||
surface get_video_surface();
|
||||
SDL_Rect screen_area();
|
||||
const SDL_Rect& screen_area();
|
||||
|
||||
bool non_interactive();
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ button::button(display& disp, const std::string& label, button::TYPE type,
|
|||
|
||||
textRect_.x = 0;
|
||||
textRect_.y = 0;
|
||||
textRect_.w = disp.x();
|
||||
textRect_.h = disp.y();
|
||||
textRect_.w = video().getx();
|
||||
textRect_.h = video().gety();
|
||||
|
||||
textRect_ = font::draw_text(NULL,textRect_,font_size,
|
||||
font::BUTTON_COLOUR,label_,0,0);
|
||||
|
@ -172,7 +172,7 @@ void button::draw_contents()
|
|||
|
||||
disp().blit_surface(loc.x, loc.y, image);
|
||||
const std::string etext = font::make_text_ellipsis(label_, font_size, loc.w);
|
||||
font::draw_text(&disp().video(), clipArea, font_size, font::BUTTON_COLOUR, etext, textx, texty);
|
||||
font::draw_text(&video(), clipArea, font_size, font::BUTTON_COLOUR, etext, textx, texty);
|
||||
|
||||
update_rect(loc);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ void button::set_label(const std::string& val)
|
|||
}
|
||||
}
|
||||
|
||||
textRect_ = disp().screen_area();
|
||||
textRect_ = screen_area();
|
||||
const std::string etext = font::make_text_ellipsis(label_, font_size, width());
|
||||
textRect_ = font::draw_text(NULL,textRect_,font_size,
|
||||
font::BUTTON_COLOUR,etext,0,0);
|
||||
|
|
|
@ -20,6 +20,7 @@ class display;
|
|||
#include "../filesystem.hpp"
|
||||
#include "../font.hpp"
|
||||
#include "../gettext.hpp"
|
||||
#include "../key.hpp"
|
||||
#include "../show_dialog.hpp"
|
||||
#include "../wml_separators.hpp"
|
||||
#include "file_chooser.hpp"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "../global.hpp"
|
||||
|
||||
#include "label.hpp"
|
||||
#include "../display.hpp"
|
||||
#include "../font.hpp"
|
||||
#include "../video.hpp"
|
||||
|
||||
|
@ -68,7 +67,7 @@ const SDL_Color& label::get_colour() const
|
|||
|
||||
void label::draw_contents()
|
||||
{
|
||||
font::draw_text(&disp().video(), screen_area(), size_, colour_, text_, location().x, location().y);
|
||||
font::draw_text(&video(), screen_area(), size_, colour_, text_, location().x, location().y);
|
||||
}
|
||||
|
||||
void label::update_label_size()
|
||||
|
|
|
@ -171,7 +171,7 @@ size_t menu::max_items_onscreen() const
|
|||
return size_t(max_items_);
|
||||
}
|
||||
|
||||
const size_t max_height = max_height_ == -1 ? (disp().y()*66)/100 : max_height_;
|
||||
const size_t max_height = max_height_ == -1 ? (video().gety()*66)/100 : max_height_;
|
||||
std::vector<int> heights;
|
||||
size_t n;
|
||||
for(n = 0; n != items_.size(); ++n) {
|
||||
|
@ -397,9 +397,9 @@ void menu::draw_item(int item)
|
|||
gui::draw_solid_tinted_rectangle(rect.x, rect.y, rect.w, rect.h,
|
||||
item == selected_ ? 150:0,0,0,
|
||||
item == selected_ ? 0.6 : 0.2,
|
||||
disp().video().getSurface());
|
||||
video().getSurface());
|
||||
|
||||
SDL_Rect const &area = disp().screen_area();
|
||||
SDL_Rect const &area = screen_area();
|
||||
//SDL_Rect area = { 0, 0, rect.w, rect.h };
|
||||
SDL_Rect const &loc = inner_location();
|
||||
|
||||
|
@ -429,7 +429,7 @@ void menu::draw_item(int item)
|
|||
font::make_text_ellipsis(str, menu_font_size, loc.w - (xpos - rect.x)) : str;
|
||||
const SDL_Rect& text_size = font::text_area(str,menu_font_size);
|
||||
const size_t y = rect.y + (rect.h - text_size.h)/2;
|
||||
font::draw_text(&disp().video(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
|
||||
font::draw_text(&video(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
|
||||
xpos += text_size.w + 5;
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ SDL_Rect menu::get_item_rect(int item) const
|
|||
|
||||
SDL_Rect res = { loc.x, y, loc.w, get_item_height(item) };
|
||||
|
||||
SDL_Rect const &screen_area = disp().screen_area();
|
||||
SDL_Rect const &screen_area = ::screen_area();
|
||||
|
||||
if(res.x > screen_area.w) {
|
||||
return empty_rect;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "progressbar.hpp"
|
||||
|
||||
#include "../display.hpp"
|
||||
#include "../font.hpp"
|
||||
#include "../util.hpp"
|
||||
#include "../video.hpp"
|
||||
|
@ -20,7 +19,7 @@ void progress_bar::set_progress_percent(int progress)
|
|||
|
||||
void progress_bar::draw_contents()
|
||||
{
|
||||
surface const surf = disp().video().getSurface();
|
||||
surface const surf = video().getSurface();
|
||||
SDL_Rect area = location();
|
||||
|
||||
if(area.w >= 2 && area.h >= 2) {
|
||||
|
@ -37,7 +36,7 @@ void progress_bar::draw_contents()
|
|||
text_area.x = area.x + area.w/2 - text_area.w/2;
|
||||
text_area.y = area.y + area.h/2 - text_area.h/2;
|
||||
|
||||
font::draw_text(&disp().video(),location(),font::SIZE_NORMAL,font::BLACK_COLOUR,text,text_area.x,text_area.y);
|
||||
font::draw_text(&video(),location(),font::SIZE_NORMAL,font::BLACK_COLOUR,text,text_area.x,text_area.y);
|
||||
}
|
||||
|
||||
update_rect(location());
|
||||
|
|
|
@ -236,7 +236,7 @@ void scrollbar::draw_contents()
|
|||
return;
|
||||
}
|
||||
|
||||
surface const screen = disp().video().getSurface();
|
||||
surface const screen = video().getSurface();
|
||||
|
||||
// draw scrollbar "groove"
|
||||
disp().blit_surface(groove.x, groove.y, top_grv);
|
||||
|
|
|
@ -120,7 +120,7 @@ void slider::draw_contents()
|
|||
if (image->w >= loc.w)
|
||||
return;
|
||||
|
||||
surface const screen = disp().video().getSurface();
|
||||
surface const screen = video().getSurface();
|
||||
|
||||
SDL_Rect line_rect = { loc.x + image->w / 2, loc.y + loc.h / 2, loc.w - image->w, 1 };
|
||||
SDL_FillRect(screen, &line_rect, SDL_MapRGB(screen->format, 255, 255, 255));
|
||||
|
|
|
@ -109,11 +109,11 @@ void textbox::clear()
|
|||
update_text_cache(true);
|
||||
}
|
||||
|
||||
void textbox::draw_cursor(int pos, display &disp) const
|
||||
void textbox::draw_cursor(int pos, CVideo &video) const
|
||||
{
|
||||
if(show_cursor_ && editable_) {
|
||||
SDL_Rect rect = {location().x + pos, location().y, 1, location().h };
|
||||
surface const frame_buffer = disp.video().getSurface();
|
||||
surface const frame_buffer = video.getSurface();
|
||||
SDL_FillRect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ void textbox::draw_contents()
|
|||
{
|
||||
SDL_Rect const &loc = inner_location();
|
||||
|
||||
surface surf = disp().video().getSurface();
|
||||
surface surf = video().getSurface();
|
||||
gui::draw_solid_tinted_rectangle(loc.x,loc.y,loc.w,loc.h,0,0,0,
|
||||
focus() ? alpha_focus_ : alpha_, surf);
|
||||
|
||||
|
@ -133,7 +133,7 @@ void textbox::draw_contents()
|
|||
src.w = minimum<size_t>(loc.w,text_image_->w);
|
||||
src.h = minimum<size_t>(loc.h,text_image_->h);
|
||||
src.x = text_pos_;
|
||||
SDL_Rect dest = disp().screen_area();
|
||||
SDL_Rect dest = screen_area();
|
||||
dest.x = loc.x;
|
||||
dest.y = loc.y;
|
||||
|
||||
|
@ -167,7 +167,7 @@ void textbox::draw_contents()
|
|||
SDL_BlitSurface(text_image_, &src, surf, &dest);
|
||||
}
|
||||
|
||||
draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), disp());
|
||||
draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), video());
|
||||
|
||||
update_rect(loc);
|
||||
}
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
#ifndef TEXTBOX_HPP_INCLUDED
|
||||
#define TEXTBOX_HPP_INCLUDED
|
||||
|
||||
class display;
|
||||
|
||||
#include "../serialization/string_utils.hpp"
|
||||
#include "../sdl_utils.hpp"
|
||||
|
||||
#include "display.hpp"
|
||||
#include "scrollarea.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
|
@ -87,7 +88,7 @@ private:
|
|||
|
||||
void handle_event(const SDL_Event& event);
|
||||
|
||||
void draw_cursor(int pos, display &disp) const;
|
||||
void draw_cursor(int pos, CVideo &video) const;
|
||||
void update_text_cache(bool reset = false);
|
||||
surface add_text_line(const wide_string& text);
|
||||
bool is_selection();
|
||||
|
|
|
@ -29,6 +29,11 @@ widget::~widget()
|
|||
bg_cancel();
|
||||
}
|
||||
|
||||
// FIXME: we should move this into the header so that it can be
|
||||
// inlined, but that would currently create a
|
||||
// widget->display->button->widget include cycle
|
||||
CVideo& widget::video() const { return (disp_->video()); }
|
||||
|
||||
void widget::bg_cancel()
|
||||
{
|
||||
for(std::vector< surface_restorer >::iterator i = restorer_.begin(),
|
||||
|
@ -57,7 +62,7 @@ void widget::update_location(SDL_Rect const &rect)
|
|||
|
||||
void widget::bg_register(SDL_Rect const &rect)
|
||||
{
|
||||
restorer_.push_back(surface_restorer(&disp_->video(), rect));
|
||||
restorer_.push_back(surface_restorer(&video(), rect));
|
||||
}
|
||||
|
||||
void widget::set_location(int x, int y)
|
||||
|
@ -163,7 +168,7 @@ void widget::bg_restore() const
|
|||
{
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
clipper.assign(new clip_rect_setter(video().getSurface(), clip_rect_));
|
||||
|
||||
if (needs_restore_) {
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
|
@ -181,7 +186,7 @@ void widget::bg_restore(SDL_Rect const &rect) const
|
|||
{
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
clipper.assign(new clip_rect_setter(video().getSurface(), clip_rect_));
|
||||
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
|
@ -204,7 +209,7 @@ void widget::draw()
|
|||
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
clipper.assign(new clip_rect_setter(video().getSurface(), clip_rect_));
|
||||
|
||||
draw_contents();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CVideo;
|
||||
class display;
|
||||
|
||||
namespace gui {
|
||||
|
@ -65,6 +66,7 @@ protected:
|
|||
void bg_cancel();
|
||||
|
||||
display& disp() const { return *disp_; }
|
||||
CVideo& video() const;
|
||||
|
||||
virtual void handle_event(SDL_Event const &event) {}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue