gui1: Use font::pango_draw_text()

This commit is contained in:
Iris Morelle 2021-03-09 00:09:05 -03:00
parent fbf7d055f2
commit 00c031d782
6 changed files with 14 additions and 10 deletions

View File

@ -22,6 +22,7 @@
#include "display.hpp"
#include "fake_unit_manager.hpp"
#include "font/sdl_ttf.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "font/text.hpp"
#include "preferences/game.hpp"
#include "gettext.hpp"
@ -1465,7 +1466,7 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
tooltips::add_tooltip(loc,text);
}
} else if(text.empty() == false) {
font::draw_text(&video,loc,label.font_size(),font::NORMAL_COLOR,text,loc.x,loc.y);
font::pango_draw_text(&video,loc,label.font_size(),font::NORMAL_COLOR,text,loc.x,loc.y);
}
}

View File

@ -18,6 +18,7 @@
#include "gettext.hpp"
#include "font/marked-up_text.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "font/standard_colors.hpp"
#include "tooltips.hpp"
@ -64,7 +65,7 @@ public:
if (state_.selected) {
sdl::draw_rectangle(location(), {255, 255, 255, 255});
}
font::draw_text(&video(), location(), 16, font::NORMAL_COLOR, desc_.empty() ? id_ : desc_, location().x + 2, location().y, 0);
font::pango_draw_text(&video(), location(), 16, font::NORMAL_COLOR, desc_.empty() ? id_ : desc_, location().x + 2, location().y, 0);
}
//TODO move to widget

View File

@ -25,6 +25,7 @@
#include "hotkey/command_executor.hpp"
#include "log.hpp"
#include "font/marked-up_text.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "font/standard_colors.hpp"
#include "sdl/rect.hpp"
@ -325,8 +326,8 @@ void dialog_frame::draw_background()
SDL_Rect dialog_frame::draw_title(CVideo* video)
{
SDL_Rect rect = CVideo::get_singleton().screen_area();
return font::draw_text(video, rect, font::SIZE_TITLE, font::TITLE_COLOR,
title_, dim_.title.x, dim_.title.y, false, TTF_STYLE_NORMAL);
return font::pango_draw_text(video, rect, font::SIZE_TITLE, font::TITLE_COLOR,
title_, dim_.title.x, dim_.title.y, false, font::pango_text::STYLE_NORMAL);
}
void dialog_frame::draw()

View File

@ -23,6 +23,7 @@
#include "picture.hpp"
#include "log.hpp"
#include "font/marked-up_text.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "font/standard_colors.hpp"
#include "sdl/rect.hpp"
#include "serialization/string_utils.hpp"
@ -227,8 +228,7 @@ void button::calculate_size()
}
if (type_ != TYPE_IMAGE){
textRect_ = font::draw_text(nullptr, video().screen_area(), font_size,
font::BUTTON_COLOR, label_text_, 0, 0);
textRect_ = font::pango_draw_text(nullptr, video().screen_area(), font_size, font::BUTTON_COLOR, label_text_, 0, 0);
}
// TODO: There's a weird text clipping bug, allowing the code below to run fixes it.
@ -382,7 +382,7 @@ void button::draw_contents()
clipArea.y += offset;
clipArea.w -= 2*offset;
clipArea.h -= 2*offset;
font::draw_text(&video(), clipArea, font_size, button_color, label_text_, textx, texty);
font::pango_draw_text(&video(), clipArea, font_size, button_color, label_text_, textx, texty);
}
}

View File

@ -22,6 +22,7 @@
#include "language.hpp"
#include "picture.hpp"
#include "font/marked-up_text.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "sdl/rect.hpp"
#include "sound.hpp"
#include "utils/general.hpp"
@ -811,7 +812,7 @@ SDL_Rect menu::style::item_size(const std::string& item) const {
else {
const SDL_Rect area {0,0,10000,10000};
const SDL_Rect font_size =
font::draw_text(nullptr,area,get_font_size(),font::NORMAL_COLOR,str,0,0);
font::pango_draw_text(nullptr,area,get_font_size(),font::NORMAL_COLOR,str,0,0);
res.w += font_size.w;
res.h = std::max<int>(font_size.h, res.h);
}
@ -984,7 +985,7 @@ void menu::draw_row(const std::size_t row_index, const SDL_Rect& rect, ROW_TYPE
const SDL_Rect& text_size = font::text_area(str,style_->get_font_size());
const std::size_t y = rect.y + (rect.h - text_size.h)/2;
const std::size_t padding = 2;
font::draw_text(&video(),column,style_->get_font_size(),font::NORMAL_COLOR,to_show,
font::pango_draw_text(&video(),column,style_->get_font_size(),font::NORMAL_COLOR,to_show,
(type == HEADING_ROW ? xpos+padding : xpos), y);
if(type == HEADING_ROW && sortby_ == int(i)) {

View File

@ -41,7 +41,7 @@ textbox::textbox(CVideo &video, int width, const std::string& text, bool editabl
,listening_(false)
{
// static const SDL_Rect area = video.screen_area();
// const int height = font::draw_text(nullptr,area,font_size,font::NORMAL_COLOR,"ABCD",0,0).h;
// const int height = font::pango_draw_text(nullptr,area,font_size,font::NORMAL_COLOR,"ABCD",0,0).h;
set_measurements(width, font::get_max_height(font_size_));
set_scroll_rate(font::get_max_height(font_size_) / 2);
update_text_cache(true);