Add some more debug domains in the gui area...
...(changes to log.?pp aren't committed).
This commit is contained in:
parent
67cf6cad9f
commit
f2b701c996
6 changed files with 169 additions and 101 deletions
|
@ -14,10 +14,25 @@
|
|||
|
||||
#include "gui/widgets/button.hpp"
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -47,69 +62,67 @@ void tbutton::set_height(const unsigned height)
|
|||
|
||||
void tbutton::mouse_down(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse down\n";
|
||||
DBG_G_E << "Button: left mouse button down.\n";
|
||||
|
||||
set_state(PRESSED);
|
||||
}
|
||||
|
||||
void tbutton::mouse_up(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse up\n";
|
||||
DBG_G_E << "Button: left mouse button up.\n";
|
||||
|
||||
set_state(FOCUSSED);
|
||||
}
|
||||
|
||||
void tbutton::mouse_click(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse click\n";
|
||||
DBG_G_E << "Button: left mouse button click.\n";
|
||||
}
|
||||
|
||||
void tbutton::mouse_double_click(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse double click\n";
|
||||
DBG_G_E << "Button: left mouse button double click.\n";
|
||||
}
|
||||
|
||||
void tbutton::mouse_enter(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse enter\n";
|
||||
DBG_G_E << "Button: mouse enter.\n";
|
||||
|
||||
set_state(FOCUSSED);
|
||||
}
|
||||
|
||||
void tbutton::mouse_leave(const tevent_info& /*event*/, bool& /*handled*/)
|
||||
{
|
||||
DBG_GUI << "mouse leave\n";
|
||||
DBG_G_E << "Button: mouse leave.\n";
|
||||
|
||||
set_state(ENABLED);
|
||||
}
|
||||
|
||||
void tbutton::draw(surface& canvas)
|
||||
{
|
||||
DBG_GUI << "Drawing button\n";
|
||||
|
||||
SDL_Rect rect = get_rect();
|
||||
switch(state_) {
|
||||
|
||||
case ENABLED :
|
||||
DBG_GUI << "Enabled.\n";
|
||||
DBG_G_D << "Button: drawing enabled state.\n";
|
||||
canvas_enabled_.draw(true);
|
||||
SDL_BlitSurface(canvas_enabled_.surf(), 0, canvas, &rect);
|
||||
break;
|
||||
|
||||
case DISABLED :
|
||||
DBG_GUI << "Disabled.\n";
|
||||
DBG_G_D << "Button: drawing disabled state.\n";
|
||||
canvas_disabled_.draw(true);
|
||||
SDL_BlitSurface(canvas_disabled_.surf(), 0, canvas, &rect);
|
||||
break;
|
||||
|
||||
case PRESSED :
|
||||
DBG_GUI << "Pressed.\n";
|
||||
DBG_G_D << "Button: drawing pressed state.\n";
|
||||
canvas_pressed_.draw(true);
|
||||
SDL_BlitSurface(canvas_pressed_.surf(), 0, canvas, &rect);
|
||||
break;
|
||||
|
||||
case FOCUSSED :
|
||||
DBG_GUI << "Focussed.\n";
|
||||
DBG_G_D << "Button: drawing focussed state.\n";
|
||||
canvas_focussed_.draw(true);
|
||||
SDL_BlitSurface(canvas_focussed_.surf(), 0, canvas, &rect);
|
||||
break;
|
||||
|
|
|
@ -27,10 +27,25 @@
|
|||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
static Uint32 decode_colour(const std::string& colour);
|
||||
|
||||
|
@ -81,9 +96,9 @@ void tcanvas::draw(const config& cfg)
|
|||
|
||||
void tcanvas::draw(const bool force)
|
||||
{
|
||||
log_scope2(widget, "Drawing canvas");
|
||||
log_scope2(gui_draw, "Canvas: drawing.");
|
||||
if(!dirty_ && !force) {
|
||||
DBG_GUI << "Nothing to do stop.\n";
|
||||
DBG_G_D << "Canvas: nothing to draw.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,24 +112,23 @@ void tcanvas::draw(const bool force)
|
|||
}
|
||||
#endif
|
||||
// instead we overwrite the entire thing for now
|
||||
DBG_GUI << "Create canvas.\n";
|
||||
DBG_G_D << "Canvas: create new empty canvas.\n";
|
||||
canvas_.assign(SDL_CreateRGBSurface(SDL_SWSURFACE, w_, h_, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000));
|
||||
|
||||
// draw items
|
||||
for(std::vector<tshape_ptr>::iterator itor =
|
||||
shapes_.begin(); itor != shapes_.end(); ++itor) {
|
||||
log_scope2(widget, "Draw shape");
|
||||
log_scope2(gui_draw, "Canvas: draw shape.");
|
||||
|
||||
(*itor)->draw(canvas_);
|
||||
}
|
||||
|
||||
DBG_GUI << "Ready.\n";
|
||||
dirty_ = false;
|
||||
}
|
||||
|
||||
void tcanvas::parse_cfg(const config& cfg)
|
||||
{
|
||||
log_scope2(widget, "Parsing config");
|
||||
log_scope2(gui_parse, "Canvas: parsing config.");
|
||||
shapes_.clear();
|
||||
|
||||
for(config::all_children_iterator itor =
|
||||
|
@ -123,7 +137,7 @@ void tcanvas::parse_cfg(const config& cfg)
|
|||
const std::string& type = *((*itor).first);;
|
||||
const vconfig data(&(*((*itor).second)));
|
||||
|
||||
DBG_GUI << "Found type " << type << '\n';
|
||||
DBG_G_P << "Canvas: found shape of the type " << type << ".\n";
|
||||
|
||||
if(type == "line") {
|
||||
shapes_.push_back(new tline(data));
|
||||
|
@ -134,7 +148,7 @@ void tcanvas::parse_cfg(const config& cfg)
|
|||
} else if(type == "text") {
|
||||
shapes_.push_back(new ttext(data));
|
||||
} else {
|
||||
ERR_GUI << "Type of shape is unknown : " << type << '\n';
|
||||
ERR_G_P << "Canvas: found a shape of an invalid type " << type << ".\n";
|
||||
assert(false); // FIXME remove in production code.
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +157,6 @@ void tcanvas::parse_cfg(const config& cfg)
|
|||
void tcanvas::tshape::put_pixel(unsigned start, Uint32 colour, unsigned w, unsigned x, unsigned y)
|
||||
{
|
||||
// fixme the 4 is true due to Uint32..
|
||||
// DBG_GUI << "Put pixel at x " << x << " y " << y << " w " << w << '\n';
|
||||
*reinterpret_cast<Uint32*>(start + (y * w * 4) + x * 4) = colour;
|
||||
}
|
||||
|
||||
|
@ -162,10 +175,10 @@ void tcanvas::tshape::draw_line(surface& canvas, Uint32 colour,
|
|||
unsigned start = reinterpret_cast<unsigned>(canvas->pixels);
|
||||
unsigned w = canvas->w;
|
||||
|
||||
DBG_GUI << "Draw line from :"
|
||||
DBG_G_D << "Shape: draw line from :"
|
||||
<< x1 << ',' << y1 << " to : " << x2 << ',' << y2
|
||||
<< " canvas width " << w << " canvas height "
|
||||
<< canvas->h << '\n';
|
||||
<< canvas->h << ".\n";
|
||||
|
||||
// use a special case for vertical lines
|
||||
if(x1 == x2) {
|
||||
|
@ -224,7 +237,6 @@ tcanvas::tline::tline(const int x1, const int y1, const int x2,
|
|||
colour_(colour),
|
||||
thickness_(thickness)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
tcanvas::tline::tline(const vconfig& cfg) :
|
||||
|
@ -261,14 +273,14 @@ tcanvas::tline::tline(const vconfig& cfg) :
|
|||
//
|
||||
const std::string& debug = (cfg["debug"]);
|
||||
if(!debug.empty()) {
|
||||
DBG_GUI << debug << '\n';
|
||||
DBG_G_P << "Line: found debug message '" << debug << "'.\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tcanvas::tline::draw(surface& canvas)
|
||||
{
|
||||
DBG_GUI << "Draw line from: "
|
||||
DBG_G_D << "Line: draw from :"
|
||||
<< x1_ << ',' << y1_ << " to: " << x2_ << ',' << y2_ << '\n';
|
||||
|
||||
// we wrap around the coordinates, this might be moved to be more
|
||||
|
@ -332,15 +344,14 @@ tcanvas::trectangle::trectangle(const vconfig& cfg) :
|
|||
|
||||
const std::string& debug = (cfg["debug"]);
|
||||
if(!debug.empty()) {
|
||||
DBG_GUI << debug << '\n';
|
||||
DBG_G_P << "Rectangle: found debug message '" << debug << "'.\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tcanvas::trectangle::draw(surface& canvas)
|
||||
{
|
||||
|
||||
DBG_GUI << "Draw rectangle from: " << rect_.x << ',' << rect_.y
|
||||
DBG_G_D << "Rectangle: draw from :" << rect_.x << ',' << rect_.y
|
||||
<< " width: " << rect_.w << " height: " << rect_.h << '\n';
|
||||
|
||||
surface_lock locker(canvas);
|
||||
|
@ -416,15 +427,13 @@ tcanvas::timage::timage(const vconfig& cfg) :
|
|||
|
||||
const std::string& debug = (cfg["debug"]);
|
||||
if(!debug.empty()) {
|
||||
DBG_GUI << debug << '\n';
|
||||
DBG_G_P << "Image: found debug message '" << debug << "'.\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tcanvas::timage::draw(surface& canvas)
|
||||
{
|
||||
|
||||
DBG_GUI << "Drawing image.\n";
|
||||
DBG_G_D << "Image: draw.\n";
|
||||
|
||||
SDL_Rect src_clip = src_clip_;
|
||||
SDL_Rect dst_clip = dst_clip_;
|
||||
|
@ -458,22 +467,24 @@ tcanvas::ttext::ttext(const vconfig& cfg) :
|
|||
|
||||
const std::string& debug = (cfg["debug"]);
|
||||
if(!debug.empty()) {
|
||||
DBG_GUI << debug << '\n';
|
||||
DBG_G_P << "Text: found debug message '" << debug << "'.\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tcanvas::ttext::draw(surface& canvas)
|
||||
{
|
||||
DBG_G_D << "Text: draw at " << x_ << ',' << y_ << " text '"
|
||||
<< text_ << "'.\n";
|
||||
|
||||
SDL_Color col = { (colour_ >> 24), (colour_ >> 16), (colour_ >> 8), colour_ };
|
||||
surface surf(font::get_rendered_text(text_, font_size_, col, TTF_STYLE_NORMAL));
|
||||
|
||||
if(surf->w > w_) {
|
||||
WRN_GUI << "Text to wide, will be clipped.\n";
|
||||
WRN_G_D << "Text: text is too wide for the canvas and will be clipped.\n";
|
||||
}
|
||||
|
||||
if(surf->h > h_) {
|
||||
WRN_GUI << "Text to high, will be clipped.\n";
|
||||
WRN_G_D << "Text: text is too high for the canvas and will be clipped.\n";
|
||||
}
|
||||
|
||||
unsigned x_off = (surf->w >= w_) ? 0 : ((w_ - surf->w) / 2);
|
||||
|
|
|
@ -32,10 +32,25 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -73,7 +88,7 @@ const std::string& get_id(const twindow_type window_type)
|
|||
|
||||
void load_settings()
|
||||
{
|
||||
LOG_GUI << "Init gui\n";
|
||||
LOG_G << "Setting: init gui.\n";
|
||||
|
||||
fill_window_types();
|
||||
|
||||
|
@ -87,7 +102,7 @@ void load_settings()
|
|||
scoped_istream stream = preprocess_file(filename);
|
||||
read(cfg, *stream);
|
||||
} catch(config::error&) {
|
||||
ERR_GUI << "Could not read file '" << filename << "'\n";
|
||||
ERR_G_P << "Setting: could not read file '" << filename << "'.\n";
|
||||
}
|
||||
|
||||
const config::child_list& gui_cfgs = cfg.get_children("gui");
|
||||
|
|
|
@ -23,10 +23,25 @@
|
|||
#include <cassert>
|
||||
#include <numeric>
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -130,8 +145,8 @@ void tsizer::add_child(twidget* widget, const unsigned row,
|
|||
// clear old child if any
|
||||
if(cell.widget()) {
|
||||
// free a child when overwriting it
|
||||
LOG_GUI << "Child '" << cell.id() << "' at cell '"
|
||||
<< row << "," << col << "' will be overwritten and is disposed\n";
|
||||
WRN_G << "Grid: child '" << cell.id()
|
||||
<< "' at cell '" << row << ',' << col << "' will be replaced.\n";
|
||||
delete cell.widget();
|
||||
}
|
||||
|
||||
|
@ -155,7 +170,7 @@ void tsizer::set_rows(const unsigned rows)
|
|||
}
|
||||
|
||||
if(!children_.empty()) {
|
||||
WRN_GUI << "Resizing a non-empty container may give unexpected problems\n";
|
||||
WRN_G << "Grid: resizing a non-empty grid may give unexpected problems.\n";
|
||||
}
|
||||
|
||||
rows_ = rows;
|
||||
|
@ -169,7 +184,7 @@ void tsizer::set_cols(const unsigned cols)
|
|||
}
|
||||
|
||||
if(!children_.empty()) {
|
||||
WRN_GUI << "Resizing a non-empty container may give unexpected problems\n";
|
||||
WRN_G << "Grid: resizing a non-empty grid may give unexpected problems.\n";
|
||||
}
|
||||
|
||||
cols_ = cols;
|
||||
|
@ -204,8 +219,6 @@ void tsizer::removed_child(const std::string& id, const bool find_all)
|
|||
|
||||
tpoint tsizer::get_best_size()
|
||||
{
|
||||
DBG_GUI << __FUNCTION__ << '\n';
|
||||
|
||||
std::vector<unsigned> best_col_width(cols_, 0);
|
||||
std::vector<unsigned> best_row_height(rows_, 0);
|
||||
|
||||
|
@ -227,11 +240,13 @@ tpoint tsizer::get_best_size()
|
|||
}
|
||||
|
||||
for(unsigned row = 0; row < rows_; ++row) {
|
||||
DBG_GUI << "Row " << row << ": " << best_row_height[row] << '\n';
|
||||
DBG_G << "Grid: the best height for row " << row
|
||||
<< " will be " << best_row_height[row] << ".\n";
|
||||
}
|
||||
|
||||
for(unsigned col = 0; col < cols_; ++col) {
|
||||
DBG_GUI << "Col " << col << ": " << best_col_width[col] << '\n';
|
||||
DBG_G << "Grid: the best width for col " << col
|
||||
<< " will be " << best_col_width[col] << ".\n";
|
||||
}
|
||||
|
||||
return tpoint(
|
||||
|
@ -242,8 +257,6 @@ tpoint tsizer::get_best_size()
|
|||
|
||||
void tsizer::set_best_size(const tpoint& origin)
|
||||
{
|
||||
DBG_GUI << __FUNCTION__ << '\n';
|
||||
|
||||
std::vector<unsigned> best_col_width(cols_, 0);
|
||||
std::vector<unsigned> best_row_height(rows_, 0);
|
||||
|
||||
|
@ -269,7 +282,8 @@ void tsizer::set_best_size(const tpoint& origin)
|
|||
for(unsigned row = 0; row < rows_; ++row) {
|
||||
for(unsigned col = 0; col < cols_; ++col) {
|
||||
|
||||
DBG_GUI << "Row : " << row << " col : " << col << " put at origin " << orig << '\n';
|
||||
DBG_G << "Grid: set widget at " << row
|
||||
<< ',' << col << " at origin " << orig << ".\n";
|
||||
|
||||
if(child(row, col).widget()) {
|
||||
child(row, col).widget()->set_best_size(orig);
|
||||
|
@ -285,33 +299,23 @@ void tsizer::set_best_size(const tpoint& origin)
|
|||
twidget* tsizer::get_widget(const tpoint& coordinate)
|
||||
{
|
||||
|
||||
DBG_GUI << "Find widget at " << coordinate << '\n';
|
||||
|
||||
//! FIXME we need to store the sizes, since this is quite
|
||||
//! pathatic.
|
||||
for(unsigned row = 0; row < rows_; ++row) {
|
||||
for(unsigned col = 0; col < cols_; ++col) {
|
||||
|
||||
DBG_GUI << "Row : " << row << " col : " << col;
|
||||
|
||||
twidget* widget = child(row, col).widget();
|
||||
if(!widget) {
|
||||
DBG_GUI << " no widget found.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
widget = widget->get_widget(coordinate);
|
||||
if(widget) {
|
||||
DBG_GUI << " hit!\n";
|
||||
return widget;
|
||||
}
|
||||
|
||||
DBG_GUI << " no hit.\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
DBG_GUI << "No widget found.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,26 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
|
||||
namespace gui2{
|
||||
|
||||
|
@ -56,7 +72,7 @@ twindow::twindow(CVideo& video,
|
|||
|
||||
void twindow::show(const bool restore, void* /*flip_function*/)
|
||||
{
|
||||
log_scope2(widget, "Starting drawing window");
|
||||
log_scope2(gui_draw, "Window: show.");
|
||||
|
||||
// Sanity
|
||||
if(status_ != NEW) {
|
||||
|
@ -88,7 +104,7 @@ void twindow::show(const bool restore, void* /*flip_function*/)
|
|||
if(dirty() || need_layout_) {
|
||||
const bool draw_foreground = need_layout_;
|
||||
if(need_layout_) {
|
||||
DBG_GUI << "Layout.\n";
|
||||
DBG_G << "Window: layout client area.\n";
|
||||
resolve_definition();
|
||||
layout(get_client_rect());
|
||||
|
||||
|
@ -110,7 +126,7 @@ void twindow::show(const bool restore, void* /*flip_function*/)
|
|||
continue;
|
||||
}
|
||||
|
||||
log_scope2(widget, "Draw child");
|
||||
log_scope2(gui_draw, "Window: draw child.");
|
||||
|
||||
itor->draw(screen);
|
||||
}
|
||||
|
@ -151,7 +167,7 @@ void twindow::layout(const SDL_Rect position)
|
|||
return;
|
||||
}
|
||||
|
||||
DBG_GUI << "Failed for best size, try minimum.\n";
|
||||
DBG_G << "Window: layout can't be set to best size, try minimum.\n";
|
||||
|
||||
// Implement the code.
|
||||
assert(false);
|
||||
|
@ -163,9 +179,6 @@ void twindow::layout(const SDL_Rect position)
|
|||
|
||||
void twindow::set_width(const unsigned width)
|
||||
{
|
||||
|
||||
DBG_GUI << "Setting width to " << width << '\n';
|
||||
|
||||
canvas_background_.set_width(width);
|
||||
canvas_foreground_.set_width(width);
|
||||
need_layout_ = true;
|
||||
|
@ -176,8 +189,6 @@ void twindow::set_width(const unsigned width)
|
|||
|
||||
void twindow::set_height(const unsigned height)
|
||||
{
|
||||
DBG_GUI << "Setting height to " << height << '\n';
|
||||
|
||||
canvas_background_.set_height(height);
|
||||
canvas_foreground_.set_height(height);
|
||||
need_layout_ = true;
|
||||
|
@ -191,7 +202,6 @@ void twindow::flip()
|
|||
// fixme we need to add the option to either call
|
||||
// video_.flip() or display.flip()
|
||||
video_.flip();
|
||||
|
||||
}
|
||||
|
||||
//! Implement events::handler::handle_event().
|
||||
|
@ -217,7 +227,6 @@ void twindow::handle_event(const SDL_Event& event)
|
|||
handle_event_resize(event);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! Handler for a mouse down.
|
||||
|
|
|
@ -24,11 +24,25 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#define DBG_GUI LOG_STREAM(debug, widget)
|
||||
#define LOG_GUI LOG_STREAM(info, widget)
|
||||
#define WRN_GUI LOG_STREAM(warn, widget)
|
||||
#define ERR_GUI LOG_STREAM(err, widget)
|
||||
#define DBG_G LOG_STREAM(debug, gui)
|
||||
#define LOG_G LOG_STREAM(info, gui)
|
||||
#define WRN_G LOG_STREAM(warn, gui)
|
||||
#define ERR_G LOG_STREAM(err, gui)
|
||||
|
||||
#define DBG_G_D LOG_STREAM(debug, gui_draw)
|
||||
#define LOG_G_D LOG_STREAM(info, gui_draw)
|
||||
#define WRN_G_D LOG_STREAM(warn, gui_draw)
|
||||
#define ERR_G_D LOG_STREAM(err, gui_draw)
|
||||
|
||||
#define DBG_G_E LOG_STREAM(debug, gui_event)
|
||||
#define LOG_G_E LOG_STREAM(info, gui_event)
|
||||
#define WRN_G_E LOG_STREAM(warn, gui_event)
|
||||
#define ERR_G_E LOG_STREAM(err, gui_event)
|
||||
|
||||
#define DBG_G_P LOG_STREAM(debug, gui_parse)
|
||||
#define LOG_G_P LOG_STREAM(info, gui_parse)
|
||||
#define WRN_G_P LOG_STREAM(warn, gui_parse)
|
||||
#define ERR_G_P LOG_STREAM(err, gui_parse)
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -57,7 +71,7 @@ twindow build(CVideo& video, const std::string& type)
|
|||
button->set_definition(def);
|
||||
window.add_child(button, x, y);
|
||||
|
||||
DBG_GUI << "Placed button '" << id << "' with defintion '"
|
||||
DBG_G << "Window builder: placed button '" << id << "' with defintion '"
|
||||
<< def << "' at " << x << ", " << y << '\n';
|
||||
|
||||
}
|
||||
|
@ -94,7 +108,7 @@ const std::string& twindow_builder::read(const config& cfg)
|
|||
VALIDATE(!id_.empty(), missing_mandatory_wml_key("window", "id"));
|
||||
VALIDATE(!description_.empty(), missing_mandatory_wml_key("window", "description"));
|
||||
|
||||
DBG_GUI << "Reading window " << id_ << '\n';
|
||||
DBG_G_P << "Window builder: reading data for window " << id_ << ".\n";
|
||||
|
||||
const config::child_list& cfgs = cfg.get_children("resolution");
|
||||
VALIDATE(!cfgs.empty(), _("No resolution defined."));
|
||||
|
@ -132,8 +146,8 @@ twindow_builder::tresolution::tresolution(const config& cfg) :
|
|||
* [/resolution]
|
||||
*/
|
||||
|
||||
DBG_GUI << "Parsing resolution "
|
||||
<< window_width << ", " << window_height << '\n';
|
||||
DBG_G_P << "Window builder: parsing resolution "
|
||||
<< window_width << ',' << window_height << '\n';
|
||||
|
||||
if(definition.empty()) {
|
||||
definition = "default";
|
||||
|
@ -174,7 +188,8 @@ twindow_builder::tresolution::tgrid::tgrid(const config* cfg) :
|
|||
|
||||
}
|
||||
|
||||
DBG_GUI << "Grid has " << rows << " rows and " << cols << " columns.\n";
|
||||
DBG_G_P << "Window builder: grid has "
|
||||
<< rows << " rows and " << cols << " columns.\n";
|
||||
}
|
||||
|
||||
twindow_builder::tresolution::tgrid::twidget::twidget(const config& cfg) :
|
||||
|
@ -186,7 +201,8 @@ twindow_builder::tresolution::tgrid::twidget::twidget(const config& cfg) :
|
|||
definition = "default";
|
||||
}
|
||||
|
||||
DBG_GUI << "Found button with id '" << id << "' and definition '" << definition << "'.\n";
|
||||
DBG_G_P << "Window builder: found button with id '"
|
||||
<< id << "' and definition '" << definition << "'.\n";
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue