widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05863
[Merge] lp:~klaus-halfmann/widelands/bug-1395278-ui_basic into lp:widelands
Klaus Halfmann has proposed merging lp:~klaus-halfmann/widelands/bug-1395278-ui_basic into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~klaus-halfmann/widelands/bug-1395278-ui_basic/+merge/284948
--
Your team Widelands Developers is requested to review the proposed merge of lp:~klaus-halfmann/widelands/bug-1395278-ui_basic into lp:widelands.
=== modified file 'src/ui_basic/box.cc'
--- src/ui_basic/box.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/box.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006-2011, 2013 by the Widelands Development Team
+ * Copyright (C) 2003-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -39,14 +39,14 @@
:
Panel (parent, x, y, 0, 0),
- m_max_x (max_x ? max_x : g_gr->get_xres()),
- m_max_y (max_y ? max_y : g_gr->get_yres()),
+ max_x_ (max_x ? max_x : g_gr->get_xres()),
+ max_y_ (max_y ? max_y : g_gr->get_yres()),
- m_scrolling(false),
- m_scrollbar(nullptr),
- m_orientation(orientation),
- m_mindesiredbreadth(0),
- m_inner_spacing(inner_spacing)
+ scrolling_(false),
+ scrollbar_(nullptr),
+ orientation_(orientation),
+ mindesiredbreadth_(0),
+ inner_spacing_(inner_spacing)
{}
/**
@@ -59,10 +59,10 @@
*/
void Box::set_scrolling(bool scroll)
{
- if (scroll == m_scrolling)
+ if (scroll == scrolling_)
return;
- m_scrolling = scroll;
+ scrolling_ = scroll;
update_desired_size();
}
@@ -74,10 +74,10 @@
*/
void Box::set_min_desired_breadth(uint32_t min)
{
- if (min == m_mindesiredbreadth)
+ if (min == mindesiredbreadth_)
return;
- m_mindesiredbreadth = min;
+ mindesiredbreadth_ = min;
update_desired_size();
}
@@ -89,34 +89,34 @@
void Box::update_desired_size()
{
int totaldepth = 0;
- int maxbreadth = m_mindesiredbreadth;
+ int maxbreadth = mindesiredbreadth_;
- for (uint32_t idx = 0; idx < m_items.size(); ++idx) {
+ for (uint32_t idx = 0; idx < items_.size(); ++idx) {
int depth, breadth;
- get_item_desired_size(idx, &depth, &breadth);
+ get_itedesired_size_(idx, &depth, &breadth);
totaldepth += depth;
if (breadth > maxbreadth)
maxbreadth = breadth;
}
- if (!m_items.empty())
- totaldepth += (m_items.size() - 1) * m_inner_spacing;
+ if (!items_.empty())
+ totaldepth += (items_.size() - 1) * inner_spacing_;
- if (m_orientation == Horizontal) {
- if (totaldepth > m_max_x && m_scrolling) {
+ if (orientation_ == Horizontal) {
+ if (totaldepth > max_x_ && scrolling_) {
maxbreadth += Scrollbar::Size;
}
set_desired_size
- (std::min(totaldepth, m_max_x), // + get_lborder() + get_rborder(),
- std::min(maxbreadth, m_max_y)); // + get_tborder() + get_bborder());
+ (std::min(totaldepth, max_x_), // + get_lborder() + get_rborder(),
+ std::min(maxbreadth, max_y_)); // + get_tborder() + get_bborder());
} else {
- if (totaldepth > m_max_y && m_scrolling) {
+ if (totaldepth > max_y_ && scrolling_) {
maxbreadth += Scrollbar::Size;
}
set_desired_size
- (std::min(maxbreadth, m_max_x) + get_lborder() + get_rborder(),
- std::min(totaldepth, m_max_y) + get_tborder() + get_bborder());
+ (std::min(maxbreadth, max_x_) + get_lborder() + get_rborder(),
+ std::min(totaldepth, max_y_) + get_tborder() + get_bborder());
}
// This is not redundant, because even if all this does not change our
@@ -133,23 +133,23 @@
// First pass: compute the depth and adjust whether we have a scrollbar
int totaldepth = 0;
- for (size_t idx = 0; idx < m_items.size(); ++idx) {
+ for (size_t idx = 0; idx < items_.size(); ++idx) {
int depth, unused;
- get_item_desired_size(idx, &depth, &unused);
+ get_itedesired_size_(idx, &depth, &unused);
totaldepth += depth;
}
- if (!m_items.empty()) {
- totaldepth += (m_items.size() - 1) * m_inner_spacing;
+ if (!items_.empty()) {
+ totaldepth += (items_.size() - 1) * inner_spacing_;
}
bool needscrollbar = false;
- if (m_orientation == Horizontal) {
- if (totaldepth > m_max_x && m_scrolling) {
+ if (orientation_ == Horizontal) {
+ if (totaldepth > max_x_ && scrolling_) {
needscrollbar = true;
}
} else {
- if (totaldepth > m_max_y && m_scrolling) {
+ if (totaldepth > max_y_ && scrolling_) {
needscrollbar = true;
}
}
@@ -157,7 +157,7 @@
if (needscrollbar) {
int32_t sb_x, sb_y, sb_w, sb_h;
int32_t pagesize;
- if (m_orientation == Horizontal) {
+ if (orientation_ == Horizontal) {
sb_x = 0;
sb_y = get_inner_h() - Scrollbar::Size;
sb_w = get_inner_w();
@@ -170,38 +170,38 @@
sb_h = get_inner_h();
pagesize = get_inner_h() - Scrollbar::Size;
}
- if (m_scrollbar == nullptr) {
- m_scrollbar.reset(
- new Scrollbar(this, sb_x, sb_y, sb_w, sb_h, m_orientation == Horizontal));
- m_scrollbar->moved.connect(boost::bind(&Box::scrollbar_moved, this, _1));
+ if (scrollbar_ == nullptr) {
+ scrollbar_.reset(
+ new Scrollbar(this, sb_x, sb_y, sb_w, sb_h, orientation_ == Horizontal));
+ scrollbar_->moved.connect(boost::bind(&Box::scrollbar_moved, this, _1));
} else {
- m_scrollbar->set_pos(Point(sb_x, sb_y));
- m_scrollbar->set_size(sb_w, sb_h);
+ scrollbar_->set_pos(Point(sb_x, sb_y));
+ scrollbar_->set_size(sb_w, sb_h);
}
- m_scrollbar->set_steps(totaldepth - pagesize);
- m_scrollbar->set_singlestepsize(Scrollbar::Size);
- m_scrollbar->set_pagesize(pagesize);
+ scrollbar_->set_steps(totaldepth - pagesize);
+ scrollbar_->set_singlestepsize(Scrollbar::Size);
+ scrollbar_->set_pagesize(pagesize);
} else {
- m_scrollbar.reset();
+ scrollbar_.reset();
}
// Second pass: Count number of infinite spaces
int infspace_count = 0;
- for (size_t idx = 0; idx < m_items.size(); ++idx)
- if (m_items[idx].fillspace)
+ for (size_t idx = 0; idx < items_.size(); ++idx)
+ if (items_[idx].fillspace)
infspace_count++;
// Third pass: Distribute left over space to all infinite spaces. To
// avoid having some pixels left at the end due to rounding errors, we
// divide the remaining space by the number of remaining infinite
// spaces every time, and not just one.
- int max_depths = m_orientation == Horizontal ? get_inner_w() : get_inner_h();
- for (size_t idx = 0; idx < m_items.size(); ++idx)
- if (m_items[idx].fillspace) {
+ int max_depths = orientation_ == Horizontal ? get_inner_w() : get_inner_h();
+ for (size_t idx = 0; idx < items_.size(); ++idx)
+ if (items_[idx].fillspace) {
assert(infspace_count > 0);
- m_items[idx].assigned_var_depth =
+ items_[idx].assigned_var_depth =
(max_depths - totaldepth) / infspace_count;
- totaldepth += m_items[idx].assigned_var_depth;
+ totaldepth += items_[idx].assigned_var_depth;
infspace_count--;
}
@@ -211,26 +211,26 @@
void Box::update_positions()
{
- int32_t scrollpos = m_scrollbar ? m_scrollbar->get_scrollpos() : 0;
+ int32_t scrollpos = scrollbar_ ? scrollbar_->get_scrollpos() : 0;
uint32_t totaldepth = 0;
- uint32_t totalbreadth = m_orientation == Horizontal ? get_inner_h() : get_inner_w();
- if (m_scrollbar)
+ uint32_t totalbreadth = orientation_ == Horizontal ? get_inner_h() : get_inner_w();
+ if (scrollbar_)
totalbreadth -= Scrollbar::Size;
- for (uint32_t idx = 0; idx < m_items.size(); ++idx) {
+ for (uint32_t idx = 0; idx < items_.size(); ++idx) {
int depth, breadth;
- get_item_size(idx, &depth, &breadth);
+ get_itesize_(idx, &depth, &breadth);
- if (m_items[idx].type == Item::ItemPanel) {
- set_item_size
- (idx, depth, m_items[idx].u.panel.fullsize ?
+ if (items_[idx].type == Item::ItemPanel) {
+ set_itesize_
+ (idx, depth, items_[idx].u.panel.fullsize ?
totalbreadth : breadth);
- set_item_pos(idx, totaldepth - scrollpos);
+ set_itepos_(idx, totaldepth - scrollpos);
}
totaldepth += depth;
- totaldepth += m_inner_spacing;
+ totaldepth += inner_spacing_;
}
}
@@ -265,7 +265,7 @@
it.fillspace = fillspace;
it.assigned_var_depth = 0;
- m_items.push_back(it);
+ items_.push_back(it);
update_desired_size();
}
@@ -283,7 +283,7 @@
it.assigned_var_depth = 0;
it.fillspace = false;
- m_items.push_back(it);
+ items_.push_back(it);
update_desired_size();
}
@@ -301,7 +301,7 @@
it.assigned_var_depth = 0;
it.fillspace = true;
- m_items.push_back(it);
+ items_.push_back(it);
update_desired_size();
}
@@ -312,16 +312,16 @@
* item along the orientation axis, breadth is the size perpendicular
* to the orientation axis.
*/
-void Box::get_item_desired_size
+void Box::get_itedesired_size_
(uint32_t const idx, int* depth, int* breadth)
{
- assert(idx < m_items.size());
+ assert(idx < items_.size());
- const Item & it = m_items[idx];
+ const Item & it = items_[idx];
switch (it.type) {
case Item::ItemPanel:
- if (m_orientation == Horizontal) {
+ if (orientation_ == Horizontal) {
it.u.panel.panel->get_desired_size(depth, breadth);
} else {
it.u.panel.panel->get_desired_size(breadth, depth);
@@ -336,31 +336,31 @@
}
/**
- * Retrieve the given item's size. This differs from get_item_desired_size only
+ * Retrieve the given item's size. This differs from get_itedesired_size_ only
* for expanding items, at least for now.
*/
-void Box::get_item_size
+void Box::get_itesize_
(uint32_t const idx, int* depth, int* breadth)
{
- assert(idx < m_items.size());
-
- const Item & it = m_items[idx];
-
- get_item_desired_size(idx, depth, breadth);
+ assert(idx < items_.size());
+
+ const Item & it = items_[idx];
+
+ get_itedesired_size_(idx, depth, breadth);
depth += it.assigned_var_depth;
}
/**
* Set the given items actual size.
*/
-void Box::set_item_size(uint32_t idx, int depth, int breadth)
+void Box::set_itesize_(uint32_t idx, int depth, int breadth)
{
- assert(idx < m_items.size());
+ assert(idx < items_.size());
- const Item & it = m_items[idx];
+ const Item & it = items_[idx];
if (it.type == Item::ItemPanel) {
- if (m_orientation == Horizontal)
+ if (orientation_ == Horizontal)
it.u.panel.panel->set_size(depth, breadth);
else
it.u.panel.panel->set_size(breadth, depth);
@@ -372,17 +372,17 @@
* pos is the position relative to the parent in the direction of the
* orientation axis.
*/
-void Box::set_item_pos(uint32_t idx, int32_t pos)
+void Box::set_itepos_(uint32_t idx, int32_t pos)
{
- assert(idx < m_items.size());
+ assert(idx < items_.size());
- const Item & it = m_items[idx];
+ const Item & it = items_[idx];
switch (it.type) {
case Item::ItemPanel: {
int32_t breadth, maxbreadth;
- if (m_orientation == Horizontal) {
+ if (orientation_ == Horizontal) {
breadth = it.u.panel.panel->get_inner_h();
maxbreadth = get_inner_h();
} else {
@@ -404,9 +404,10 @@
break;
}
- if (m_orientation == Horizontal)
- it .u.panel.panel->set_pos(Point(pos, breadth));
- else it.u.panel.panel->set_pos(Point(breadth, pos));
+ if (orientation_ == Horizontal)
+ it.u.panel.panel->set_pos(Point(pos, breadth));
+ else
+ it.u.panel.panel->set_pos(Point(breadth, pos));
break;
}
=== modified file 'src/ui_basic/box.h'
--- src/ui_basic/box.h 2016-01-28 21:27:04 +0000
+++ src/ui_basic/box.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2003-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -49,7 +49,7 @@
void set_scrolling(bool scroll);
- int32_t get_nritems() const {return m_items.size();}
+ int32_t get_nritems() const {return items_.size();}
void add
(Panel * panel,
@@ -67,15 +67,15 @@
void update_desired_size() override;
private:
- void get_item_desired_size(uint32_t idx, int* depth, int* breadth);
- void get_item_size(uint32_t idx, int* depth, int* breadth);
- void set_item_size(uint32_t idx, int depth, int breadth);
- void set_item_pos(uint32_t idx, int32_t pos);
+ void get_itedesired_size_(uint32_t idx, int* depth, int* breadth);
+ void get_itesize_(uint32_t idx, int* depth, int* breadth);
+ void set_itesize_(uint32_t idx, int depth, int breadth);
+ void set_itepos_(uint32_t idx, int32_t pos);
void scrollbar_moved(int32_t);
void update_positions();
//don't resize beyond this size
- int m_max_x, m_max_y;
+ int max_x_, max_y_;
struct Item {
enum Type {
@@ -98,13 +98,13 @@
int assigned_var_depth;
};
- bool m_scrolling;
- std::unique_ptr<Scrollbar> m_scrollbar;
- uint32_t m_orientation;
- uint32_t m_mindesiredbreadth;
- uint32_t m_inner_spacing;
+ bool scrolling_;
+ std::unique_ptr<Scrollbar> scrollbar_;
+ uint32_t orientation_;
+ uint32_t mindesiredbreadth_;
+ uint32_t inner_spacing_;
- std::vector<Item> m_items;
+ std::vector<Item> items_;
};
}
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/button.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -42,18 +42,18 @@
bool const _enabled, bool const flat)
:
NamedPanel (parent, name, x, y, w, h, tooltip_text),
- m_highlighted (false),
- m_pressed (false),
- m_permpressed (false),
- m_enabled (_enabled),
- m_repeating (false),
- m_flat (flat),
- m_draw_flat_background(false),
- m_time_nextact (0),
- m_title (title_text),
- m_pic_background(bg_pic),
- m_pic_custom (nullptr),
- m_clr_down (229, 161, 2)
+ highlighted_ (false),
+ pressed_ (false),
+ permpressed_ (false),
+ enabled_ (_enabled),
+ repeating_ (false),
+ flat_ (flat),
+ draw_flat_background_(false),
+ time_nextact_ (0),
+ title_ (title_text),
+ pic_background_(bg_pic),
+ pic_custom_ (nullptr),
+ clr_down_ (229, 161, 2)
{
// Automatically resize for font height and give it a margin.
if (h < 1) {
@@ -74,18 +74,18 @@
bool const _enabled, bool const flat, const bool keep_image_size)
:
NamedPanel (parent, name, x, y, w, h, tooltip_text),
- m_highlighted (false),
- m_pressed (false),
- m_permpressed (false),
- m_enabled (_enabled),
- m_repeating (false),
- m_flat (flat),
- m_keep_image_size(keep_image_size),
- m_draw_flat_background(false),
- m_time_nextact (0),
- m_pic_background(bg_pic),
- m_pic_custom (fg_pic),
- m_clr_down (229, 161, 2)
+ highlighted_ (false),
+ pressed_ (false),
+ permpressed_ (false),
+ enabled_ (_enabled),
+ repeating_ (false),
+ flat_ (flat),
+ keep_image_size_(keep_image_size),
+ draw_flat_background_(false),
+ time_nextact_ (0),
+ pic_background_(bg_pic),
+ pic_custom_ (fg_pic),
+ clr_down_ (229, 161, 2)
{
set_thinks(false);
}
@@ -101,12 +101,12 @@
*/
void Button::set_pic(const Image* pic)
{
- m_title.clear();
+ title_.clear();
- if (m_pic_custom == pic)
+ if (pic_custom_ == pic)
return;
- m_pic_custom = pic;
+ pic_custom_ = pic;
}
@@ -114,11 +114,11 @@
* Set a text title for the Button
*/
void Button::set_title(const std::string & title) {
- if (m_title == title)
+ if (title_ == title)
return;
- m_pic_custom = nullptr;
- m_title = title;
+ pic_custom_ = nullptr;
+ title_ = title;
}
@@ -128,20 +128,20 @@
*/
void Button::set_enabled(bool const on)
{
- if (m_enabled == on)
+ if (enabled_ == on)
return;
// disabled buttons should look different...
if (on)
- m_enabled = true;
+ enabled_ = true;
else {
- if (m_pressed) {
- m_pressed = false;
+ if (pressed_) {
+ pressed_ = false;
set_thinks(false);
grab_mouse(false);
}
- m_enabled = false;
- m_highlighted = false;
+ enabled_ = false;
+ highlighted_ = false;
}
}
@@ -152,35 +152,35 @@
void Button::draw(RenderTarget & dst)
{
// Draw the background
- if (!m_flat || m_draw_flat_background) {
- assert(m_pic_background);
+ if (!flat_ || draw_flat_background_) {
+ assert(pic_background_);
dst.fill_rect(Rect(Point(0, 0), get_w(), get_h()), RGBAColor(0, 0, 0, 255));
- dst.tile(Rect(Point(0, 0), get_w(), get_h()), m_pic_background, Point(get_x(), get_y()));
+ dst.tile(Rect(Point(0, 0), get_w(), get_h()), pic_background_, Point(get_x(), get_y()));
}
- if (m_enabled && m_highlighted && !m_flat)
+ if (enabled_ && highlighted_ && !flat_)
dst.brighten_rect
(Rect(Point(0, 0), get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
// If we've got a picture, draw it centered
- if (m_pic_custom) {
- if (m_keep_image_size) {
- if (m_enabled) {
+ if (pic_custom_) {
+ if (keep_image_size_) {
+ if (enabled_) {
// ">> 1" is almost like "/ 2", but simpler for signed types (difference
// is that -1 >> 1 is -1 but -1 / 2 is 0).
dst.blit(
Point(
- (get_w() - static_cast<int32_t>(m_pic_custom->width())) >> 1,
- (get_h() - static_cast<int32_t>(m_pic_custom->height())) >> 1),
- m_pic_custom);
+ (get_w() - static_cast<int32_t>(pic_custom_->width())) >> 1,
+ (get_h() - static_cast<int32_t>(pic_custom_->height())) >> 1),
+ pic_custom_);
} else {
// ">> 1" is almost like "/ 2", but simpler for signed types (difference
// is that -1 >> 1 is -1 but -1 / 2 is 0).
dst.blit_monochrome(
Point(
- (get_w() - static_cast<int32_t>(m_pic_custom->width())) >> 1,
- (get_h() - static_cast<int32_t>(m_pic_custom->height())) >> 1),
- m_pic_custom,
+ (get_w() - static_cast<int32_t>(pic_custom_->width())) >> 1,
+ (get_h() - static_cast<int32_t>(pic_custom_->height())) >> 1),
+ pic_custom_,
RGBAColor(255, 255, 255, 127));
}
} else {
@@ -188,33 +188,33 @@
const int max_image_h = get_h() - 2 * kButtonImageMargin;
double image_scale =
std::min(1.,
- std::min(static_cast<double>(max_image_w) / m_pic_custom->width(),
- static_cast<double>(max_image_h) / m_pic_custom->height()));
- int blit_width = image_scale * m_pic_custom->width();
- int blit_height = image_scale * m_pic_custom->height();
+ std::min(static_cast<double>(max_image_w) / pic_custom_->width(),
+ static_cast<double>(max_image_h) / pic_custom_->height()));
+ int blit_width = image_scale * pic_custom_->width();
+ int blit_height = image_scale * pic_custom_->height();
- if (m_enabled) {
+ if (enabled_) {
dst.blitrect_scale(
Rect((get_w() - blit_width) / 2, (get_h() - blit_height) / 2, blit_width, blit_height),
- m_pic_custom,
- Rect(0, 0, m_pic_custom->width(), m_pic_custom->height()),
+ pic_custom_,
+ Rect(0, 0, pic_custom_->width(), pic_custom_->height()),
1.,
BlendMode::UseAlpha);
} else {
dst.blitrect_scale_monochrome(
Rect((get_w() - blit_width) / 2, (get_h() - blit_height) / 2, blit_width, blit_height),
- m_pic_custom,
- Rect(0, 0, m_pic_custom->width(), m_pic_custom->height()),
+ pic_custom_,
+ Rect(0, 0, pic_custom_->width(), pic_custom_->height()),
RGBAColor(255, 255, 255, 127));
}
}
- } else if (m_title.length()) {
+ } else if (title_.length()) {
// Otherwise draw title string centered
const Image* entry_text_im = UI::g_fh1->render(
- as_uifont(m_title,
+ as_uifont(title_,
UI_FONT_SIZE_SMALL,
- m_enabled ? UI_FONT_CLR_FG : UI_FONT_CLR_DISABLED));
+ enabled_ ? UI_FONT_CLR_FG : UI_FONT_CLR_DISABLED));
dst.blit(Point((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),
entry_text_im);
}
@@ -225,11 +225,11 @@
// stays pressed when it is pressed once
RGBAColor black(0, 0, 0, 255);
- // m_permpressed is true, we invert the behaviour on m_pressed
- bool draw_pressed = m_permpressed ? !(m_pressed && m_highlighted)
- : (m_pressed && m_highlighted);
+ // permpressed_ is true, we invert the behaviour on pressed_
+ bool draw_pressed = permpressed_ ? !(pressed_ && highlighted_)
+ : (pressed_ && highlighted_);
- if (!m_flat) {
+ if (!flat_) {
assert(2 <= get_w());
assert(2 <= get_h());
// button is a normal one, not flat
@@ -265,7 +265,7 @@
} else {
// Button is flat, do not draw borders, instead, if it is pressed, draw
// a box around it.
- if (m_enabled && m_highlighted)
+ if (enabled_ && highlighted_)
{
RGBAColor shade(100, 100, 100, 80);
dst.fill_rect(Rect(Point(0, 0), get_w(), 2), shade);
@@ -278,16 +278,16 @@
void Button::think()
{
- assert(m_repeating);
- assert(m_pressed);
+ assert(repeating_);
+ assert(pressed_);
Panel::think();
- if (m_highlighted) {
+ if (highlighted_) {
uint32_t const time = SDL_GetTicks();
- if (m_time_nextact <= time) {
- m_time_nextact += MOUSE_BUTTON_AUTOREPEAT_TICK; // schedule next tick
- if (m_time_nextact < time)
- m_time_nextact = time;
+ if (time_nextact_ <= time) {
+ time_nextact_ += MOUSE_BUTTON_AUTOREPEAT_TICK; // schedule next tick
+ if (time_nextact_ < time)
+ time_nextact_ = time;
play_click();
sigclicked();
clicked();
@@ -303,14 +303,14 @@
*/
void Button::handle_mousein(bool const inside)
{
- bool oldhl = m_highlighted;
-
- m_highlighted = inside && m_enabled;
-
- if (oldhl == m_highlighted)
+ bool oldhl = highlighted_;
+
+ highlighted_ = inside && enabled_;
+
+ if (oldhl == highlighted_)
return;
- if (m_highlighted)
+ if (highlighted_)
sigmousein();
else
sigmouseout();
@@ -324,11 +324,11 @@
if (btn != SDL_BUTTON_LEFT)
return false;
- if (m_enabled) {
+ if (enabled_) {
grab_mouse(true);
- m_pressed = true;
- if (m_repeating) {
- m_time_nextact =
+ pressed_ = true;
+ if (repeating_) {
+ time_nextact_ =
SDL_GetTicks() + MOUSE_BUTTON_AUTOREPEAT_DELAY;
set_thinks(true);
}
@@ -340,11 +340,11 @@
if (btn != SDL_BUTTON_LEFT)
return false;
- if (m_pressed) {
- m_pressed = false;
+ if (pressed_) {
+ pressed_ = false;
set_thinks(false);
grab_mouse(false);
- if (m_highlighted && m_enabled) {
+ if (highlighted_ && enabled_) {
play_click();
sigclicked();
clicked();
@@ -361,17 +361,17 @@
}
void Button::set_perm_pressed(bool state) {
- if (state != m_permpressed) {
- m_permpressed = state;
+ if (state != permpressed_) {
+ permpressed_ = state;
}
}
void Button::set_flat(bool flat) {
- m_flat = flat;
+ flat_ = flat;
}
void Button::set_draw_flat_background(bool set) {
- m_draw_flat_background = set;
+ draw_flat_background_ = set;
}
}
=== modified file 'src/ui_basic/button.h'
--- src/ui_basic/button.h 2016-01-28 05:24:34 +0000
+++ src/ui_basic/button.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -60,11 +60,11 @@
void set_pic(const Image* pic);
void set_title(const std::string &);
- const std::string & get_title() const {return m_title;}
+ const std::string & get_title() const {return title_;}
- bool enabled() const {return m_enabled;}
+ bool enabled() const {return enabled_;}
void set_enabled(bool on);
- void set_repeating(bool const on) {m_repeating = on;}
+ void set_repeating(bool const on) {repeating_ = on;}
bool is_snap_target() const override {return true;}
// Drawing and event handlers
@@ -78,7 +78,7 @@
// Set the permanently pressed state of the button
void set_perm_pressed(bool state);
- bool get_perm_pressed() const {return m_permpressed;}
+ bool get_perm_pressed() const {return permpressed_;}
// Set button to flat / not flat
void set_flat(bool flat);
@@ -92,23 +92,23 @@
protected:
virtual void clicked() {} /// Override this to react on the click.
- bool m_highlighted; // mouse is over the button
- bool m_pressed; // mouse is clicked over the button
- bool m_permpressed; // button should appear pressed
- bool m_enabled;
- bool m_repeating;
- bool m_flat;
- bool m_keep_image_size; // Keep image's original size and center it
- bool m_draw_flat_background;
-
- uint32_t m_time_nextact;
-
- std::string m_title; // title string used when _mypic == 0
-
- const Image* m_pic_background; // background texture (picture ID)
- const Image* m_pic_custom; // custom icon on the button
-
- RGBColor m_clr_down; // color of border while a flat button is "down"
+ bool highlighted_; // mouse is over the button
+ bool pressed_; // mouse is clicked over the button
+ bool permpressed_; // button should appear pressed
+ bool enabled_;
+ bool repeating_;
+ bool flat_;
+ bool keep_image_size_; // Keep image's original size and center it
+ bool draw_flat_background_;
+
+ uint32_t time_nextact_;
+
+ std::string title_; // title string used when _mypic == 0
+
+ const Image* pic_background_; // background texture (picture ID)
+ const Image* pic_custom_; // custom icon on the button
+
+ RGBColor clr_down_; // color of border while a flat button is "down"
};
} // namespace UI
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/checkbox.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -39,7 +39,7 @@
const std::string & tooltip_text)
:
Panel (parent, p.x, p.y, kStateboxSize, kStateboxSize, tooltip_text),
- m_flags(Is_Enabled),
+ flags_(Is_Enabled),
rendered_text_(nullptr)
{
uint16_t w = pic->width();
@@ -47,8 +47,8 @@
set_desired_size(w, h);
set_size(w, h);
- set_flags(Has_Custom_Picture, true);
- m_pic_graphics = pic;
+ set_flags(Has_CustoPicture_, true);
+ pic_graphics_ = pic;
}
Statebox::Statebox
@@ -59,17 +59,17 @@
uint32_t width)
:
Panel (parent, p.x, p.y, kStateboxSize, kStateboxSize, tooltip_text),
- m_flags(Is_Enabled),
+ flags_(Is_Enabled),
rendered_text_(
label_text.empty() ?
nullptr :
UI::g_fh1->render(as_uifont(label_text),
width > (kStateboxSize + kPadding) ? width - kStateboxSize - kPadding : 0))
{
- m_pic_graphics = g_gr->images().get("images/ui_basic/checkbox_light.png");
+ pic_graphics_ = g_gr->images().get("images/ui_basic/checkbox_light.png");
if (rendered_text_) {
- int w = rendered_text_->width() + kPadding + m_pic_graphics->width() / 2;
- int h = std::max(rendered_text_->height(), m_pic_graphics->height());
+ int w = rendered_text_->width() + kPadding + pic_graphics_->width() / 2;
+ int h = std::max(rendered_text_->height(), pic_graphics_->height());
set_desired_size(w, h);
set_size(w, h);
}
@@ -88,17 +88,17 @@
*/
void Statebox::set_enabled(bool const enabled)
{
- if (((m_flags & Is_Enabled) > 1) && enabled)
+ if (((flags_ & Is_Enabled) > 1) && enabled)
return;
set_flags(Is_Enabled, enabled);
- if (!(m_flags & Has_Custom_Picture)) {
- m_pic_graphics = g_gr->images().get(enabled ?
+ if (!(flags_ & Has_CustoPicture_)) {
+ pic_graphics_ = g_gr->images().get(enabled ?
"images/ui_basic/checkbox_light.png" :
"images/ui_basic/checkbox.png");
set_flags
- (Is_Highlighted, (m_flags & Is_Highlighted) && (m_flags & Is_Enabled));
+ (Is_Highlighted, (flags_ & Is_Highlighted) && (flags_ & Is_Enabled));
}
}
@@ -109,7 +109,7 @@
* Args: on true if the checkbox should be checked
*/
void Statebox::set_state(bool const on) {
- if (on ^ ((m_flags & Is_Checked) > 1)) {
+ if (on ^ ((flags_ & Is_Checked) > 1)) {
set_flags(Is_Checked, on);
changed();
changedto(on);
@@ -122,17 +122,17 @@
*/
void Statebox::draw(RenderTarget & dst)
{
- if (m_flags & Has_Custom_Picture) {
+ if (flags_ & Has_CustoPicture_) {
// center picture
- const uint16_t w = m_pic_graphics->width();
- const uint16_t h = m_pic_graphics->height();
-
- dst.blit(Point((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), m_pic_graphics);
-
- if (m_flags & Is_Checked) {
+ const uint16_t w = pic_graphics_->width();
+ const uint16_t h = pic_graphics_->height();
+
+ dst.blit(Point((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), pic_graphics_);
+
+ if (flags_ & Is_Checked) {
dst.draw_rect
(Rect(Point(0, 0), get_w(), get_h()), RGBColor(229, 116, 2));
- } else if (m_flags & Is_Highlighted) {
+ } else if (flags_ & Is_Highlighted) {
dst.draw_rect
(Rect(Point(0, 0), get_w(), get_h()), RGBColor(100, 100, 80));
}
@@ -153,12 +153,12 @@
dst.blitrect
(image_anchor,
- m_pic_graphics,
+ pic_graphics_,
Rect
- (Point(m_flags & Is_Checked ? kStateboxSize : 0, 0),
+ (Point(flags_ & Is_Checked ? kStateboxSize : 0, 0),
kStateboxSize, kStateboxSize));
- if (m_flags & Is_Highlighted)
+ if (flags_ & Is_Highlighted)
dst.draw_rect
(Rect(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));
}
@@ -169,7 +169,7 @@
* Highlight the checkbox when the mouse moves into it
*/
void Statebox::handle_mousein(bool const inside) {
- set_flags(Is_Highlighted, inside && (m_flags & Is_Enabled));
+ set_flags(Is_Highlighted, inside && (flags_ & Is_Enabled));
}
@@ -177,11 +177,11 @@
* Left-click: Toggle checkbox state
*/
bool Statebox::handle_mousepress(const uint8_t btn, int32_t, int32_t) {
- if (btn == SDL_BUTTON_LEFT && (m_flags & Is_Enabled)) {
+ if (btn == SDL_BUTTON_LEFT && (flags_ & Is_Enabled)) {
clicked();
return true;
- } else
- return false;
+ }
+ return false;
}
bool Statebox::handle_mouserelease(const uint8_t btn, int32_t, int32_t)
{
=== modified file 'src/ui_basic/checkbox.h'
--- src/ui_basic/checkbox.h 2015-10-10 11:47:22 +0000
+++ src/ui_basic/checkbox.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2008-2011 by the Widelands Development Team
+ * Copyright (C) 2004-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -63,12 +63,12 @@
void set_enabled(bool enabled);
- bool get_state() const {return m_flags & Is_Checked;}
+ bool get_state() const {return flags_ & Is_Checked;}
void set_state(bool on);
- void set_owns_custom_picture() {
- assert(m_flags & Has_Custom_Picture);
- set_flags(Owns_Custom_Picture, true);
+ void set_owns_custopicture_() {
+ assert(flags_ & Has_CustoPicture_);
+ set_flags(Owns_CustoPicture_, true);
}
// Drawing and event handlers
@@ -86,16 +86,16 @@
Is_Highlighted = 0x01,
Is_Enabled = 0x02,
Is_Checked = 0x04,
- Has_Custom_Picture = 0x08,
- Owns_Custom_Picture = 0x10
+ Has_CustoPicture_ = 0x08,
+ Owns_CustoPicture_ = 0x10
};
- uint8_t m_flags;
+ uint8_t flags_;
void set_flags(uint8_t const flags, bool const enable) {
- m_flags &= ~flags;
+ flags_ &= ~flags;
if (enable)
- m_flags |= flags;
+ flags_ |= flags;
}
- const Image* m_pic_graphics;
+ const Image* pic_graphics_;
const Image* rendered_text_;
};
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/editbox.cc 2016-02-03 18:13:14 +0000
@@ -48,7 +48,7 @@
*/
/*@{*/
std::string fontname;
- uint32_t fontsize;
+ uint32_t fontsize;
/*@}*/
/// Background tile style.
@@ -77,22 +77,22 @@
int font_size)
:
Panel(parent, x, y, w, UI::g_fh1->render(as_uifont("."), font_size)->height() + 2),
- m(new EditBoxImpl),
- m_history_active(false),
- m_history_position(-1)
+ m_(new EditBoxImpl),
+ history_active_(false),
+ history_position_(-1)
{
set_thinks(false);
- m->background = background;
- m->fontname = UI::g_fh1->fontset().serif();
- m->fontsize = font_size;
+ m_->background = background;
+ m_->fontname = UI::g_fh1->fontset().serif();
+ m_->fontsize = font_size;
// Set alignment to the UI language's principal writing direction
- m->align = UI::g_fh1->fontset().is_rtl() ? UI::Align::kCenterRight : UI::Align::kCenterLeft;
- m->caret = 0;
- m->scrolloffset = 0;
+ m_->align = UI::g_fh1->fontset().is_rtl() ? UI::Align::kCenterRight : UI::Align::kCenterLeft;
+ m_->caret = 0;
+ m_->scrolloffset = 0;
// yes, use *signed* max as maximum length; just a small safe-guard.
- m->maxLength = std::numeric_limits<int32_t>::max();
+ m_->maxLength = std::numeric_limits<int32_t>::max();
set_handle_mouse(true);
set_can_focus(true);
@@ -100,7 +100,7 @@
// Initialize history as empty string
for (uint8_t i = 0; i < CHAT_HISTORY_SIZE; ++i)
- m_history[i] = "";
+ history_[i] = "";
}
EditBox::~EditBox()
@@ -113,7 +113,7 @@
*/
const std::string & EditBox::text() const
{
- return m->text;
+ return m_->text;
}
/**
@@ -124,16 +124,16 @@
*/
void EditBox::set_text(const std::string & t)
{
- if (t == m->text)
+ if (t == m_->text)
return;
- bool caretatend = m->caret == m->text.size();
+ bool caretatend = m_->caret == m_->text.size();
- m->text = t;
- if (m->text.size() > m->maxLength)
- m->text.erase(m->text.begin() + m->maxLength, m->text.end());
- if (caretatend || m->caret > m->text.size())
- m->caret = m->text.size();
+ m_->text = t;
+ if (m_->text.size() > m_->maxLength)
+ m_->text.erase(m_->text.begin() + m_->maxLength, m_->text.end());
+ if (caretatend || m_->caret > m_->text.size())
+ m_->caret = m_->text.size();
}
@@ -142,7 +142,7 @@
*/
uint32_t EditBox::max_length() const
{
- return m->maxLength;
+ return m_->maxLength;
}
@@ -154,12 +154,12 @@
*/
void EditBox::set_max_length(uint32_t const n)
{
- m->maxLength = n;
+ m_->maxLength = n;
- if (m->text.size() > m->maxLength) {
- m->text.erase(m->text.begin() + m->maxLength, m->text.end());
- if (m->caret > m->text.size())
- m->caret = m->text.size();
+ if (m_->text.size() > m_->maxLength) {
+ m_->text.erase(m_->text.begin() + m_->maxLength, m_->text.end());
+ if (m_->caret > m_->text.size())
+ m_->caret = m_->text.size();
check_caret();
}
@@ -204,12 +204,12 @@
case SDLK_KP_ENTER:
case SDLK_RETURN:
// Save history if active and text is not empty
- if (m_history_active) {
- if (!m->text.empty()) {
+ if (history_active_) {
+ if (!m_->text.empty()) {
for (uint8_t i = CHAT_HISTORY_SIZE - 1; i > 0; --i)
- m_history[i] = m_history[i - 1];
- m_history[0] = m->text;
- m_history_position = -1;
+ history_[i] = history_[i - 1];
+ history_[0] = m_->text;
+ history_position_ = -1;
}
}
ok();
@@ -221,17 +221,17 @@
}
/* no break */
case SDLK_DELETE:
- if (m->caret < m->text.size()) {
- while ((m->text[++m->caret] & 0xc0) == 0x80) {};
+ if (m_->caret < m_->text.size()) {
+ while ((m_->text[++m_->caret] & 0xc0) == 0x80) {};
// now handle it like Backspace
} else
return true;
/* no break */
case SDLK_BACKSPACE:
- if (m->caret > 0) {
- while ((m->text[--m->caret] & 0xc0) == 0x80)
- m->text.erase(m->text.begin() + m->caret);
- m->text.erase(m->text.begin() + m->caret);
+ if (m_->caret > 0) {
+ while ((m_->text[--m_->caret] & 0xc0) == 0x80)
+ m_->text.erase(m_->text.begin() + m_->caret);
+ m_->text.erase(m_->text.begin() + m_->caret);
check_caret();
changed();
}
@@ -243,11 +243,11 @@
}
/* no break */
case SDLK_LEFT:
- if (m->caret > 0) {
- while ((m->text[--m->caret] & 0xc0) == 0x80) {};
+ if (m_->caret > 0) {
+ while ((m_->text[--m_->caret] & 0xc0) == 0x80) {};
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
- for (uint32_t new_caret = m->caret;; m->caret = new_caret)
- if (0 == new_caret || isspace(m->text[--new_caret]))
+ for (uint32_t new_caret = m_->caret;; m_->caret = new_caret)
+ if (0 == new_caret || isspace(m_->text[--new_caret]))
break;
check_caret();
@@ -260,16 +260,16 @@
}
/* no break */
case SDLK_RIGHT:
- if (m->caret < m->text.size()) {
- while ((m->text[++m->caret] & 0xc0) == 0x80) {};
+ if (m_->caret < m_->text.size()) {
+ while ((m_->text[++m_->caret] & 0xc0) == 0x80) {};
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
- for (uint32_t new_caret = m->caret;; ++new_caret)
+ for (uint32_t new_caret = m_->caret;; ++new_caret)
if
- (new_caret == m->text.size()
+ (new_caret == m_->text.size()
||
- isspace(m->text[new_caret - 1]))
+ isspace(m_->text[new_caret - 1]))
{
- m->caret = new_caret;
+ m_->caret = new_caret;
break;
}
@@ -283,8 +283,8 @@
}
/* no break */
case SDLK_HOME:
- if (m->caret != 0) {
- m->caret = 0;
+ if (m_->caret != 0) {
+ m_->caret = 0;
check_caret();
}
@@ -296,8 +296,8 @@
}
/* no break */
case SDLK_END:
- if (m->caret != m->text.size()) {
- m->caret = m->text.size();
+ if (m_->caret != m_->text.size()) {
+ m_->caret = m_->text.size();
check_caret();
}
return true;
@@ -309,12 +309,12 @@
/* no break */
case SDLK_UP:
// Load entry from history if active and text is not empty
- if (m_history_active) {
- if (m_history_position > CHAT_HISTORY_SIZE - 2)
- m_history_position = CHAT_HISTORY_SIZE - 2;
- if (m_history[++m_history_position].size() > 0) {
- m->text = m_history[m_history_position];
- m->caret = m->text.size();
+ if (history_active_) {
+ if (history_position_ > CHAT_HISTORY_SIZE - 2)
+ history_position_ = CHAT_HISTORY_SIZE - 2;
+ if (history_[++history_position_].size() > 0) {
+ m_->text = history_[history_position_];
+ m_->caret = m_->text.size();
check_caret();
}
}
@@ -327,12 +327,12 @@
/* no break */
case SDLK_DOWN:
// Load entry from history if active and text is not equivalent to the current one
- if (m_history_active) {
- if (m_history_position < 1)
- m_history_position = 1;
- if (m_history[--m_history_position] != m->text) {
- m->text = m_history[m_history_position];
- m->caret = m->text.size();
+ if (history_active_) {
+ if (history_position_ < 1)
+ history_position_ = 1;
+ if (history_[--history_position_] != m_->text) {
+ m_->text = history_[history_position_];
+ m_->caret = m_->text.size();
check_caret();
}
}
@@ -347,9 +347,9 @@
}
bool EditBox::handle_textinput(const std::string& input_text) {
- if ((m->text.size() + input_text.length()) < m->maxLength) {
- m->text.insert(m->caret, input_text);
- m->caret += input_text.length();
+ if ((m_->text.size() + input_text.length()) < m_->maxLength) {
+ m_->text.insert(m_->caret, input_text);
+ m_->caret += input_text.length();
check_caret();
changed();
}
@@ -363,7 +363,7 @@
// Draw the background
dst.tile
(Rect(Point(0, 0), get_w(), get_h()),
- m->background,
+ m_->background,
Point(get_x(), get_y()));
// Draw border.
@@ -393,18 +393,18 @@
const int max_width = get_w() - 2 * kMargin;
- const Image* entry_text_im = UI::g_fh1->render(as_editorfont(m->text, m->fontsize));
+ const Image* entry_text_im = UI::g_fh1->render(as_editorfont(m_->text, m_->fontsize));
int linewidth = entry_text_im->width();
int lineheight = entry_text_im->height();
Point point(kMargin, get_h() / 2);
- if (static_cast<int>(m->align & UI::Align::kRight)) {
+ if (static_cast<int>(m_->align & UI::Align::kRight)) {
point.x += max_width;
}
- UI::correct_for_align(m->align, linewidth, lineheight, &point);
+ UI::correct_for_align(m_->align, linewidth, lineheight, &point);
// Crop to max_width while blitting
if (max_width < linewidth) {
@@ -413,22 +413,22 @@
point.x = 0;
}
// We want this always on, e.g. for mixed language savegame filenames
- if (i18n::has_rtl_character(m->text.c_str(), 100)) { // Restrict check for efficiency
+ if (i18n::has_rtl_character(m_->text.c_str(), 100)) { // Restrict check for efficiency
// TODO(GunChleoc): Arabic: Fix scrolloffset
dst.blitrect(point,
entry_text_im,
Rect(linewidth - max_width, 0, linewidth, lineheight));
}
else {
- if (static_cast<int>(m->align & UI::Align::kRight)) {
+ if (static_cast<int>(m_->align & UI::Align::kRight)) {
// TODO(GunChleoc): Arabic: Fix scrolloffset
dst.blitrect(point,
entry_text_im,
- Rect(point.x + m->scrolloffset + kMargin, point.y, max_width, lineheight));
+ Rect(point.x + m_->scrolloffset + kMargin, point.y, max_width, lineheight));
} else {
dst.blitrect(point,
entry_text_im,
- Rect(point.x - m->scrolloffset - kMargin, point.y, max_width, lineheight));
+ Rect(point.x - m_->scrolloffset - kMargin, point.y, max_width, lineheight));
}
}
} else {
@@ -437,15 +437,15 @@
if (has_focus()) {
// Draw the caret
- std::string line_to_caret = m->text.substr(0, m->caret);
+ std::string line_to_caret = m_->text.substr(0, m_->caret);
// TODO(GunChleoc): Arabic: Fix cursor position for BIDI text.
- int caret_x = text_width(line_to_caret, m->fontsize);
+ int caret_x = text_width(line_to_caret, m_->fontsize);
- const uint16_t fontheight = text_height(m->text, m->fontsize);
+ const uint16_t fontheight = text_height(m_->text, m_->fontsize);
const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
Point caretpt;
- caretpt.x = point.x + m->scrolloffset + caret_x - caret_image->width() + LINE_MARGIN;
+ caretpt.x = point.x + m_->scrolloffset + caret_x - caret_image->width() + LINE_MARGIN;
caretpt.y = point.y + (fontheight - caret_image->height()) / 2;
dst.blit(caretpt, caret_image);
}
@@ -456,33 +456,33 @@
*/
void EditBox::check_caret()
{
- std::string leftstr(m->text, 0, m->caret);
- std::string rightstr(m->text, m->caret, std::string::npos);
- int32_t leftw = text_width(leftstr, m->fontsize);
- int32_t rightw = text_width(rightstr, m->fontsize);
+ std::string leftstr(m_->text, 0, m_->caret);
+ std::string rightstr(m_->text, m_->caret, std::string::npos);
+ int32_t leftw = text_width(leftstr, m_->fontsize);
+ int32_t rightw = text_width(rightstr, m_->fontsize);
int32_t caretpos;
- switch (m->align & UI::Align::kHorizontal) {
+ switch (m_->align & UI::Align::kHorizontal) {
case UI::Align::kRight:
- caretpos = get_w() - kMargin + m->scrolloffset - rightw;
+ caretpos = get_w() - kMargin + m_->scrolloffset - rightw;
break;
default:
- caretpos = kMargin + m->scrolloffset + leftw;
+ caretpos = kMargin + m_->scrolloffset + leftw;
break;
}
if (caretpos < kMargin)
- m->scrolloffset += kMargin - caretpos + get_w() / 5;
+ m_->scrolloffset += kMargin - caretpos + get_w() / 5;
else if (caretpos > get_w() - kMargin)
- m->scrolloffset -= caretpos - get_w() + kMargin + get_w() / 5;
+ m_->scrolloffset -= caretpos - get_w() + kMargin + get_w() / 5;
- if ((m->align & UI::Align::kHorizontal) == UI::Align::kLeft) {
- if (m->scrolloffset > 0)
- m->scrolloffset = 0;
- } else if ((m->align & UI::Align::kHorizontal) == UI::Align::kRight) {
- if (m->scrolloffset < 0)
- m->scrolloffset = 0;
+ if ((m_->align & UI::Align::kHorizontal) == UI::Align::kLeft) {
+ if (m_->scrolloffset > 0)
+ m_->scrolloffset = 0;
+ } else if ((m_->align & UI::Align::kHorizontal) == UI::Align::kRight) {
+ if (m_->scrolloffset < 0)
+ m_->scrolloffset = 0;
}
}
=== modified file 'src/ui_basic/editbox.h'
--- src/ui_basic/editbox.h 2016-01-31 10:57:58 +0000
+++ src/ui_basic/editbox.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006-2008, 2011 by the Widelands Development Team
+ * Copyright (C) 2003-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,9 +35,11 @@
struct EditBoxImpl;
-/// An editbox can be clicked, then the user can change its text (title). When
-/// return is pressed, the editbox is unfocused, the keyboard released and a
-/// callback function is called
+/** An editbox can be clicked, then the user can change its text (title).
+ *
+ * When return is pressed, the editbox is unfocused, the keyboard
+ * released and a callback function is called.
+ */
struct EditBox : public Panel {
EditBox
(Panel *,
@@ -55,7 +57,7 @@
uint32_t max_length() const;
void set_max_length(uint32_t);
- void activate_history(bool activate) {m_history_active = activate;}
+ void activate_history(bool activate) {history_active_ = activate;}
bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
@@ -65,13 +67,13 @@
void draw(RenderTarget &) override;
private:
- std::unique_ptr<EditBoxImpl> m;
+ std::unique_ptr<EditBoxImpl> m_;
void check_caret();
- bool m_history_active;
- int16_t m_history_position;
- std::string m_history[CHAT_HISTORY_SIZE];
+ bool history_active_;
+ int16_t history_position_;
+ std::string history_[CHAT_HISTORY_SIZE];
};
}
=== modified file 'src/ui_basic/icon.cc'
--- src/ui_basic/icon.cc 2016-01-30 22:26:21 +0000
+++ src/ui_basic/icon.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2013 by the Widelands Development Team
+ * Copyright (C) 2010-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,33 +30,33 @@
const Image* picture_id)
:
Panel(parent, x, y, w, h),
- m_pic(picture_id)
+ pic_(picture_id)
{
set_handle_mouse(false);
set_thinks(false);
}
void Icon::set_icon(const Image* picture_id) {
- m_pic = picture_id;
+ pic_ = picture_id;
}
void Icon::set_frame(const RGBColor& color)
{
- m_draw_frame = true;
- m_framecolor.r = color.r;
- m_framecolor.g = color.g;
- m_framecolor.b = color.b;
+ draw_frame_ = true;
+ framecolor_.r = color.r;
+ framecolor_.g = color.g;
+ framecolor_.b = color.b;
}
void Icon::set_no_frame()
{
- m_draw_frame = false;
+ draw_frame_ = false;
}
void Icon::draw(RenderTarget & dst) {
- if (m_pic) {
- double scale = std::min(static_cast<double>(get_w()) / m_pic->width(),
- static_cast<double>(get_h()) / m_pic->height());
+ if (pic_) {
+ double scale = std::min(static_cast<double>(get_w()) / pic_->width(),
+ static_cast<double>(get_h()) / pic_->height());
scale = std::min(1., scale);
int width = scale * get_w();
@@ -64,13 +64,13 @@
int x = (get_w() - width) / 2;
int y = (get_h() - height) / 2;
dst.blitrect_scale(Rect(x, y, width, height),
- m_pic,
- Rect(0, 0, m_pic->width(), m_pic->height()),
+ pic_,
+ Rect(0, 0, pic_->width(), pic_->height()),
1.,
BlendMode::UseAlpha);
}
- if (m_draw_frame) {
- dst.draw_rect(Rect(0, 0, get_w(), get_h()), m_framecolor);
+ if (draw_frame_) {
+ dst.draw_rect(Rect(0, 0, get_w(), get_h()), framecolor_);
}
}
=== modified file 'src/ui_basic/icon.h'
--- src/ui_basic/icon.h 2014-12-03 19:28:37 +0000
+++ src/ui_basic/icon.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2013 by the Widelands Development Team
+ * Copyright (C) 2010-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -42,9 +42,9 @@
void draw(RenderTarget &) override;
private:
- const Image* m_pic;
- bool m_draw_frame;
- RGBColor m_framecolor;
+ const Image* pic_;
+ bool draw_frame_;
+ RGBColor framecolor_;
};
}
=== modified file 'src/ui_basic/icongrid.cc'
--- src/ui_basic/icongrid.cc 2016-01-28 05:24:34 +0000
+++ src/ui_basic/icongrid.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2003-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -37,19 +37,19 @@
(&parent, name, x, y, w, h, background_picture_id,
foreground_picture_id,
tooltip_text, true, true),
- m_icongrid(parent),
+ icongrid_(parent),
_callback_argument_id(callback_argument_id)
{}
private:
- IconGrid & m_icongrid;
+ IconGrid & icongrid_;
const uint32_t _callback_argument_id;
void handle_mousein(bool inside) override {
if (inside) {
- m_icongrid.mousein(_callback_argument_id);
+ icongrid_.mousein(_callback_argument_id);
} else {
- m_icongrid.mouseout(_callback_argument_id);
+ icongrid_.mouseout(_callback_argument_id);
}
Button::handle_mousein(inside);
}
@@ -64,9 +64,9 @@
int32_t cols)
:
Panel (parent, x, y, 0, 0),
- m_columns (cols),
- m_cell_width (cellw),
- m_cell_height (cellh)
+ columns_ (cols),
+ cell_width_ (cellw),
+ cell_height_ (cellh)
{}
@@ -82,25 +82,25 @@
it.data = data;
- m_items.push_back(it);
+ items_.push_back(it);
// resize
- const int32_t rows = (m_items.size() + m_columns - 1) / m_columns;
+ const int32_t rows = (items_.size() + columns_ - 1) / columns_;
if (rows <= 1) {
- set_desired_size(m_cell_width * m_columns, m_cell_height);
+ set_desired_size(cell_width_ * columns_, cell_height_);
} else {
set_desired_size
- (m_cell_width * m_columns, m_cell_height * rows);
+ (cell_width_ * columns_, cell_height_ * rows);
}
- uint32_t idx = m_items.size() - 1;
- uint32_t x = (idx % m_columns) * m_cell_width;
- uint32_t y = (idx / m_columns) * m_cell_height;
+ uint32_t idx = items_.size() - 1;
+ uint32_t x = (idx % columns_) * cell_width_;
+ uint32_t y = (idx / columns_) * cell_height_;
UI::Button * btn = new IconGridButton
(*this, name,
- x, y, m_cell_width, m_cell_height,
+ x, y, cell_width_, cell_height_,
nullptr, pic,
idx, tooltip_text);
btn->sigclicked.connect(boost::bind(&IconGrid::clicked_button, this, idx));
@@ -118,9 +118,9 @@
*/
void * IconGrid::get_data(int32_t idx)
{
- assert(static_cast<uint32_t>(idx) < m_items.size());
+ assert(static_cast<uint32_t>(idx) < items_.size());
- return m_items[idx].data;
+ return items_[idx].data;
}
}
=== modified file 'src/ui_basic/icongrid.h'
--- src/ui_basic/icongrid.h 2014-09-10 14:48:40 +0000
+++ src/ui_basic/icongrid.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2003-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -60,11 +60,11 @@
};
/// max # of columns (or rows, depending on orientation) in the grid
- int32_t m_columns;
- int32_t m_cell_width; ///< size of one cell
- int32_t m_cell_height;
+ int32_t columns_;
+ int32_t cell_width_; ///< size of one cell
+ int32_t cell_height_;
- std::vector<Item> m_items;
+ std::vector<Item> items_;
};
}
=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/listselect.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -51,37 +51,37 @@
Align const align, bool const show_check)
:
Panel(parent, x, y, w, h),
- m_lineheight(g_fh->get_fontheight(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_SMALL)),
- m_scrollbar (this, get_w() - 24, 0, 24, h, false),
- m_scrollpos (0),
- m_selection (no_selection_index()),
- m_last_click_time(-10000),
- m_last_selection(no_selection_index()),
- m_show_check(show_check),
- m_fontname(UI::g_fh1->fontset().serif()),
- m_fontsize(UI_FONT_SIZE_SMALL)
+ lineheight_(g_fh->get_fontheight(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_SMALL)),
+ scrollbar_ (this, get_w() - 24, 0, 24, h, false),
+ scrollpos_ (0),
+ selection_ (no_selection_index()),
+ last_click_time_(-10000),
+ last_selection_(no_selection_index()),
+ show_check_(show_check),
+ fontname_(UI::g_fh1->fontset().serif()),
+ fontsize_(UI_FONT_SIZE_SMALL)
{
set_thinks(false);
// do not allow vertical alignment as it does not make sense
- m_align = align & UI::Align::kHorizontal;
+ align_ = align & UI::Align::kHorizontal;
- m_scrollbar.moved.connect(boost::bind(&BaseListselect::set_scrollpos, this, _1));
- m_scrollbar.set_singlestepsize(g_fh->get_fontheight(m_fontname, m_fontsize));
- m_scrollbar.set_pagesize
- (h - 2 * g_fh->get_fontheight(m_fontname, m_fontsize));
- m_scrollbar.set_steps(1);
+ scrollbar_.moved.connect(boost::bind(&BaseListselect::set_scrollpos, this, _1));
+ scrollbar_.set_singlestepsize(g_fh->get_fontheight(fontname_, fontsize_));
+ scrollbar_.set_pagesize
+ (h - 2 * g_fh->get_fontheight(fontname_, fontsize_));
+ scrollbar_.set_steps(1);
if (show_check) {
uint32_t pic_h;
- m_check_pic = g_gr->images().get("images/ui_basic/list_selected.png");
- m_max_pic_width = m_check_pic->width();
- pic_h = m_check_pic->height();
- if (pic_h > m_lineheight)
- m_lineheight = pic_h;
+ check_pic_ = g_gr->images().get("images/ui_basic/list_selected.png");
+ max_pic_width_ = check_pic_->width();
+ pic_h = check_pic_->height();
+ if (pic_h > lineheight_)
+ lineheight_ = pic_h;
}
else {
- m_max_pic_width = 0;
+ max_pic_width_ = 0;
}
set_can_focus(true);
}
@@ -100,16 +100,16 @@
* Remove all entries from the listselect
*/
void BaseListselect::clear() {
- for (EntryRecord * entry : m_entry_records) {
+ for (EntryRecord * entry : entry_records_) {
delete entry;
}
- m_entry_records.clear();
+ entry_records_.clear();
- m_scrollbar.set_steps(1);
- m_scrollpos = 0;
- m_selection = no_selection_index();
- m_last_click_time = -10000;
- m_last_selection = no_selection_index();
+ scrollbar_.set_steps(1);
+ scrollpos_ = 0;
+ selection_ = no_selection_index();
+ last_click_time_ = -10000;
+ last_selection_ = no_selection_index();
}
@@ -130,30 +130,30 @@
{
EntryRecord * er = new EntryRecord();
- er->m_entry = entry;
+ er->entry_ = entry;
er->pic = pic;
er->use_clr = false;
er->name = name;
er->tooltip = tooltip_text;
er->font_face = fontname;
- uint32_t entry_height = g_fh->get_fontheight(fontname.empty() ? m_fontname : fontname, m_fontsize);
+ uint32_t entry_height = g_fh->get_fontheight(fontname.empty() ? fontname_ : fontname, fontsize_);
if (pic) {
uint16_t w = pic->width();
uint16_t h = pic->height();
entry_height = (h >= entry_height) ? h : entry_height;
- if (m_max_pic_width < w)
- m_max_pic_width = w;
+ if (max_pic_width_ < w)
+ max_pic_width_ = w;
}
- if (entry_height > m_lineheight)
- m_lineheight = entry_height;
-
- m_entry_records.push_back(er);
-
- m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());
+ if (entry_height > lineheight_)
+ lineheight_ = entry_height;
+
+ entry_records_.push_back(er);
+
+ scrollbar_.set_steps(entry_records_.size() * get_lineheight() - get_h());
if (sel)
- select(m_entry_records.size() - 1);
+ select(entry_records_.size() - 1);
}
void BaseListselect::add_front
@@ -165,9 +165,9 @@
{
EntryRecord * er = new EntryRecord();
- er->m_entry = 0;
- for (EntryRecord * temp_entry : m_entry_records) {
- ++(temp_entry)->m_entry;
+ er->entry_ = 0;
+ for (EntryRecord * temp_entry : entry_records_) {
+ ++(temp_entry)->entry_;
}
er->pic = pic;
@@ -176,21 +176,21 @@
er->tooltip = tooltip_text;
er->font_face = fontname;
- uint32_t entry_height = g_fh->get_fontheight(fontname.empty() ? m_fontname : fontname, m_fontsize);
+ uint32_t entry_height = g_fh->get_fontheight(fontname.empty() ? fontname_ : fontname, fontsize_);
if (pic) {
uint16_t w = pic->width();
uint16_t h = pic->height();
entry_height = (h >= entry_height) ? h : entry_height;
- if (m_max_pic_width < w)
- m_max_pic_width = w;
+ if (max_pic_width_ < w)
+ max_pic_width_ = w;
}
- if (entry_height > m_lineheight)
- m_lineheight = entry_height;
-
- m_entry_records.push_front(er);
-
- m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());
+ if (entry_height > lineheight_)
+ lineheight_ = entry_height;
+
+ entry_records_.push_front(er);
+
+ scrollbar_.set_steps(entry_records_.size() * get_lineheight() - get_h());
if (sel)
select(0);
@@ -204,13 +204,13 @@
assert(m < size());
assert(n < size());
- std::swap(m_entry_records[m], m_entry_records[n]);
+ std::swap(entry_records_[m], entry_records_[n]);
- if (m_selection == m) {
- m_selection = n;
+ if (selection_ == m) {
+ selection_ = n;
selected(n);
- } else if (m_selection == n) {
- m_selection = m;
+ } else if (selection_ == n) {
+ selection_ = m;
selected(m);
}
}
@@ -228,15 +228,15 @@
End = size();
for (uint32_t i = Begin; i < End; ++i)
for (uint32_t j = i + 1; j < End; ++j) {
- EntryRecord * const eri = m_entry_records[i];
- EntryRecord * const erj = m_entry_records[j];
+ EntryRecord * const eri = entry_records_[i];
+ EntryRecord * const erj = entry_records_[j];
if (strcmp(eri->name.c_str(), erj->name.c_str()) > 0) {
- if (m_selection == i)
- m_selection = j;
- else if (m_selection == j)
- m_selection = i;
- m_entry_records[i] = erj;
- m_entry_records[j] = eri;
+ if (selection_ == i)
+ selection_ = j;
+ else if (selection_ == j)
+ selection_ = i;
+ entry_records_[i] = erj;
+ entry_records_[j] = eri;
}
}
}
@@ -246,10 +246,10 @@
*/
void BaseListselect::set_scrollpos(const int32_t i)
{
- if (m_scrollpos == uint32_t(i))
+ if (scrollpos_ == uint32_t(i))
return;
- m_scrollpos = i;
+ scrollpos_ = i;
}
@@ -260,10 +260,10 @@
void BaseListselect::set_entry_color
(const uint32_t n, const RGBColor col)
{
- assert(n < m_entry_records.size());
+ assert(n < entry_records_.size());
- m_entry_records[n]->use_clr = true;
- m_entry_records[n]->clr = col;
+ entry_records_[n]->use_clr = true;
+ entry_records_[n]->clr = col;
}
@@ -274,17 +274,17 @@
*/
void BaseListselect::select(const uint32_t i)
{
- if (m_selection == i)
+ if (selection_ == i)
return;
- if (m_show_check) {
- if (m_selection != no_selection_index())
- m_entry_records[m_selection]->pic = nullptr;
- m_entry_records[i]->pic = m_check_pic;
+ if (show_check_) {
+ if (selection_ != no_selection_index())
+ entry_records_[selection_]->pic = nullptr;
+ entry_records_[i]->pic = check_pic_;
}
- m_selection = i;
+ selection_ = i;
- selected(m_selection);
+ selected(selection_);
}
/**
@@ -293,7 +293,7 @@
*/
bool BaseListselect::has_selection() const
{
- return m_selection != no_selection_index();
+ return selection_ != no_selection_index();
}
@@ -305,10 +305,10 @@
*/
uint32_t BaseListselect::get_selected() const
{
- if (m_selection == no_selection_index())
+ if (selection_ == no_selection_index())
throw NoSelection();
- return m_entry_records[m_selection]->m_entry;
+ return entry_records_[selection_]->entry_;
}
@@ -318,21 +318,21 @@
*/
void BaseListselect::remove_selected()
{
- if (m_selection == no_selection_index())
+ if (selection_ == no_selection_index())
throw NoSelection();
- remove(m_selection);
+ remove(selection_);
}
uint32_t BaseListselect::get_lineheight() const
{
- return m_lineheight + 2;
+ return lineheight_ + 2;
}
uint32_t BaseListselect::get_eff_w() const
{
- return m_scrollbar.is_enabled() ? get_w() - m_scrollbar.get_w() : get_w();
+ return scrollbar_.is_enabled() ? get_w() - scrollbar_.get_w() : get_w();
}
/**
@@ -342,22 +342,22 @@
{
// draw text lines
const uint32_t lineheight = get_lineheight();
- uint32_t idx = m_scrollpos / lineheight;
- int32_t y = 1 + idx * lineheight - m_scrollpos;
+ uint32_t idx = scrollpos_ / lineheight;
+ int32_t y = 1 + idx * lineheight - scrollpos_;
dst.brighten_rect(Rect(Point(0, 0), get_w(), get_h()), ms_darken_value);
- while (idx < m_entry_records.size()) {
+ while (idx < entry_records_.size()) {
assert(get_h() < std::numeric_limits<int32_t>::max());
if (y >= get_h()) {
break;
}
- const EntryRecord & er = *m_entry_records[idx];
+ const EntryRecord & er = *entry_records_[idx];
// Highlight the current selected entry
- if (idx == m_selection) {
- Rect r = Rect(Point(1, y), get_eff_w() - 2, m_lineheight);
+ if (idx == selection_) {
+ Rect r = Rect(Point(1, y), get_eff_w() - 2, lineheight_);
if (r.x < 0) {
r.w += r.x; r.x = 0;
}
@@ -372,26 +372,26 @@
}
}
- Align draw_alignment = mirror_alignment(m_align);
+ Align draw_alignment = mirror_alignment(align_);
int32_t const x =
(static_cast<int>(draw_alignment & UI::Align::kRight)) ? get_eff_w() - 1 :
(static_cast<int>(draw_alignment & UI::Align::kHCenter)) ? get_eff_w() >> 1 :
// Pictures are always left aligned, leave some space here
- m_max_pic_width ? m_max_pic_width + 10 :
+ max_pic_width_ ? max_pic_width_ + 10 :
1;
- std::string font_face = er.font_face.empty() ? m_fontname : er.font_face;
+ std::string font_face = er.font_face.empty() ? fontname_ : er.font_face;
// Horizontal center the string
UI::g_fh->draw_text
(dst,
- TextStyle::makebold(Font::get(font_face, m_fontsize), er.use_clr ? er.clr : UI_FONT_CLR_FG),
+ TextStyle::makebold(Font::get(font_face, fontsize_), er.use_clr ? er.clr : UI_FONT_CLR_FG),
Point
(x,
y +
- (get_lineheight() - g_fh->get_fontheight(font_face, m_fontsize))
+ (get_lineheight() - g_fh->get_fontheight(font_face, fontsize_))
/
2),
er.name,
@@ -412,7 +412,7 @@
* Handle mouse wheel events
*/
bool BaseListselect::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
- return m_scrollbar.handle_mousewheel(which, x, y);
+ return scrollbar_.handle_mousewheel(which, x, y);
}
/**
@@ -427,25 +427,25 @@
// This hick hack is needed if any of the callback functions calls clear
// to forget the last clicked time.
- uint32_t const real_last_click_time = m_last_click_time;
-
- m_last_selection = m_selection;
- m_last_click_time = time;
-
- y = (y + m_scrollpos) / get_lineheight();
- if (y < 0 || static_cast<int32_t>(m_entry_records.size()) <= y)
+ uint32_t const real_last_click_time = last_click_time_;
+
+ last_selection_ = selection_;
+ last_click_time_ = time;
+
+ y = (y + scrollpos_) / get_lineheight();
+ if (y < 0 || static_cast<int32_t>(entry_records_.size()) <= y)
return false;
play_click();
select(y);
- clicked(m_selection);
+ clicked(selection_);
if // check if doubleclicked
(time - real_last_click_time < DOUBLE_CLICK_INTERVAL
&&
- m_last_selection == m_selection
+ last_selection_ == selection_
&&
- m_selection != no_selection_index())
- double_clicked(m_selection);
+ selection_ != no_selection_index())
+ double_clicked(selection_);
return true;
}
@@ -460,12 +460,12 @@
}
bool BaseListselect::handle_mousemove(uint8_t, int32_t, int32_t y, int32_t, int32_t) {
- y = (y + m_scrollpos) / get_lineheight();
- if (y < 0 || static_cast<int32_t>(m_entry_records.size()) <= y) {
+ y = (y + scrollpos_) / get_lineheight();
+ if (y < 0 || static_cast<int32_t>(entry_records_.size()) <= y) {
set_tooltip("");
return false;
}
- set_tooltip(m_entry_records.at(y)->tooltip);
+ set_tooltip(entry_records_.at(y)->tooltip);
return true;
}
@@ -481,10 +481,10 @@
selected_idx = selection_index() + 1;
if (selected_idx < size())
select(selected_idx);
- if ((selection_index() + 1) * get_lineheight() - get_inner_h() > m_scrollpos) {
+ if ((selection_index() + 1) * get_lineheight() - get_inner_h() > scrollpos_) {
int32_t scrollpos = (selection_index() + 1) * get_lineheight() - get_inner_h();
- m_scrollpos = (scrollpos < 0) ? 0 : scrollpos;
- m_scrollbar.set_scrollpos(m_scrollpos);
+ scrollpos_ = (scrollpos < 0) ? 0 : scrollpos;
+ scrollbar_.set_scrollpos(scrollpos_);
}
return true;
case SDLK_KP_8:
@@ -495,9 +495,9 @@
selected_idx = selection_index();
if (selected_idx > 0)
select(selected_idx - 1);
- if (selection_index() * get_lineheight() < m_scrollpos) {
- m_scrollpos = selection_index() * get_lineheight();
- m_scrollbar.set_scrollpos(m_scrollpos);
+ if (selection_index() * get_lineheight() < scrollpos_) {
+ scrollpos_ = selection_index() * get_lineheight();
+ scrollbar_.set_scrollpos(scrollpos_);
}
return true;
default:
@@ -513,14 +513,14 @@
*/
void BaseListselect::remove(const uint32_t i)
{
- assert(i < m_entry_records.size());
+ assert(i < entry_records_.size());
- delete (m_entry_records[i]);
- m_entry_records.erase(m_entry_records.begin() + i);
- if (m_selection == i)
- selected(m_selection = no_selection_index());
- else if (i < m_selection)
- --m_selection;
+ delete (entry_records_[i]);
+ entry_records_.erase(entry_records_.begin() + i);
+ if (selection_ == i)
+ selected(selection_ = no_selection_index());
+ else if (i < selection_)
+ --selection_;
}
/**
@@ -530,8 +530,8 @@
*/
void BaseListselect::remove(const char * const str)
{
- for (uint32_t i = 0; i < m_entry_records.size(); ++i) {
- if (!strcmp(m_entry_records[i]->name.c_str(), str)) {
+ for (uint32_t i = 0; i < entry_records_.size(); ++i) {
+ if (!strcmp(entry_records_[i]->name.c_str(), str)) {
remove(i);
return;
}
=== modified file 'src/ui_basic/listselect.h'
--- src/ui_basic/listselect.h 2015-12-17 09:36:59 +0000
+++ src/ui_basic/listselect.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -79,17 +79,17 @@
void set_entry_color(uint32_t, RGBColor);
void set_font(const std::string & fontname, int32_t const fontsize) {
- m_fontname = fontname;
- m_fontsize = fontsize;
+ fontname_ = fontname;
+ fontsize_ = fontsize;
}
- uint32_t size () const {return m_entry_records.size ();}
- bool empty() const {return m_entry_records.empty();}
+ uint32_t size () const {return entry_records_.size ();}
+ bool empty() const {return entry_records_.empty();}
uint32_t operator[](const uint32_t i) const
{
assert(i < size());
- return m_entry_records[i]->m_entry;
+ return entry_records_[i]->entry_;
}
static uint32_t no_selection_index()
@@ -99,7 +99,7 @@
uint32_t selection_index() const
{
- return m_selection;
+ return selection_;
}
void select(uint32_t i);
@@ -131,7 +131,7 @@
static const int32_t ms_darken_value = -20;
struct EntryRecord {
- uint32_t m_entry;
+ uint32_t entry_;
bool use_clr;
RGBColor clr;
const Image* pic;
@@ -141,21 +141,21 @@
};
using EntryRecordDeque = std::deque<EntryRecord *>;
- uint32_t m_max_pic_width;
- uint32_t m_lineheight;
- Align m_align;
- EntryRecordDeque m_entry_records;
- Scrollbar m_scrollbar;
- uint32_t m_scrollpos; // in pixels
- uint32_t m_selection;
- uint32_t m_last_click_time;
- uint32_t m_last_selection; // for double clicks
- bool m_show_check; // show a green arrow left of selected element
- const Image* m_check_pic;
+ uint32_t max_pic_width_;
+ uint32_t lineheight_;
+ Align align_;
+ EntryRecordDeque entry_records_;
+ Scrollbar scrollbar_;
+ uint32_t scrollpos_; // in pixels
+ uint32_t selection_;
+ uint32_t last_click_time_;
+ uint32_t last_selection_; // for double clicks
+ bool show_check_; // show a green arrow left of selected element
+ const Image* check_pic_;
- std::string m_fontname;
- uint32_t m_fontsize;
- std::string m_current_tooltip;
+ std::string fontname_;
+ uint32_t fontsize_;
+ std::string current_tooltip_;
};
template<typename Entry>
@@ -177,8 +177,8 @@
const std::string & tooltip_text = std::string(),
const std::string & font_face = "")
{
- m_entry_cache.push_back(value);
- BaseListselect::add(name, m_entry_cache.size() - 1, pic, select_this, tooltip_text, font_face);
+ entry_cache_.push_back(value);
+ BaseListselect::add(name, entry_cache_.size() - 1, pic, select_this, tooltip_text, font_face);
}
void add_front
(const std::string& name,
@@ -187,22 +187,22 @@
const bool select_this = false,
const std::string & tooltip_text = std::string())
{
- m_entry_cache.push_front(value);
+ entry_cache_.push_front(value);
BaseListselect::add_front(name, pic, select_this, tooltip_text);
}
const Entry & operator[](uint32_t const i) const
{
- return m_entry_cache[BaseListselect::operator[](i)];
+ return entry_cache_[BaseListselect::operator[](i)];
}
const Entry & get_selected() const
{
- return m_entry_cache[BaseListselect::get_selected()];
+ return entry_cache_[BaseListselect::get_selected()];
}
private:
- std::deque<Entry> m_entry_cache;
+ std::deque<Entry> entry_cache_;
};
/**
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2016-01-30 22:26:21 +0000
+++ src/ui_basic/multilineeditbox.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -89,9 +89,9 @@
const Image* background)
:
Panel(parent, x, y, w, h),
- d(new Data(*this))
+ d_(new Data(*this))
{
- d->background = background;
+ d_->background = background;
set_handle_mouse(true);
set_can_focus(true);
set_thinks(false);
@@ -129,7 +129,7 @@
*/
const std::string & MultilineEditbox::get_text() const
{
- return d->text;
+ return d_->text;
}
/**
@@ -137,18 +137,18 @@
*/
void MultilineEditbox::set_text(const std::string & text)
{
- if (text == d->text)
+ if (text == d_->text)
return;
- d->text = text;
- while (d->text.size() > d->maxbytes)
- d->erase_bytes(d->prev_char(d->text.size()), d->text.size());
-
- if (d->cursor_pos > d->text.size())
- d->cursor_pos = d->text.size();
-
- d->update();
- d->scroll_cursor_into_view();
+ d_->text = text;
+ while (d_->text.size() > d_->maxbytes)
+ d_->erase_bytes(d_->prev_char(d_->text.size()), d_->text.size());
+
+ if (d_->cursor_pos > d_->text.size())
+ d_->cursor_pos = d_->text.size();
+
+ d_->update();
+ d_->scroll_cursor_into_view();
changed();
}
@@ -158,11 +158,11 @@
*/
void MultilineEditbox::set_textstyle(const UI::TextStyle & ts)
{
- if (d->textstyle == ts)
+ if (d_->textstyle == ts)
return;
- d->textstyle = ts;
- d->update();
+ d_->textstyle = ts;
+ d_->update();
}
@@ -173,9 +173,9 @@
*/
void MultilineEditbox::set_maximum_bytes(const uint32_t n)
{
- while (n < d->text.size())
- d->erase_bytes(d->prev_char(d->text.size()), d->text.size());
- d->maxbytes = n;
+ while (n < d_->text.size())
+ d_->erase_bytes(d_->prev_char(d_->text.size()), d_->text.size());
+ d_->maxbytes = n;
// do not need to update here, because erase() will
// update when necessary
@@ -186,7 +186,7 @@
*/
uint32_t MultilineEditbox::get_maximum_bytes() const
{
- return d->maxbytes;
+ return d_->maxbytes;
}
/**
@@ -265,15 +265,15 @@
break;
/* no break */
case SDLK_DELETE:
- if (d->cursor_pos < d->text.size()) {
- d->erase_bytes(d->cursor_pos, d->next_char(d->cursor_pos));
+ if (d_->cursor_pos < d_->text.size()) {
+ d_->erase_bytes(d_->cursor_pos, d_->next_char(d_->cursor_pos));
changed();
}
break;
case SDLK_BACKSPACE:
- if (d->cursor_pos > 0) {
- d->erase_bytes(d->prev_char(d->cursor_pos), d->cursor_pos);
+ if (d_->cursor_pos > 0) {
+ d_->erase_bytes(d_->prev_char(d_->cursor_pos), d_->cursor_pos);
changed();
}
break;
@@ -285,18 +285,18 @@
/* no break */
case SDLK_LEFT: {
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
- uint32_t newpos = d->prev_char(d->cursor_pos);
- while (newpos > 0 && isspace(d->text[newpos]))
- newpos = d->prev_char(newpos);
+ uint32_t newpos = d_->prev_char(d_->cursor_pos);
+ while (newpos > 0 && isspace(d_->text[newpos]))
+ newpos = d_->prev_char(newpos);
while (newpos > 0) {
- uint32_t prev = d->prev_char(newpos);
- if (isspace(d->text[prev]))
+ uint32_t prev = d_->prev_char(newpos);
+ if (isspace(d_->text[prev]))
break;
newpos = prev;
}
- d->set_cursor_pos(newpos);
+ d_->set_cursor_pos(newpos);
} else {
- d->set_cursor_pos(d->prev_char(d->cursor_pos));
+ d_->set_cursor_pos(d_->prev_char(d_->cursor_pos));
}
break;
}
@@ -308,14 +308,14 @@
/* no break */
case SDLK_RIGHT:
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
- uint32_t newpos = d->next_char(d->cursor_pos);
- while (newpos < d->text.size() && isspace(d->text[newpos]))
- newpos = d->next_char(newpos);
- while (newpos < d->text.size() && !isspace(d->text[newpos]))
- newpos = d->next_char(newpos);
- d->set_cursor_pos(newpos);
+ uint32_t newpos = d_->next_char(d_->cursor_pos);
+ while (newpos < d_->text.size() && isspace(d_->text[newpos]))
+ newpos = d_->next_char(newpos);
+ while (newpos < d_->text.size() && !isspace(d_->text[newpos]))
+ newpos = d_->next_char(newpos);
+ d_->set_cursor_pos(newpos);
} else {
- d->set_cursor_pos(d->next_char(d->cursor_pos));
+ d_->set_cursor_pos(d_->next_char(d_->cursor_pos));
}
break;
@@ -325,25 +325,25 @@
}
/* no break */
case SDLK_DOWN:
- if (d->cursor_pos < d->text.size()) {
- d->refresh_ww();
+ if (d_->cursor_pos < d_->text.size()) {
+ d_->refresh_ww();
uint32_t cursorline, cursorpos;
- d->ww.calc_wrapped_pos(d->cursor_pos, cursorline, cursorpos);
-
- if (cursorline + 1 < d->ww.nrlines()) {
- uint32_t lineend = d->text.size();
- if (cursorline + 2 < d->ww.nrlines())
- lineend = d->prev_char(d->ww.line_offset(cursorline + 2));
-
- uint32_t newpos = d->ww.line_offset(cursorline + 1) + cursorpos;
+ d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
+
+ if (cursorline + 1 < d_->ww.nrlines()) {
+ uint32_t lineend = d_->text.size();
+ if (cursorline + 2 < d_->ww.nrlines())
+ lineend = d_->prev_char(d_->ww.line_offset(cursorline + 2));
+
+ uint32_t newpos = d_->ww.line_offset(cursorline + 1) + cursorpos;
if (newpos > lineend)
newpos = lineend;
else
- newpos = d->snap_to_char(newpos);
- d->set_cursor_pos(newpos);
+ newpos = d_->snap_to_char(newpos);
+ d_->set_cursor_pos(newpos);
} else {
- d->set_cursor_pos(d->text.size());
+ d_->set_cursor_pos(d_->text.size());
}
}
break;
@@ -354,23 +354,23 @@
}
/* no break */
case SDLK_UP:
- if (d->cursor_pos > 0) {
- d->refresh_ww();
+ if (d_->cursor_pos > 0) {
+ d_->refresh_ww();
uint32_t cursorline, cursorpos;
- d->ww.calc_wrapped_pos(d->cursor_pos, cursorline, cursorpos);
+ d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
if (cursorline > 0) {
- uint32_t newpos = d->ww.line_offset(cursorline-1) + cursorpos;
- uint32_t lineend = d->prev_char(d->ww.line_offset(cursorline));
+ uint32_t newpos = d_->ww.line_offset(cursorline-1) + cursorpos;
+ uint32_t lineend = d_->prev_char(d_->ww.line_offset(cursorline));
if (newpos > lineend)
newpos = lineend;
else
- newpos = d->snap_to_char(newpos);
- d->set_cursor_pos(newpos);
+ newpos = d_->snap_to_char(newpos);
+ d_->set_cursor_pos(newpos);
} else {
- d->set_cursor_pos(0);
+ d_->set_cursor_pos(0);
}
}
break;
@@ -382,14 +382,14 @@
/* no break */
case SDLK_HOME:
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
- d->set_cursor_pos(0);
+ d_->set_cursor_pos(0);
} else {
- d->refresh_ww();
+ d_->refresh_ww();
uint32_t cursorline, cursorpos;
- d->ww.calc_wrapped_pos(d->cursor_pos, cursorline, cursorpos);
+ d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
- d->set_cursor_pos(d->ww.line_offset(cursorline));
+ d_->set_cursor_pos(d_->ww.line_offset(cursorline));
}
break;
@@ -400,23 +400,23 @@
/* no break */
case SDLK_END:
if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
- d->set_cursor_pos(d->text.size());
+ d_->set_cursor_pos(d_->text.size());
} else {
- d->refresh_ww();
+ d_->refresh_ww();
uint32_t cursorline, cursorpos;
- d->ww.calc_wrapped_pos(d->cursor_pos, cursorline, cursorpos);
+ d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
- if (cursorline + 1 < d->ww.nrlines())
- d->set_cursor_pos(d->prev_char(d->ww.line_offset(cursorline + 1)));
+ if (cursorline + 1 < d_->ww.nrlines())
+ d_->set_cursor_pos(d_->prev_char(d_->ww.line_offset(cursorline + 1)));
else
- d->set_cursor_pos(d->text.size());
+ d_->set_cursor_pos(d_->text.size());
}
break;
case SDLK_KP_ENTER:
case SDLK_RETURN:
- d->insert(d->cursor_pos, "\n");
+ d_->insert(d_->cursor_pos, "\n");
changed();
break;
@@ -430,8 +430,8 @@
}
bool MultilineEditbox::handle_textinput(const std::string& input_text) {
- if (d->text.size() + input_text.size() <= d->maxbytes) {
- d->insert(d->cursor_pos, input_text);
+ if (d_->text.size() + input_text.size() <= d_->maxbytes) {
+ d_->insert(d_->cursor_pos, input_text);
changed();
}
return true;
@@ -452,7 +452,7 @@
// Draw the background
dst.tile
(Rect(Point(0, 0), get_w(), get_h()),
- d->background,
+ d_->background,
Point(get_x(), get_y()));
// Draw border.
@@ -479,13 +479,13 @@
dst.brighten_rect
(Rect(Point(0, 0), get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
- d->refresh_ww();
-
- d->ww.set_draw_caret(has_focus());
-
- d->ww.draw
- (dst, Point(0, -int32_t(d->scrollbar.get_scrollpos())), UI::Align::kLeft,
- has_focus() ? d->cursor_pos : std::numeric_limits<uint32_t>::max());
+ d_->refresh_ww();
+
+ d_->ww.set_draw_caret(has_focus());
+
+ d_->ww.draw
+ (dst, Point(0, -int32_t(d_->scrollbar.get_scrollpos())), UI::Align::kLeft,
+ has_focus() ? d_->cursor_pos : std::numeric_limits<uint32_t>::max());
}
/**
=== modified file 'src/ui_basic/multilineeditbox.h'
--- src/ui_basic/multilineeditbox.h 2015-10-04 19:26:02 +0000
+++ src/ui_basic/multilineeditbox.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2011 by Widelands Development Team
+ * Copyright (C) 2002-2016 by Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -61,7 +61,7 @@
void scrollpos_changed(int32_t);
struct Data;
- std::unique_ptr<Data> d;
+ std::unique_ptr<Data> d_;
};
}
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2016-02-01 17:20:23 +0000
+++ src/ui_basic/multilinetextarea.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002-2004, 2006-2009, 2011, 2013 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -39,25 +39,25 @@
MultilineTextarea::ScrollMode scroll_mode)
:
Panel (parent, x, y, w, h),
- m_text (text),
- m_style(UI::TextStyle::ui_small()),
+ text_ (text),
+ style_(UI::TextStyle::ui_small()),
isrichtext(false),
- m_scrollbar (this, get_w() - scrollbar_w(), 0, scrollbar_w(), h, false),
- m_scrollmode(scroll_mode)
+ scrollbar_ (this, get_w() - scrollbar_w(), 0, scrollbar_w(), h, false),
+ scrollmode_(scroll_mode)
{
assert(scrollbar_w() <= w);
set_thinks(false);
// do not allow vertical alignment as it does not make sense
- m_align = align & UI::Align::kHorizontal;
-
- m_scrollbar.moved.connect(boost::bind(&MultilineTextarea::scrollpos_changed, this, _1));
-
- m_scrollbar.set_singlestepsize(UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_SMALL))->height());
- m_scrollbar.set_pagesize(h - 2 * UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_BIG))->height());
- m_scrollbar.set_steps(1);
- m_scrollbar.set_force_draw(m_scrollmode == ScrollMode::kScrollNormalForced ||
- m_scrollmode == ScrollMode::kScrollLogForced);
+ align_ = align & UI::Align::kHorizontal;
+
+ scrollbar_.moved.connect(boost::bind(&MultilineTextarea::scrollpos_changed, this, _1));
+
+ scrollbar_.set_singlestepsize(UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_SMALL))->height());
+ scrollbar_.set_pagesize(h - 2 * UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_BIG))->height());
+ scrollbar_.set_steps(1);
+ scrollbar_.set_force_draw(scrollmode_ == ScrollMode::kScrollNormalForced ||
+ scrollmode_ == ScrollMode::kScrollLogForced);
recompute();
}
@@ -69,7 +69,7 @@
*/
void MultilineTextarea::set_text(const std::string& text)
{
- m_text = text;
+ text_ = text;
recompute();
}
@@ -82,39 +82,39 @@
uint32_t height;
// We wrap the text twice. We need to do this to account for the presence/absence of the scollbar.
- bool scrollbar_was_enabled = m_scrollbar.is_enabled();
+ bool scrollbar_was_enabled = scrollbar_.is_enabled();
for (int i = 0; i < 2; ++i) {
- if (m_text.compare(0, 3, "<rt")) {
+ if (text_.compare(0, 3, "<rt")) {
isrichtext = false;
- std::string text_to_render = richtext_escape(m_text);
+ std::string text_to_render = richtext_escape(text_);
boost::replace_all(text_to_render, "\n", "<br>");
- const Image* text_im = UI::g_fh1->render(as_uifont(text_to_render, m_style.font->size(), m_style.fg),
+ const Image* text_im = UI::g_fh1->render(as_uifont(text_to_render, style_.font->size(), style_.fg),
get_eff_w() - 2 * RICHTEXT_MARGIN);
height = text_im->height();
} else {
isrichtext = true;
rt.set_width(get_eff_w() - 2 * RICHTEXT_MARGIN);
- rt.parse(m_text);
+ rt.parse(text_);
height = rt.height() + 2 * RICHTEXT_MARGIN;
}
bool setbottom = false;
- if (m_scrollmode == ScrollMode::kScrollLog || m_scrollmode == ScrollMode::kScrollLogForced) {
- if (m_scrollbar.get_scrollpos() >= m_scrollbar.get_steps() - 1)
+ if (scrollmode_ == ScrollMode::kScrollLog || scrollmode_ == ScrollMode::kScrollLogForced) {
+ if (scrollbar_.get_scrollpos() >= scrollbar_.get_steps() - 1)
setbottom = true;
- } else if (m_scrollmode == ScrollMode::kNoScrolling) {
- m_scrollbar.set_scrollpos(0);
- m_scrollbar.set_steps(1);
+ } else if (scrollmode_ == ScrollMode::kNoScrolling) {
+ scrollbar_.set_scrollpos(0);
+ scrollbar_.set_steps(1);
set_desired_size(get_w(), height);
set_size(get_w(), height);
}
- m_scrollbar.set_steps(height - get_h());
+ scrollbar_.set_steps(height - get_h());
if (setbottom)
- m_scrollbar.set_scrollpos(height - get_h());
+ scrollbar_.set_scrollpos(height - get_h());
- if (m_scrollbar.is_enabled() == scrollbar_was_enabled) {
+ if (scrollbar_.is_enabled() == scrollbar_was_enabled) {
break; // No need to wrap twice.
}
}
@@ -133,8 +133,8 @@
recompute();
// Take care about the scrollbar
- m_scrollbar.set_pos(Point(get_w() - scrollbar_w(), 0));
- m_scrollbar.set_size(scrollbar_w(), get_h());
+ scrollbar_.set_pos(Point(get_w() - scrollbar_w(), 0));
+ scrollbar_.set_size(scrollbar_w(), get_h());
}
/**
@@ -143,12 +143,12 @@
void MultilineTextarea::draw(RenderTarget& dst)
{
if (isrichtext) {
- rt.draw(dst, Point(RICHTEXT_MARGIN, RICHTEXT_MARGIN - m_scrollbar.get_scrollpos()));
+ rt.draw(dst, Point(RICHTEXT_MARGIN, RICHTEXT_MARGIN - scrollbar_.get_scrollpos()));
} else {
- std::string text_to_render = richtext_escape(m_text);
+ std::string text_to_render = richtext_escape(text_);
boost::replace_all(text_to_render, "\n", "<br>");
const Image* text_im =
- UI::g_fh1->render(as_aligned(text_to_render, m_align, m_style.font->size(), m_style.fg),
+ UI::g_fh1->render(as_aligned(text_to_render, align_, style_.font->size(), style_.fg),
get_eff_w() - 2 * RICHTEXT_MARGIN);
uint32_t blit_width = std::min(text_im->width(), static_cast<int>(get_eff_w()));
@@ -156,7 +156,7 @@
if (blit_width > 0 && blit_height > 0) {
int32_t anchor = 0;
- Align alignment = mirror_alignment(m_align);
+ Align alignment = mirror_alignment(align_);
switch (alignment & UI::Align::kHorizontal) {
case UI::Align::kHCenter:
anchor = (get_eff_w() - blit_width) / 2;
@@ -172,7 +172,7 @@
dst.blitrect_scale(
Rect(anchor, 0, blit_width, blit_height),
text_im,
- Rect(0, m_scrollbar.get_scrollpos(), blit_width, blit_height),
+ Rect(0, scrollbar_.get_scrollpos(), blit_width, blit_height),
1.,
BlendMode::UseAlpha);
}
@@ -181,11 +181,11 @@
bool MultilineTextarea::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
- return m_scrollbar.handle_mousewheel(which, x, y);
+ return scrollbar_.handle_mousewheel(which, x, y);
}
void MultilineTextarea::scroll_to_top() {
- m_scrollbar.set_scrollpos(0);
+ scrollbar_.set_scrollpos(0);
}
} // namespace UI
=== modified file 'src/ui_basic/multilinetextarea.h'
--- src/ui_basic/multilinetextarea.h 2016-02-01 17:17:45 +0000
+++ src/ui_basic/multilinetextarea.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2009, 2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -52,14 +52,14 @@
const Align = UI::Align::kLeft,
MultilineTextarea::ScrollMode scroll_mode = MultilineTextarea::ScrollMode::kScrollNormal);
- const std::string& get_text() const {return m_text;}
+ const std::string& get_text() const {return text_;}
void set_text(const std::string&);
uint32_t scrollbar_w() const {return 24;}
- uint32_t get_eff_w() const {return m_scrollbar.is_enabled() ? get_w() - scrollbar_w() : get_w();}
+ uint32_t get_eff_w() const {return scrollbar_.is_enabled() ? get_w() - scrollbar_w() : get_w();}
- void set_color(RGBColor fg) {m_style.fg = fg;}
+ void set_color(RGBColor fg) {style_.fg = fg;}
// Drawing and event handlers
void draw(RenderTarget&) override;
@@ -74,15 +74,15 @@
void recompute();
void scrollpos_changed(int32_t pixels);
- std::string m_text;
- UI::TextStyle m_style;
- Align m_align;
+ std::string text_;
+ UI::TextStyle style_;
+ Align align_;
bool isrichtext;
RichText rt;
- Scrollbar m_scrollbar;
- ScrollMode m_scrollmode;
+ Scrollbar scrollbar_;
+ ScrollMode scrollmode_;
};
}
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/panel.cc 2016-02-03 18:13:14 +0000
@@ -148,7 +148,7 @@
// Panel-specific startup code. This might call end_modal()!
start();
- const uint32_t minimum_frame_time =
+ const uint32_t minimuframe_time_ =
1000 / std::max(5, g_options.pull_section("global").get_int("maxfps", 30));
while (_running) {
@@ -181,8 +181,8 @@
// Wait until 1second/maxfps are over.
const uint32_t frame_time = SDL_GetTicks() - startTime;
- if (frame_time < minimum_frame_time) {
- SDL_Delay(minimum_frame_time - frame_time);
+ if (frame_time < minimuframe_time_) {
+ SDL_Delay(minimuframe_time_ - frame_time);
}
}
end();
@@ -1102,11 +1102,11 @@
Rect r
(WLApplication::get()->get_mouse_position() + Point(2, 32),
tip_width, tip_height);
- const Point tooltip_bottom_right = r.opposite_of_origin();
- const Point screen_bottom_right(g_gr->get_xres(), g_gr->get_yres());
- if (screen_bottom_right.x < tooltip_bottom_right.x)
+ const Point tooltip_bottoright_ = r.opposite_of_origin();
+ const Point screen_bottoright_(g_gr->get_xres(), g_gr->get_yres());
+ if (screen_bottoright_.x < tooltip_bottoright_.x)
r.x -= 4 + r.w;
- if (screen_bottom_right.y < tooltip_bottom_right.y)
+ if (screen_bottoright_.y < tooltip_bottoright_.y)
r.y -= 35 + r.h;
dst.fill_rect(r, RGBColor(63, 52, 34));
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2016-01-30 22:26:21 +0000
+++ src/ui_basic/panel.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -358,14 +358,14 @@
int32_t const nx, int32_t const ny,
int const nw, int const nh,
const std::string & tooltip_text = std::string())
- : Panel(nparent, nx, ny, nw, nh, tooltip_text), m_name(name)
+ : Panel(nparent, nx, ny, nw, nh, tooltip_text), name_(name)
{
}
- const std::string & get_name() const {return m_name;}
+ const std::string & get_name() const {return name_;}
private:
- std::string m_name;
+ std::string name_;
};
}
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2016-01-30 22:26:21 +0000
+++ src/ui_basic/progressbar.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006-2007, 2009 by the Widelands Development Team
+ * Copyright (C) 2004-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -37,9 +37,9 @@
uint32_t const orientation)
:
Panel (parent, x, y, w, h),
- m_orientation(orientation),
- m_state (0),
- m_total (100)
+ orientation_(orientation),
+ state_ (0),
+ total_ (100)
{}
@@ -48,7 +48,7 @@
*/
void ProgressBar::set_state(uint32_t state)
{
- m_state = state;
+ state_ = state;
}
@@ -58,7 +58,7 @@
void ProgressBar::set_total(uint32_t total)
{
assert(total);
- m_total = total;
+ total_ = total;
}
@@ -69,9 +69,9 @@
{
assert(0 < get_w());
assert(0 < get_h());
- assert(m_total);
+ assert(total_);
const float fraction =
- m_state < m_total ? static_cast<float>(m_state) / m_total : 1.0;
+ state_ < total_ ? static_cast<float>(state_) / total_ : 1.0;
assert(0 <= fraction);
assert (fraction <= 1);
@@ -81,7 +81,7 @@
fraction <= 0.67 ? RGBColor(255, 255, 0) : RGBColor(0, 255, 0);
// Draw the actual bar
- if (m_orientation == Horizontal)
+ if (orientation_ == Horizontal)
{
const uint32_t w = static_cast<uint32_t>(get_w() * fraction);
assert(w <= static_cast<uint32_t>(get_w()));
=== modified file 'src/ui_basic/progressbar.h'
--- src/ui_basic/progressbar.h 2014-09-10 14:48:40 +0000
+++ src/ui_basic/progressbar.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2009 by the Widelands Development Team
+ * Copyright (C) 2004-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -45,18 +45,18 @@
int32_t x, int32_t y, int32_t w, int32_t h,
uint32_t orientation);
- uint32_t get_state() const {return m_state;}
+ uint32_t get_state() const {return state_;}
void set_state(uint32_t);
- uint32_t get_total() const {return m_total;}
+ uint32_t get_total() const {return total_;}
void set_total(uint32_t);
protected:
void draw(RenderTarget &) override;
private:
- uint32_t m_orientation;
- uint32_t m_state; ///< m_state is [0..m_total]
- uint32_t m_total; ///< maximum progress
+ uint32_t orientation_;
+ uint32_t state_; ///< state_ is [0..total_]
+ uint32_t total_; ///< maximum progress
};
}
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/progresswindow.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2008, 2010, 2013 by the Widelands Development Team
+ * Copyright (C) 2007-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -47,7 +47,7 @@
}
ProgressWindow::~ProgressWindow() {
- for (IProgressVisualization * visualization : m_visualizations) {
+ for (IProgressVisualization * visualization : visualizations_) {
visualization->stop(); // inform visualizations
}
}
@@ -55,23 +55,23 @@
void ProgressWindow::draw_background
(RenderTarget & rt, const uint32_t xres, const uint32_t yres)
{
- m_label_center.x = xres / 2;
- m_label_center.y = yres * PROGRESS_LABEL_POSITION_Y / 100;
+ label_center_.x = xres / 2;
+ label_center_.y = yres * PROGRESS_LABEL_POSITION_Y / 100;
Rect wnd_rect(Point(0, 0), xres, yres);
const uint32_t h = UI::g_fh1->render(as_uifont("."))->height();
- m_label_rectangle.x = xres / 4;
- m_label_rectangle.w = xres / 2;
- m_label_rectangle.y =
- m_label_center.y - h / 2 - PROGRESS_STATUS_RECT_PADDING;
- m_label_rectangle.h = h + 2 * PROGRESS_STATUS_RECT_PADDING;
+ label_rectangle_.x = xres / 4;
+ label_rectangle_.w = xres / 2;
+ label_rectangle_.y =
+ label_center_.y - h / 2 - PROGRESS_STATUS_RECT_PADDING;
+ label_rectangle_.h = h + 2 * PROGRESS_STATUS_RECT_PADDING;
- const Image* bg = g_gr->images().get(m_background);
+ const Image* bg = g_gr->images().get(background_);
rt.blitrect_scale(
Rect(0, 0, xres, yres), bg, Rect(0, 0, bg->width(), bg->height()), 1., BlendMode::UseAlpha);
- Rect border_rect = m_label_rectangle;
+ Rect border_rect = label_rectangle_;
border_rect.x -= PROGRESS_STATUS_BORDER_X;
border_rect.y -= PROGRESS_STATUS_BORDER_Y;
border_rect.w += 2 * PROGRESS_STATUS_BORDER_X;
@@ -84,9 +84,9 @@
void ProgressWindow::set_background(const std::string & file_name) {
RenderTarget & rt = *g_gr->get_render_target();
if (!file_name.empty() && g_fs->file_exists(file_name)) {
- m_background = file_name;
+ background_ = file_name;
} else {
- m_background = "images/loadscreens/progress.png";
+ background_ = "images/loadscreens/progress.png";
}
draw_background(rt, g_gr->get_xres(), g_gr->get_yres());
}
@@ -100,8 +100,8 @@
// always repaint the background first
draw_background(rt, xres, yres);
- rt.fill_rect(m_label_rectangle, PROGRESS_FONT_COLOR_BG);
- rt.blit(m_label_center,
+ rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG);
+ rt.blit(label_center_,
UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG)),
BlendMode::UseAlpha,
UI::Align::kCenter);
@@ -114,7 +114,7 @@
}
void ProgressWindow::update(bool const repaint) {
- for (IProgressVisualization * visualization : m_visualizations) {
+ for (IProgressVisualization * visualization : visualizations_) {
visualization->update(repaint); // let visualizations do their work
}
g_gr->refresh();
@@ -140,18 +140,18 @@
void ProgressWindow::add_visualization(IProgressVisualization * const instance)
{
// just add to collection
- m_visualizations.push_back(instance);
+ visualizations_.push_back(instance);
}
void ProgressWindow::remove_visualization(IProgressVisualization * instance) {
- VisualizationArray & visualizations = m_visualizations;
+ VisualizationArray & visualizations = visualizations_;
for (VisualizationArray::iterator vis_iter = visualizations.begin();
vis_iter != visualizations.end();
++vis_iter) {
if (*vis_iter == instance) {
- m_visualizations.erase (vis_iter);
+ visualizations_.erase (vis_iter);
break;
}
}
=== modified file 'src/ui_basic/progresswindow.h'
--- src/ui_basic/progresswindow.h 2015-02-27 09:38:51 +0000
+++ src/ui_basic/progresswindow.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2008 by the Widelands Development Team
+ * Copyright (C) 2007-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -62,10 +62,10 @@
private:
using VisualizationArray = std::vector<IProgressVisualization *>;
- Point m_label_center;
- Rect m_label_rectangle;
- VisualizationArray m_visualizations;
- std::string m_background;
+ Point label_center_;
+ Rect label_rectangle_;
+ VisualizationArray visualizations_;
+ std::string background_;
void draw_background(RenderTarget & rt, uint32_t xres, uint32_t yres);
void update(bool repaint);
=== modified file 'src/ui_basic/radiobutton.cc'
--- src/ui_basic/radiobutton.cc 2014-10-18 13:39:27 +0000
+++ src/ui_basic/radiobutton.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -34,11 +34,11 @@
int32_t const id)
:
Statebox (parent, p, pic),
- m_nextbtn(group.m_buttons),
- m_group (group),
- m_id (id)
+ nextbtn_(group.buttons_),
+ group_ (group),
+ id_ (id)
{
- group.m_buttons = this;
+ group.buttons_ = this;
}
/**
@@ -46,9 +46,9 @@
*/
Radiobutton::~Radiobutton()
{
- for (Radiobutton * * pp = &m_group.m_buttons; *pp; pp = &(*pp)->m_nextbtn) {
+ for (Radiobutton * * pp = &group_.buttons_; *pp; pp = &(*pp)->nextbtn_) {
if (*pp == this) {
- *pp = m_nextbtn;
+ *pp = nextbtn_;
break;
}
}
@@ -60,7 +60,7 @@
*/
void Radiobutton::clicked()
{
- m_group.set_state(m_id);
+ group_.set_state(id_);
play_click();
}
@@ -78,9 +78,9 @@
*/
Radiogroup::Radiogroup()
{
- m_buttons = nullptr;
- m_highestid = -1;
- m_state = -1;
+ buttons_ = nullptr;
+ highestid_ = -1;
+ state_ = -1;
}
/**
@@ -90,7 +90,7 @@
//Scan-build claims this results in double free.
//This is a false positive.
//See https://bugs.launchpad.net/widelands/+bug/1198928
- while (m_buttons) delete m_buttons;
+ while (buttons_) delete buttons_;
}
@@ -105,11 +105,11 @@
const std::string& tooltip,
Radiobutton ** ret_btn)
{
- ++m_highestid;
- Radiobutton * btn = new Radiobutton(parent, p, pic, *this, m_highestid);
+ ++highestid_;
+ Radiobutton * btn = new Radiobutton(parent, p, pic, *this, highestid_);
btn->set_tooltip(tooltip);
if (ret_btn) (*ret_btn) = btn;
- return m_highestid;
+ return highestid_;
}
@@ -119,14 +119,14 @@
* Args: state the ID of the checked button (-1 means don't check any button)
*/
void Radiogroup::set_state(int32_t const state) {
- if (state == m_state) {
+ if (state == state_) {
clicked();
return;
}
- for (Radiobutton * btn = m_buttons; btn; btn = btn->m_nextbtn)
- btn->set_state(btn->m_id == state);
- m_state = state;
+ for (Radiobutton * btn = buttons_; btn; btn = btn->nextbtn_)
+ btn->set_state(btn->id_ == state);
+ state_ = state;
changed();
changedto(state);
}
@@ -135,7 +135,7 @@
* Disable this radiogroup
*/
void Radiogroup::set_enabled(bool st) {
- for (Radiobutton * btn = m_buttons; btn; btn = btn->m_nextbtn)
+ for (Radiobutton * btn = buttons_; btn; btn = btn->nextbtn_)
btn->set_enabled(st);
}
=== modified file 'src/ui_basic/radiobutton.h'
--- src/ui_basic/radiobutton.h 2014-11-22 10:18:20 +0000
+++ src/ui_basic/radiobutton.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2008-2011 by the Widelands Development Team
+ * Copyright (C) 2004-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -38,14 +38,14 @@
(Panel * parent, Point, const Image* pic, Radiogroup &, int32_t id);
~Radiobutton();
- Radiobutton * next_button() {return m_nextbtn;}
+ Radiobutton * next_button() {return nextbtn_;}
private:
void clicked() override;
- Radiobutton * m_nextbtn;
- Radiogroup & m_group;
- int32_t m_id;
+ Radiobutton * nextbtn_;
+ Radiogroup & group_;
+ int32_t id_;
};
/**
@@ -65,14 +65,14 @@
int32_t add_button
(Panel * parent, Point, const Image* pic, const std::string& tooltip = "", Radiobutton ** = nullptr);
- int32_t get_state() const {return m_state;}
+ int32_t get_state() const {return state_;}
void set_state(int32_t state);
void set_enabled(bool);
- Radiobutton * get_first_button() {return m_buttons;}
+ Radiobutton * get_first_button() {return buttons_;}
private:
- Radiobutton * m_buttons; // linked list of buttons (not sorted)
- int32_t m_highestid;
- int32_t m_state; // -1: none
+ Radiobutton * buttons_; // linked list of buttons (not sorted)
+ int32_t highestid_;
+ int32_t state_; // -1: none
};
}
=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/scrollbar.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011, 2013, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -46,26 +46,26 @@
bool const horiz)
:
Panel (parent, x, y, w, h),
- m_horizontal (horiz),
- m_force_draw (false),
- m_pos (0),
- m_singlestepsize(1),
- m_pagesize (5),
- m_steps (100),
- m_pressed (None),
- m_time_nextact (0),
- m_knob_grabdelta(0),
- m_pic_minus
+ horizontal_ (horiz),
+ force_draw_ (false),
+ pos_ (0),
+ singlestepsize_(1),
+ pagesize_ (5),
+ steps_ (100),
+ pressed_ (None),
+ time_nextact_ (0),
+ knob_grabdelta_(0),
+ pic_minus_
(g_gr->images().get(horiz ?
"images/ui_basic/scrollbar_left.png" :
"images/ui_basic/scrollbar_up.png")),
- m_pic_plus
+ pic_plus_
(g_gr->images().get(horiz ?
"images/ui_basic/scrollbar_right.png" :
"images/ui_basic/scrollbar_down.png")),
- m_pic_background
+ pic_background_
(g_gr->images().get("images/ui_basic/scrollbar_background.png")),
- m_pic_buttons (g_gr->images().get("images/ui_basic/but3.png"))
+ pic_buttons_ (g_gr->images().get("images/ui_basic/but3.png"))
{
set_thinks(true);
}
@@ -79,15 +79,15 @@
if (steps < 1)
steps = 1;
- if (m_pos >= static_cast<uint32_t>(steps))
+ if (pos_ >= static_cast<uint32_t>(steps))
set_scrollpos(steps - 1);
- m_steps = steps;
+ steps_ = steps;
}
bool Scrollbar::is_enabled() const {
- return m_steps != 1 || m_force_draw;
+ return steps_ != 1 || force_draw_;
}
@@ -96,7 +96,7 @@
*/
uint32_t Scrollbar::get_steps() const
{
- return m_steps;
+ return steps_;
}
@@ -108,7 +108,7 @@
if (singlestepsize < 1)
singlestepsize = 1;
- m_singlestepsize = singlestepsize;
+ singlestepsize_ = singlestepsize;
}
@@ -117,7 +117,7 @@
*/
void Scrollbar::set_pagesize(int32_t const pagesize)
{
- m_pagesize = pagesize < 1 ? 1 : pagesize;
+ pagesize_ = pagesize < 1 ? 1 : pagesize;
}
@@ -131,13 +131,13 @@
{
if (pos < 0)
pos = 0;
- if (static_cast<uint32_t>(pos) >= m_steps)
- pos = m_steps - 1;
+ if (static_cast<uint32_t>(pos) >= steps_)
+ pos = steps_ - 1;
- if (m_pos == static_cast<uint32_t>(pos))
+ if (pos_ == static_cast<uint32_t>(pos))
return;
- m_pos = pos;
+ pos_ = pos;
moved(pos);
}
@@ -153,7 +153,7 @@
return None;
// Normalize coordinates
- if (m_horizontal) {
+ if (horizontal_) {
std::swap(x, y);
extent = get_w();
} else
@@ -183,10 +183,10 @@
* Return the center of the knob, in pixels, depending on the current position.
*/
uint32_t Scrollbar::get_knob_pos() {
- assert(0 != m_steps);
+ assert(0 != steps_);
uint32_t result = Size + get_knob_size() / 2;
- if (uint32_t const d = m_steps - 1)
- result += m_pos * ((m_horizontal ? get_w() : get_h()) - 2 * result) / d;
+ if (uint32_t const d = steps_ - 1)
+ result += pos_ * ((horizontal_ ? get_w() : get_h()) - 2 * result) / d;
return result;
}
@@ -197,12 +197,12 @@
void Scrollbar::set_knob_pos(int32_t pos)
{
uint32_t knobsize = get_knob_size();
- int32_t extent = m_horizontal ? get_w() : get_h();
+ int32_t extent = horizontal_ ? get_w() : get_h();
extent -= 2 * Size + knobsize;
pos -= Size + knobsize / 2;
- pos = (pos * static_cast<int32_t>(m_steps)) / extent;
+ pos = (pos * static_cast<int32_t>(steps_)) / extent;
set_scrollpos(pos);
}
@@ -214,14 +214,14 @@
*/
uint32_t Scrollbar::get_knob_size()
{
- uint32_t extent = m_horizontal ? get_w() : get_h();
+ uint32_t extent = horizontal_ ? get_w() : get_h();
if (extent <= 3 * Size)
return Size;
uint32_t maxhalfsize = extent / 2 - Size;
uint32_t halfsize = (maxhalfsize * get_pagesize()) /
- (m_steps + get_pagesize());
+ (steps_ + get_pagesize());
uint32_t size = 2 * halfsize;
if (size < Size)
size = Size;
@@ -236,30 +236,30 @@
int32_t pos = 0;
switch (area) {
- case Minus: diff = -m_singlestepsize; break;
- case MinusPage: diff = -m_pagesize; break;
- case Plus: diff = m_singlestepsize; break;
- case PlusPage: diff = m_pagesize; break;
+ case Minus: diff = -singlestepsize_; break;
+ case MinusPage: diff = -pagesize_; break;
+ case Plus: diff = singlestepsize_; break;
+ case PlusPage: diff = pagesize_; break;
case Knob:
case None:
return;
}
- pos = static_cast<int32_t>(m_pos) + diff;
+ pos = static_cast<int32_t>(pos_) + diff;
set_scrollpos(pos);
}
void Scrollbar::draw_button(RenderTarget & dst, const Area area, const Rect r) {
- dst.tile(r, m_pic_buttons, Point(get_x(), get_y()));
+ dst.tile(r, pic_buttons_, Point(get_x(), get_y()));
// Draw the picture
const Image* pic = nullptr;
if (area == Minus)
- pic = m_pic_minus;
+ pic = pic_minus_;
else if (area == Plus)
- pic = m_pic_plus;
+ pic = pic_plus_;
if (pic) {
uint16_t cpw = pic->width();
@@ -271,7 +271,7 @@
// Draw border
RGBColor black(0, 0, 0);
- if (area != m_pressed) {
+ if (area != pressed_) {
// top edge
dst.brighten_rect(Rect(r.origin(), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
// left edge
@@ -301,9 +301,9 @@
void Scrollbar::draw_area(RenderTarget & dst, const Area area, const Rect r) {
- dst.tile(r, m_pic_background, Point(get_x(), get_y()) + r.origin());
+ dst.tile(r, pic_background_, Point(get_x(), get_y()) + r.origin());
- if (area == m_pressed)
+ if (area == pressed_)
dst.brighten_rect(r, BUTTON_EDGE_BRIGHT_FACTOR);
}
@@ -320,7 +320,7 @@
return; // Don't draw a scrollbar that doesn't do anything
}
- if (m_horizontal) {
+ if (horizontal_) {
if ((2 * Size + knobsize) > static_cast<uint32_t>(get_w())) {
// Our owner obviously allocated too little space - draw something
// stupid
@@ -383,19 +383,19 @@
{
Panel::think();
- if (m_pressed == None || m_pressed == Knob)
+ if (pressed_ == None || pressed_ == Knob)
return;
uint32_t const time = SDL_GetTicks();
- if (time < m_time_nextact)
+ if (time < time_nextact_)
return;
- action(m_pressed);
+ action(pressed_);
// Schedule next tick
- m_time_nextact += MOUSE_BUTTON_AUTOREPEAT_TICK;
- if (m_time_nextact < time)
- m_time_nextact = time;
+ time_nextact_ += MOUSE_BUTTON_AUTOREPEAT_TICK;
+ if (time_nextact_ < time)
+ time_nextact_ = time;
}
@@ -414,14 +414,14 @@
switch (btn) {
case SDL_BUTTON_LEFT:
- m_pressed = get_area_for_point(x, y);
- if (m_pressed != None) {
+ pressed_ = get_area_for_point(x, y);
+ if (pressed_ != None) {
grab_mouse(true);
- if (m_pressed != Knob) {
- action(m_pressed);
- m_time_nextact = SDL_GetTicks() + MOUSE_BUTTON_AUTOREPEAT_DELAY;
+ if (pressed_ != Knob) {
+ action(pressed_);
+ time_nextact_ = SDL_GetTicks() + MOUSE_BUTTON_AUTOREPEAT_DELAY;
} else
- m_knob_grabdelta = (m_horizontal ? x : y) - get_knob_pos();
+ knob_grabdelta_ = (horizontal_ ? x : y) - get_knob_pos();
}
result = true;
break;
@@ -436,9 +436,9 @@
switch (btn) {
case SDL_BUTTON_LEFT:
- if (m_pressed != None) {
+ if (pressed_ != None) {
grab_mouse(false);
- m_pressed = None;
+ pressed_ = None;
}
result = true;
break;
@@ -456,8 +456,8 @@
bool Scrollbar::handle_mousemove
(uint8_t, int32_t const mx, int32_t const my, int32_t, int32_t)
{
- if (m_pressed == Knob)
- set_knob_pos((m_horizontal ? mx : my) - m_knob_grabdelta);
+ if (pressed_ == Knob)
+ set_knob_pos((horizontal_ ? mx : my) - knob_grabdelta_);
return true;
}
=== modified file 'src/ui_basic/scrollbar.h'
--- src/ui_basic/scrollbar.h 2015-11-21 11:34:10 +0000
+++ src/ui_basic/scrollbar.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -59,14 +59,14 @@
bool is_enabled() const;
uint32_t get_steps() const;
- uint32_t get_singlestepsize() const {return m_singlestepsize;}
- uint32_t get_pagesize() const {return m_pagesize;}
- uint32_t get_scrollpos() const {return m_pos;}
+ uint32_t get_singlestepsize() const {return singlestepsize_;}
+ uint32_t get_pagesize() const {return pagesize_;}
+ uint32_t get_scrollpos() const {return pos_;}
bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
bool handle_mousewheel(uint32_t, int32_t, int32_t y) override;
- void set_force_draw(bool const t) {m_force_draw = t;}
+ void set_force_draw(bool const t) {force_draw_ = t;}
private:
Area get_area_for_point(int32_t x, int32_t y);
@@ -86,22 +86,22 @@
(uint8_t state, int32_t mx, int32_t my, int32_t xdiff, int32_t ydiff) override;
private:
- bool m_horizontal;
- bool m_force_draw; // draw this scrollbar, even if it can't do anything
-
- uint32_t m_pos; ///< from 0 to m_range - 1
- uint32_t m_singlestepsize;
- uint32_t m_pagesize;
- uint32_t m_steps;
-
- Area m_pressed; ///< area that the user clicked on (None if mouse is up)
- uint32_t m_time_nextact;
- int32_t m_knob_grabdelta; ///< only while m_pressed == Knob
-
- const Image* m_pic_minus; ///< left/up
- const Image* m_pic_plus; ///< right/down
- const Image* m_pic_background;
- const Image* m_pic_buttons;
+ bool horizontal_;
+ bool force_draw_; // draw this scrollbar, even if it can't do anything
+
+ uint32_t pos_; ///< from 0 to range_ - 1
+ uint32_t singlestepsize_;
+ uint32_t pagesize_;
+ uint32_t steps_;
+
+ Area pressed_; ///< area that the user clicked on (None if mouse is up)
+ uint32_t time_nextact_;
+ int32_t knob_grabdelta_; ///< only while pressed_ == Knob
+
+ const Image* pic_minus_; ///< left/up
+ const Image* pic_plus_; ///< right/down
+ const Image* pic_background_;
+ const Image* pic_buttons_;
};
}
=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/slider.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -58,17 +58,17 @@
const int32_t x_gap, const int32_t y_gap, const int32_t bar_size)
:
Panel (parent, x, y, w, h, tooltip_text),
- m_min_value (min_value),
- m_max_value (max_value),
- m_value (value),
- m_highlighted (false),
- m_pressed (false),
- m_enabled (enabled),
- m_pic_background (background_picture_id),
- m_x_gap (x_gap),
- m_y_gap (y_gap),
- m_bar_size (bar_size),
- m_cursor_size (cursor_size)
+ min_value_ (min_value),
+ max_value_ (max_value),
+ value_ (value),
+ highlighted_ (false),
+ pressed_ (false),
+ enabled_ (enabled),
+ pic_background_ (background_picture_id),
+ x_gap_ (x_gap),
+ y_gap_ (y_gap),
+ bar_size_ (bar_size),
+ cursor_size_ (cursor_size)
{
set_thinks(false);
calculate_cursor_position();
@@ -76,27 +76,27 @@
void Slider::set_value(int32_t new_value)
{
- new_value = std::max(m_min_value, std::min(new_value, m_max_value));
+ new_value = std::max(min_value_, std::min(new_value, max_value_));
- if (new_value != m_value) {
- m_value = new_value;
+ if (new_value != value_) {
+ value_ = new_value;
calculate_cursor_position();
send_value_changed();
}
}
void Slider::calculate_cursor_position() {
- if (m_max_value == m_min_value) {
- m_cursor_pos = m_min_value;
- } else if (m_value == m_min_value) {
- m_cursor_pos = 0;
- } else if (m_value == m_max_value) {
- m_cursor_pos = get_bar_size();
+ if (max_value_ == min_value_) {
+ cursor_pos_ = min_value_;
+ } else if (value_ == min_value_) {
+ cursor_pos_ = 0;
+ } else if (value_ == max_value_) {
+ cursor_pos_ = get_bar_size();
} else {
- m_cursor_pos =
- (m_value - m_min_value) * get_bar_size()
+ cursor_pos_ =
+ (value_ - min_value_) * get_bar_size()
/
- (m_max_value - m_min_value);
+ (max_value_ - min_value_);
}
}
@@ -111,12 +111,12 @@
* \param new_max The new max value.
*/
void Slider::set_max_value(int32_t new_max) {
- assert(m_min_value <= new_max);
- if (m_max_value != new_max) {
+ assert(min_value_ <= new_max);
+ if (max_value_ != new_max) {
calculate_cursor_position();
}
- m_max_value = new_max;
- set_value(m_value);
+ max_value_ = new_max;
+ set_value(value_);
}
/**
@@ -125,12 +125,12 @@
* \param new_min The new min value.
*/
void Slider::set_min_value(int32_t new_min) {
- assert(m_max_value >= new_min);
- if (m_min_value != new_min) {
+ assert(max_value_ >= new_min);
+ if (min_value_ != new_min) {
calculate_cursor_position();
}
- m_min_value = new_min;
- set_value(m_value);
+ min_value_ = new_min;
+ set_value(value_);
}
/**
@@ -150,12 +150,12 @@
RGBColor black(0, 0, 0);
dst.tile // background
- (Rect(Point(x, y), w, h), m_pic_background, Point(get_x(), get_y()));
+ (Rect(Point(x, y), w, h), pic_background_, Point(get_x(), get_y()));
- if (m_highlighted)
+ if (highlighted_)
dst.brighten_rect(Rect(Point(x, y), w, h), MOUSE_OVER_BRIGHT_FACTOR);
- if (m_pressed) { // draw border
+ if (pressed_) { // draw border
dst.brighten_rect // bottom edge
(Rect(Point(x, y + h - 2), w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
dst.brighten_rect // right edge
@@ -192,7 +192,7 @@
void Slider::send_value_changed()
{
changed();
- changedto(m_value);
+ changedto(value_);
}
@@ -204,13 +204,13 @@
void Slider::set_enabled(const bool enabled)
{
// TODO(unknown): disabled should look different...
- if (m_enabled == enabled)
+ if (enabled_ == enabled)
return;
- m_enabled = enabled;
+ enabled_ = enabled;
if (!enabled) {
- m_pressed = false;
- m_highlighted = false;
+ pressed_ = false;
+ highlighted_ = false;
grab_mouse(false);
}
}
@@ -221,10 +221,10 @@
*/
void Slider::set_highlighted(bool highlighted)
{
- if (m_highlighted == highlighted)
+ if (highlighted_ == highlighted)
return;
- m_highlighted = highlighted;
+ highlighted_ = highlighted;
}
@@ -248,9 +248,9 @@
bool Slider::handle_mouserelease(const uint8_t btn, int32_t, int32_t) {
if (btn != SDL_BUTTON_LEFT)
return false;
- if (m_pressed) {
+ if (pressed_) {
grab_mouse(false);
- m_pressed = false;
+ pressed_ = false;
// cursor position: align to integer value
calculate_cursor_position();
@@ -267,40 +267,40 @@
* \param y The y position of the mouse pointer.
*/
void Slider::cursor_moved(int32_t pointer, int32_t x, int32_t y) {
- if (!m_enabled)
+ if (!enabled_)
return;
set_highlighted
- (pointer >= m_cursor_pos && pointer <= m_cursor_pos + m_cursor_size
+ (pointer >= cursor_pos_ && pointer <= cursor_pos_ + cursor_size_
&& y >= 0 && y < get_h() && x >= 0 && x < get_w());
- if (!m_pressed)
+ if (!pressed_)
return;
- m_cursor_pos = pointer - m_relative_move;
- if (m_cursor_pos < 0)
- m_cursor_pos = 0;
- if (m_cursor_pos > get_bar_size())
- m_cursor_pos = get_bar_size();
+ cursor_pos_ = pointer - relative_move_;
+ if (cursor_pos_ < 0)
+ cursor_pos_ = 0;
+ if (cursor_pos_ > get_bar_size())
+ cursor_pos_ = get_bar_size();
// absolute value
int32_t new_value =
static_cast<int32_t>
(rint
- (static_cast<double>((m_max_value - m_min_value) * m_cursor_pos)
+ (static_cast<double>((max_value_ - min_value_) * cursor_pos_)
/
get_bar_size()));
// relative value in bounds
- new_value += m_min_value;
- if (new_value < m_min_value)
- new_value = m_min_value;
- if (new_value > m_max_value)
- new_value = m_max_value;
+ new_value += min_value_;
+ if (new_value < min_value_)
+ new_value = min_value_;
+ if (new_value > max_value_)
+ new_value = max_value_;
// updating
- if (new_value != m_value) {
- m_value = new_value;
+ if (new_value != value_) {
+ value_ = new_value;
send_value_changed();
}
}
@@ -312,13 +312,13 @@
* \param pointer The relative position of the mouse pointer.
*/
void Slider::cursor_pressed(int32_t pointer) {
- if (!m_enabled)
+ if (!enabled_)
return;
grab_mouse(true);
- m_pressed = true;
- m_highlighted = true;
- m_relative_move = pointer - m_cursor_pos;
+ pressed_ = true;
+ highlighted_ = true;
+ relative_move_ = pointer - cursor_pos_;
play_click();
}
@@ -331,41 +331,41 @@
* \param ofs The cursor offset.
*/
void Slider::bar_pressed(int32_t pointer, int32_t ofs) {
- if (!m_enabled)
+ if (!enabled_)
return;
grab_mouse(true);
- m_pressed = true;
+ pressed_ = true;
- m_cursor_pos = pointer - ofs;
+ cursor_pos_ = pointer - ofs;
// absolute value
if (get_bar_size() == 0) {
- m_value = 0;
+ value_ = 0;
} else {
- m_value =
+ value_ =
static_cast<int32_t>
(rint
- (static_cast<double>((m_max_value - m_min_value) * m_cursor_pos)
+ (static_cast<double>((max_value_ - min_value_) * cursor_pos_)
/
get_bar_size()));
}
// relative value in bounds
- if (m_value < m_min_value)
- m_value = m_min_value;
- if (m_value > m_max_value)
- m_value = m_max_value;
+ if (value_ < min_value_)
+ value_ = min_value_;
+ if (value_ > max_value_)
+ value_ = max_value_;
play_click();
send_value_changed();
- m_relative_move = ofs;
+ relative_move_ = ofs;
}
void VerticalSlider::layout() {
- m_x_gap = get_w() / 2 - 2;
- m_bar_size = get_h() - m_cursor_size;
+ x_gap_ = get_w() / 2 - 2;
+ bar_size_ = get_h() - cursor_size_;
Slider::layout();
}
@@ -402,7 +402,7 @@
dst.fill_rect(Rect(Point(get_x_gap(), get_y_gap()), 1, 4), black);
dst.fill_rect(Rect(Point(get_x_gap() + 1, get_y_gap()), 1, 3), black);
- draw_cursor(dst, m_cursor_pos, 0, m_cursor_size, get_h());
+ draw_cursor(dst, cursor_pos_, 0, cursor_size_, get_h());
}
@@ -435,7 +435,7 @@
return false;
- if (x >= m_cursor_pos && x <= m_cursor_pos + m_cursor_size) {
+ if (x >= cursor_pos_ && x <= cursor_pos_ + cursor_size_) {
// click on cursor
cursor_pressed(x);
return true;
@@ -451,8 +451,8 @@
}
void HorizontalSlider::layout() {
- m_y_gap = get_h() / 2 - 2;
- m_bar_size = get_w() - m_cursor_size;
+ y_gap_ = get_h() / 2 - 2;
+ bar_size_ = get_w() - cursor_size_;
Slider::layout();
}
@@ -486,7 +486,7 @@
dst.fill_rect(Rect(Point(get_x_gap(), get_y_gap()), 4, 1), black);
dst.fill_rect(Rect(Point(get_x_gap(), get_y_gap() + 1), 3, 1), black);
- draw_cursor(dst, 0, m_cursor_pos, get_w(), m_cursor_size);
+ draw_cursor(dst, 0, cursor_pos_, get_w(), cursor_size_);
}
@@ -516,7 +516,7 @@
if (btn != SDL_BUTTON_LEFT)
return false;
- if (y >= m_cursor_pos && y <= m_cursor_pos + m_cursor_size) {
+ if (y >= cursor_pos_ && y <= cursor_pos_ + cursor_size_) {
// click on cursor
cursor_pressed(y);
return true;
@@ -539,7 +539,7 @@
(Panel * const parent,
const int32_t x, const int32_t y, const uint32_t w, const uint32_t h,
const std::vector<std::string> labels_in,
- uint32_t m_value,
+ uint32_t value_,
const Image* background_picture_id,
const std::string & tooltip_text,
const uint32_t cursor_size,
@@ -552,7 +552,7 @@
w / (2 * labels_in.size()) - cursor_size / 2, 0,
w - (w / labels_in.size()) + cursor_size,
h - UI::g_fh1->render(as_uifont("."))->height() - 2,
- 0, labels_in.size() - 1, m_value,
+ 0, labels_in.size() - 1, value_,
background_picture_id,
tooltip_text,
cursor_size,
@@ -594,9 +594,9 @@
uint32_t w = get_w();
uint32_t h = get_h();
assert(labels.size());
- slider.set_pos(Point(w / (2 * labels.size()) - slider.m_cursor_size / 2, 0));
+ slider.set_pos(Point(w / (2 * labels.size()) - slider.cursor_size_ / 2, 0));
slider.set_size
- (w - (w / labels.size()) + slider.m_cursor_size,
+ (w - (w / labels.size()) + slider.cursor_size_,
h - UI::g_fh1->render(as_uifont("."))->height() - 2);
Panel::layout();
}
=== modified file 'src/ui_basic/slider.h'
--- src/ui_basic/slider.h 2015-10-04 19:26:02 +0000
+++ src/ui_basic/slider.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -50,9 +50,9 @@
public:
bool is_snap_target() const override {return true;}
- int32_t get_value() const {return m_value;}
- int32_t get_max_value() const {return m_max_value;}
- int32_t get_min_value() const {return m_min_value;}
+ int32_t get_value() const {return value_;}
+ int32_t get_max_value() const {return max_value_;}
+ int32_t get_min_value() const {return min_value_;}
void set_value(int32_t);
void set_max_value(int32_t);
@@ -66,9 +66,9 @@
void calculate_cursor_position();
// drawing
- int32_t get_x_gap() const {return m_x_gap;}
- int32_t get_y_gap() const {return m_y_gap;}
- int32_t get_bar_size() const {return m_bar_size;}
+ int32_t get_x_gap() const {return x_gap_;}
+ int32_t get_y_gap() const {return y_gap_;}
+ int32_t get_bar_size() const {return bar_size_;}
void draw_cursor
(RenderTarget &, int32_t x, int32_t y, int32_t w, int32_t h);
@@ -88,24 +88,24 @@
boost::signals2::signal<void (int32_t)> changedto;
private:
- int32_t m_min_value; // cursor values
- int32_t m_max_value;
- int32_t m_value;
- int32_t m_relative_move;
-
- bool m_highlighted; // mouse over
- bool m_pressed; // the cursor is pressed
- bool m_enabled; // enabled widget
-
- const Image* m_pic_background; // background texture (picture ID)
+ int32_t min_value_; // cursor values
+ int32_t max_value_;
+ int32_t value_;
+ int32_t relative_move_;
+
+ bool highlighted_; // mouse over
+ bool pressed_; // the cursor is pressed
+ bool enabled_; // enabled widget
+
+ const Image* pic_background_; // background texture (picture ID)
protected:
- int32_t m_x_gap; // draw positions
- int32_t m_y_gap;
- int32_t m_bar_size;
+ int32_t x_gap_; // draw positions
+ int32_t y_gap_;
+ int32_t bar_size_;
- int32_t m_cursor_pos; // cursor position
- int32_t m_cursor_size; // cursor width
+ int32_t cursor_pos_; // cursor position
+ int32_t cursor_size_; // cursor width
};
@@ -186,7 +186,7 @@
(Panel * const parent,
const int32_t x, const int32_t y, const uint32_t w, const uint32_t h,
const std::vector<std::string> labels_in,
- uint32_t m_value,
+ uint32_t value_,
const Image* background_picture_id,
const std::string & tooltip_text = std::string(),
const uint32_t cursor_size = 20,
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/table.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011, 2015 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -50,17 +50,17 @@
const bool descending)
:
Panel (parent, x, y, w, h),
- m_total_width (0),
- m_fontsize (UI_FONT_SIZE_SMALL),
- m_headerheight (UI::g_fh1->render(as_uifont(".", m_fontsize))->height() + 4),
- m_lineheight (UI::g_fh1->render(as_uifont(".", m_fontsize))->height()),
- m_scrollbar (nullptr),
- m_scrollpos (0),
- m_selection (no_selection_index()),
- m_last_click_time (-10000),
- m_last_selection (no_selection_index()),
- m_sort_column (0),
- m_sort_descending (descending)
+ total_width_ (0),
+ fontsize_ (UI_FONT_SIZE_SMALL),
+ headerheight_ (UI::g_fh1->render(as_uifont(".", fontsize_))->height() + 4),
+ lineheight_ (UI::g_fh1->render(as_uifont(".", fontsize_))->height()),
+ scrollbar_ (nullptr),
+ scrollpos_ (0),
+ selection_ (no_selection_index()),
+ last_click_time_ (-10000),
+ last_selection_ (no_selection_index()),
+ sort_column_ (0),
+ sort_descending_ (descending)
{
set_thinks(false);
set_can_focus(true);
@@ -72,7 +72,7 @@
*/
Table<void *>::~Table()
{
- for (const EntryRecord * entry : m_entry_records) {
+ for (const EntryRecord * entry : entry_records_) {
delete entry;
}
}
@@ -89,12 +89,12 @@
assert(size() == 0);
uint32_t complete_width = 0;
- for (const Column& col : m_columns) {
+ for (const Column& col : columns_) {
complete_width += col.width;
}
- m_total_width += width;
- set_desired_size(m_total_width, get_h());
+ total_width_ += width;
+ set_desired_size(total_width_, get_h());
{
Column c;
@@ -103,11 +103,11 @@
c.btn =
new Button
(this, title,
- complete_width, 0, width, m_headerheight,
+ complete_width, 0, width, headerheight_,
g_gr->images().get("images/ui_basic/but3.png"),
title, tooltip_string, true, false);
c.btn->sigclicked.connect
- (boost::bind(&Table::header_button_clicked, boost::ref(*this), m_columns.size()));
+ (boost::bind(&Table::header_button_clicked, boost::ref(*this), columns_.size()));
}
c.width = width;
c.alignment = alignment;
@@ -116,41 +116,41 @@
if (is_checkbox_column) {
c.compare = boost::bind
(&Table<void *>::default_compare_checkbox,
- this, m_columns.size(), _1, _2);
+ this, columns_.size(), _1, _2);
} else {
c.compare = boost::bind
(&Table<void *>::default_compare_string,
- this, m_columns.size(), _1, _2);
+ this, columns_.size(), _1, _2);
}
- m_columns.push_back(c);
+ columns_.push_back(c);
}
- if (!m_scrollbar) {
- m_scrollbar =
+ if (!scrollbar_) {
+ scrollbar_ =
new Scrollbar
(get_parent(),
- get_x() + get_w() - 24, get_y() + m_headerheight,
- 24, get_h() - m_headerheight,
+ get_x() + get_w() - 24, get_y() + headerheight_,
+ 24, get_h() - headerheight_,
false);
- m_scrollbar->moved.connect(boost::bind(&Table::set_scrollpos, this, _1));
- m_scrollbar->set_steps(1);
- m_scrollbar->set_singlestepsize(m_lineheight);
- m_scrollbar->set_pagesize(get_h() - m_lineheight);
+ scrollbar_->moved.connect(boost::bind(&Table::set_scrollpos, this, _1));
+ scrollbar_->set_steps(1);
+ scrollbar_->set_singlestepsize(lineheight_);
+ scrollbar_->set_pagesize(get_h() - lineheight_);
}
}
void Table<void *>::set_column_title(uint8_t const col, const std::string & title)
{
- assert(col < m_columns.size());
- Column & column = m_columns.at(col);
+ assert(col < columns_.size());
+ Column & column = columns_.at(col);
if (!column.btn && !title.empty()) { // no title before, but now
uint32_t complete_width = 0;
for (uint8_t i = 0; i < col; ++i)
- complete_width += m_columns.at(i).width;
+ complete_width += columns_.at(i).width;
column.btn =
new Button
(this, title,
- complete_width, 0, column.width, m_headerheight,
+ complete_width, 0, column.width, headerheight_,
g_gr->images().get("images/ui_basic/but3.png"),
title, "", true, false);
column.btn->sigclicked.connect
@@ -170,15 +170,15 @@
void Table<void *>::set_column_compare
(uint8_t col, const Table<void *>::CompareFn & fn)
{
- assert(col < m_columns.size());
- Column & column = m_columns.at(col);
+ assert(col < columns_.size());
+ Column & column = columns_.at(col);
column.compare = fn;
}
void Table<void *>::EntryRecord::set_checked
(uint8_t const col, bool const checked)
{
- _data & cell = m_data.at(col);
+ _data & cell = data_.at(col);
cell.d_checked = checked;
cell.d_picture =
@@ -194,7 +194,7 @@
bool Table<void *>::EntryRecord::is_checked(uint8_t const col) const {
- const _data & cell = m_data.at(col);
+ const _data & cell = data_.at(col);
return cell.d_checked;
}
@@ -203,7 +203,7 @@
(const void * const entry) const
{
- for (EntryRecord * temp_entry : m_entry_records) {
+ for (EntryRecord * temp_entry : entry_records_) {
if (temp_entry->entry() == entry) {
return temp_entry;
}
@@ -215,7 +215,7 @@
* A header button has been clicked
*/
void Table<void *>::header_button_clicked(Columns::size_type const n) {
- assert(m_columns.at(n).btn);
+ assert(columns_.at(n).btn);
if (get_sort_colum() == n) {
set_sort_descending(!get_sort_descending()); // change sort direction
sort();
@@ -232,17 +232,17 @@
*/
void Table<void *>::clear()
{
- for (const EntryRecord * entry : m_entry_records) {
+ for (const EntryRecord * entry : entry_records_) {
delete entry;
}
- m_entry_records.clear();
+ entry_records_.clear();
- if (m_scrollbar)
- m_scrollbar->set_steps(1);
- m_scrollpos = 0;
- m_selection = no_selection_index();
- m_last_click_time = -10000;
- m_last_selection = no_selection_index();
+ if (scrollbar_)
+ scrollbar_->set_steps(1);
+ scrollpos_ = 0;
+ selection_ = no_selection_index();
+ last_click_time_ = -10000;
+ last_selection_ = no_selection_index();
}
@@ -253,7 +253,7 @@
int tablewidth;
int tableheight;
get_desired_size(&tablewidth, &tableheight);
- tableheight = m_headerheight + 2 + get_lineheight() * entries;
+ tableheight = headerheight_ + 2 + get_lineheight() * entries;
set_desired_size(tablewidth, tableheight);
}
@@ -264,27 +264,27 @@
{
// draw text lines
int32_t lineheight = get_lineheight();
- uint32_t idx = m_scrollpos / lineheight;
- int32_t y = 1 + idx * lineheight - m_scrollpos + m_headerheight;
+ uint32_t idx = scrollpos_ / lineheight;
+ int32_t y = 1 + idx * lineheight - scrollpos_ + headerheight_;
dst.brighten_rect(Rect(Point(0, 0), get_w(), get_h()), ms_darken_value);
- while (idx < m_entry_records.size()) {
+ while (idx < entry_records_.size()) {
if (y >= static_cast<int32_t>(get_h()))
return;
- const EntryRecord & er = *m_entry_records[idx];
+ const EntryRecord & er = *entry_records_[idx];
- if (idx == m_selection) {
+ if (idx == selection_) {
assert(2 <= get_eff_w());
dst.brighten_rect
- (Rect(Point(1, y), get_eff_w() - 2, m_lineheight),
+ (Rect(Point(1, y), get_eff_w() - 2, lineheight_),
-ms_darken_value);
}
- Columns::size_type const nr_columns = m_columns.size();
+ Columns::size_type const nr_columns = columns_.size();
for (uint32_t i = 0, curx = 0; i < nr_columns; ++i) {
- const Column& column = m_columns[i];
+ const Column& column = columns_[i];
int const curw = column.width;
Align alignment = mirror_alignment(column.alignment);
@@ -309,8 +309,8 @@
int blit_width = image_scale * picw;
if (entry_string.empty()) {
- if (i == nr_columns - 1 && m_scrollbar->is_enabled()) {
- draw_x = point.x + (curw - blit_width - m_scrollbar->get_w()) / 2;
+ if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
+ draw_x = point.x + (curw - blit_width - scrollbar_->get_w()) / 2;
} else {
draw_x = point.x + (curw - blit_width) / 2;
}
@@ -328,8 +328,8 @@
picw = blit_width;
} else {
if (entry_string.empty()) {
- if (i == nr_columns - 1 && m_scrollbar->is_enabled()) {
- draw_x = point.x + (curw - picw - m_scrollbar->get_w()) / 2;
+ if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
+ draw_x = point.x + (curw - picw - scrollbar_->get_w()) / 2;
} else {
draw_x = point.x + (curw - picw) / 2;
}
@@ -347,7 +347,7 @@
curx += curw;
continue;
}
- const Image* entry_text_im = UI::g_fh1->render(as_uifont(richtext_escape(entry_string), m_fontsize));
+ const Image* entry_text_im = UI::g_fh1->render(as_uifont(richtext_escape(entry_string), fontsize_));
if (static_cast<int>(alignment & UI::Align::kRight)) {
point.x += curw - 2 * picw;
@@ -357,8 +357,8 @@
// Add an offset for rightmost column when the scrollbar is shown.
int text_width = entry_text_im->width();
- if (i == nr_columns - 1 && m_scrollbar->is_enabled()) {
- text_width = text_width + m_scrollbar->get_w();
+ if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
+ text_width = text_width + scrollbar_->get_w();
}
UI::correct_for_align(alignment, text_width, entry_text_im->height(), &point);
@@ -415,7 +415,7 @@
bool Table<void *>::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
- return m_scrollbar->handle_mousewheel(which, x, y);
+ return scrollbar_->handle_mousewheel(which, x, y);
}
/**
@@ -433,23 +433,23 @@
// This hick hack is needed if any of the callback functions calls clear
// to forget the last clicked time.
- uint32_t const real_last_click_time = m_last_click_time;
+ uint32_t const real_last_click_time = last_click_time_;
- m_last_selection = m_selection;
- m_last_click_time = time;
+ last_selection_ = selection_;
+ last_click_time_ = time;
uint32_t const row =
- (y + m_scrollpos - m_headerheight) / get_lineheight();
- if (row < m_entry_records.size()) {
+ (y + scrollpos_ - headerheight_) / get_lineheight();
+ if (row < entry_records_.size()) {
select(row);
- Columns::size_type const nr_cols = m_columns.size();
+ Columns::size_type const nr_cols = columns_.size();
for (uint8_t col = 0; col < nr_cols; ++col) {
- const Column & column = m_columns.at(col);
+ const Column & column = columns_.at(col);
x -= column.width;
if (x <= 0) {
if (column.is_checkbox_column) {
play_click();
- m_entry_records.at(row)->toggle(col);
+ entry_records_.at(row)->toggle(col);
}
break;
}
@@ -459,9 +459,9 @@
if // check if doubleclicked
(time - real_last_click_time < DOUBLE_CLICK_INTERVAL
&&
- m_last_selection == m_selection
- && m_selection != no_selection_index())
- double_clicked(m_selection);
+ last_selection_ == selection_
+ && selection_ != no_selection_index())
+ double_clicked(selection_);
return true;
}
@@ -482,32 +482,32 @@
void Table<void *>::move_selection(const int32_t offset)
{
if (!has_selection()) return;
- int32_t new_selection = m_selection + offset;
+ int32_t new_selection = selection_ + offset;
if (new_selection < 0) new_selection = 0;
- else if (static_cast<uint32_t>(new_selection) > m_entry_records.size() - 1)
- new_selection = m_entry_records.size() - 1;
+ else if (static_cast<uint32_t>(new_selection) > entry_records_.size() - 1)
+ new_selection = entry_records_.size() - 1;
select(static_cast<uint32_t>(new_selection));
//scroll to newly selected entry
- if (m_scrollbar)
+ if (scrollbar_)
{
// Keep an unselected item above or below
int32_t scroll_item = new_selection + offset;
if (scroll_item < 0) scroll_item = 0;
- if (scroll_item > static_cast<int32_t>(m_entry_records.size())) {
- scroll_item = m_entry_records.size();
+ if (scroll_item > static_cast<int32_t>(entry_records_.size())) {
+ scroll_item = entry_records_.size();
}
// Ensure scroll_item is visible
- if (static_cast<int32_t>(scroll_item * get_lineheight()) < m_scrollpos) {
- m_scrollbar->set_scrollpos(scroll_item * get_lineheight());
+ if (static_cast<int32_t>(scroll_item * get_lineheight()) < scrollpos_) {
+ scrollbar_->set_scrollpos(scroll_item * get_lineheight());
} else if
(static_cast<int32_t>((scroll_item + 1) * get_lineheight() - get_inner_h())
- > m_scrollpos)
+ > scrollpos_)
{
- m_scrollbar->set_scrollpos((scroll_item + 1) * get_lineheight() - get_inner_h());
+ scrollbar_->set_scrollpos((scroll_item + 1) * get_lineheight() - get_inner_h());
}
}
}
@@ -519,12 +519,12 @@
*/
void Table<void *>::select(const uint32_t i)
{
- if (empty() || m_selection == i)
+ if (empty() || selection_ == i)
return;
- m_selection = i;
+ selection_ = i;
- selected(m_selection);
+ selected(selection_);
}
/**
@@ -534,22 +534,22 @@
(void * const entry, const bool do_select)
{
EntryRecord & result = *new EntryRecord(entry);
- m_entry_records.push_back(&result);
- result.m_data.resize(m_columns.size());
- for (size_t i = 0; i < m_columns.size(); ++i)
- if (m_columns.at(i).is_checkbox_column) {
- result.m_data.at(i).d_picture =
+ entry_records_.push_back(&result);
+ result.data_.resize(columns_.size());
+ for (size_t i = 0; i < columns_.size(); ++i)
+ if (columns_.at(i).is_checkbox_column) {
+ result.data_.at(i).d_picture =
g_gr->images().get("images/ui_basic/checkbox_empty.png");
}
- m_scrollbar->set_steps
- (m_entry_records.size() * get_lineheight()
+ scrollbar_->set_steps
+ (entry_records_.size() * get_lineheight()
-
- (get_h() - m_headerheight - 2));
+ (get_h() - headerheight_ - 2));
if (do_select) {
- select(m_entry_records.size() - 1);
- m_scrollbar->set_scrollpos(std::numeric_limits<int32_t>::max());
+ select(entry_records_.size() - 1);
+ scrollbar_->set_scrollpos(std::numeric_limits<int32_t>::max());
}
return result;
}
@@ -559,35 +559,35 @@
*/
void Table<void *>::set_scrollpos(int32_t const i)
{
- m_scrollpos = i;
+ scrollpos_ = i;
}
/**
* Remove the table entry at the given (zero-based) index.
*/
void Table<void *>::remove(const uint32_t i) {
- assert(i < m_entry_records.size());
+ assert(i < entry_records_.size());
- const EntryRecordVector::iterator it = m_entry_records.begin() + i;
+ const EntryRecordVector::iterator it = entry_records_.begin() + i;
delete *it;
- m_entry_records.erase(it);
- if (m_selection == i)
- m_selection = no_selection_index();
- else if (m_selection > i && m_selection != no_selection_index())
- m_selection--;
+ entry_records_.erase(it);
+ if (selection_ == i)
+ selection_ = no_selection_index();
+ else if (selection_ > i && selection_ != no_selection_index())
+ selection_--;
- m_scrollbar->set_steps
- (m_entry_records.size() * get_lineheight()
+ scrollbar_->set_steps
+ (entry_records_.size() * get_lineheight()
-
- (get_h() - m_headerheight - 2));
+ (get_h() - headerheight_ - 2));
}
bool Table<void *>::sort_helper(uint32_t a, uint32_t b)
{
- if (m_sort_descending)
- return m_columns[m_sort_column].compare(b, a);
+ if (sort_descending_)
+ return columns_[sort_column_].compare(b, a);
else
- return m_columns[m_sort_column].compare(a, b);
+ return columns_[sort_column_].compare(a, b);
}
/**
@@ -599,8 +599,8 @@
*/
void Table<void *>::sort(const uint32_t Begin, uint32_t End)
{
- assert(m_columns.at(m_sort_column).btn);
- assert(m_sort_column < m_columns.size());
+ assert(columns_.at(sort_column_).btn);
+ assert(sort_column_ < columns_.size());
if (End > size())
End = size();
@@ -612,21 +612,21 @@
copy.reserve(End - Begin);
for (uint32_t i = Begin; i < End; ++i) {
indices.push_back(i);
- copy.push_back(m_entry_records[i]);
+ copy.push_back(entry_records_[i]);
}
std::stable_sort
(indices.begin(), indices.end(),
boost::bind(&Table<void *>::sort_helper, this, _1, _2));
- uint32_t newselection = m_selection;
+ uint32_t newselection = selection_;
for (uint32_t i = Begin; i < End; ++i) {
uint32_t from = indices[i - Begin];
- m_entry_records[i] = copy[from - Begin];
- if (m_selection == from)
+ entry_records_[i] = copy[from - Begin];
+ if (selection_ == from)
newselection = i;
}
- m_selection = newselection;
+ selection_ = newselection;
}
/**
@@ -650,37 +650,37 @@
}
Table<void *>::EntryRecord::EntryRecord(void * const e)
- : m_entry(e), use_clr(false)
+ : entry_(e), use_clr(false)
{}
void Table<void *>::EntryRecord::set_picture
(uint8_t const col, const Image* pic, const std::string & str)
{
- assert(col < m_data.size());
+ assert(col < data_.size());
- m_data.at(col).d_picture = pic;
- m_data.at(col).d_string = str;
+ data_.at(col).d_picture = pic;
+ data_.at(col).d_string = str;
}
void Table<void *>::EntryRecord::set_string
(uint8_t const col, const std::string & str)
{
- assert(col < m_data.size());
+ assert(col < data_.size());
- m_data.at(col).d_picture = nullptr;
- m_data.at(col).d_string = str;
+ data_.at(col).d_picture = nullptr;
+ data_.at(col).d_string = str;
}
const Image* Table<void *>::EntryRecord::get_picture(uint8_t const col) const
{
- assert(col < m_data.size());
+ assert(col < data_.size());
- return m_data.at(col).d_picture;
+ return data_.at(col).d_picture;
}
const std::string & Table<void *>::EntryRecord::get_string
(uint8_t const col) const
{
- assert(col < m_data.size());
+ assert(col < data_.size());
- return m_data.at(col).d_string;
+ return data_.at(col).d_string;
}
}
=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h 2016-01-28 21:27:04 +0000
+++ src/ui_basic/table.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2011, 2015-2016 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -36,13 +36,16 @@
struct Scrollbar;
struct Button;
-/// A table with columns and lines. The entries can be sorted by columns by
-/// clicking on the column header button.
-///
-/// Entry can be
-/// 1. a reference type,
-/// 2. a pointer type or
-/// 3. uintptr_t.
+/** A table with columns and lines.
+ *
+ * The entries can be sorted by columns by
+ * clicking on the column header button.
+ *
+ * Entry can be
+ * 1. a reference type,
+ * 2. a pointer type or
+ * 3. uintptr_t.
+ */
template<typename Entry> class Table {
public:
struct EntryRecord {
@@ -122,7 +125,7 @@
void set_string(uint8_t col, const std::string &);
const Image* get_picture(uint8_t col) const;
const std::string & get_string(uint8_t col) const;
- void * entry() const {return m_entry;}
+ void * entry() const {return entry_;}
void set_color(const RGBColor c) {
use_clr = true;
clr = c;
@@ -137,7 +140,7 @@
private:
friend class Table<void *>;
- void * m_entry;
+ void * entry_;
bool use_clr;
RGBColor clr;
struct _data {
@@ -147,7 +150,7 @@
_data() : d_checked(false) {}
};
- std::vector<_data> m_data;
+ std::vector<_data> data_;
};
/**
@@ -178,13 +181,13 @@
void clear();
void set_sort_column(uint8_t const col) {
- assert(col < m_columns.size());
- m_sort_column = col;
+ assert(col < columns_.size());
+ sort_column_ = col;
}
- uint8_t get_sort_colum() const {return m_sort_column;}
- bool get_sort_descending() const {return m_sort_descending;}
+ uint8_t get_sort_colum() const {return sort_column_;}
+ bool get_sort_descending() const {return sort_descending_;}
void set_sort_descending(bool const descending) {
- m_sort_descending = descending;
+ sort_descending_ = descending;
}
void sort
@@ -194,22 +197,22 @@
EntryRecord & add(void * entry = nullptr, bool select = false);
- uint32_t size() const {return m_entry_records.size();}
- bool empty() const {return m_entry_records.empty();}
+ uint32_t size() const {return entry_records_.size();}
+ bool empty() const {return entry_records_.empty();}
void * operator[](uint32_t const i) const {
- assert(i < m_entry_records.size());
- return m_entry_records[i]->entry();
+ assert(i < entry_records_.size());
+ return entry_records_[i]->entry();
}
static uint32_t no_selection_index() {
return std::numeric_limits<uint32_t>::max();
}
bool has_selection() const {
- return m_selection != no_selection_index();
+ return selection_ != no_selection_index();
}
- uint32_t selection_index() const {return m_selection;}
+ uint32_t selection_index() const {return selection_;}
EntryRecord & get_record(uint32_t const n) const {
- assert(n < m_entry_records.size());
- return *m_entry_records[n];
+ assert(n < entry_records_.size());
+ return *entry_records_[n];
}
static void * get(const EntryRecord & er) {return er.entry();}
EntryRecord * find(const void * entry) const;
@@ -222,19 +225,19 @@
}
};
EntryRecord & get_selected_record() const {
- if (m_selection == no_selection_index())
+ if (selection_ == no_selection_index())
throw NoSelection();
- assert(m_selection < m_entry_records.size());
- return *m_entry_records.at(m_selection);
+ assert(selection_ < entry_records_.size());
+ return *entry_records_.at(selection_);
}
void remove_selected() {
- if (m_selection == no_selection_index())
+ if (selection_ == no_selection_index())
throw NoSelection();
- remove(m_selection);
+ remove(selection_);
}
void * get_selected() const {return get_selected_record().entry();}
- uint32_t get_lineheight() const {return m_lineheight + 2;}
+ uint32_t get_lineheight() const {return lineheight_ + 2;}
uint32_t get_eff_w () const {return get_w();}
/// Adjust the desired size to fit the height needed for the number of entries.
@@ -265,22 +268,22 @@
static const int32_t ms_darken_value = -20;
- Columns m_columns;
- uint32_t m_total_width;
- uint32_t m_fontsize;
- uint32_t m_headerheight;
- int32_t m_lineheight;
- Scrollbar * m_scrollbar;
- int32_t m_scrollpos; // in pixels
- uint32_t m_selection;
- uint32_t m_last_click_time;
- uint32_t m_last_selection; // for double clicks
- Columns::size_type m_sort_column;
- bool m_sort_descending;
+ Columns columns_;
+ uint32_t total_width_;
+ uint32_t fontsize_;
+ uint32_t headerheight_;
+ int32_t lineheight_;
+ Scrollbar * scrollbar_;
+ int32_t scrollpos_; // in pixels
+ uint32_t selection_;
+ uint32_t last_click_time_;
+ uint32_t last_selection_; // for double clicks
+ Columns::size_type sort_column_;
+ bool sort_descending_;
void header_button_clicked(Columns::size_type);
using EntryRecordVector = std::vector<EntryRecord *>;
- EntryRecordVector m_entry_records;
+ EntryRecordVector entry_records_;
void set_scrollpos(int32_t pos);
};
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc 2016-01-30 22:26:21 +0000
+++ src/ui_basic/textarea.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,8 +30,8 @@
const std::string & text, Align align)
:
Panel (parent, x, y, 0, 0),
- m_layoutmode(AutoMove),
- m_align (align)
+ layoutmode_(AutoMove),
+ align_ (align)
{
init();
set_text(text);
@@ -43,8 +43,8 @@
Align align)
:
Panel (parent, x, y, w, h),
- m_layoutmode(AutoMove),
- m_align (align)
+ layoutmode_(AutoMove),
+ align_ (align)
{
init();
}
@@ -55,8 +55,8 @@
const std::string & text, Align align)
:
Panel (parent, x, y, w, h),
- m_layoutmode(AutoMove),
- m_align (align)
+ layoutmode_(AutoMove),
+ align_ (align)
{
init();
set_text(text);
@@ -68,8 +68,8 @@
Align align)
:
Panel(parent, 0, 0, 0, 0),
-m_layoutmode(Layouted),
-m_align(align)
+layoutmode_(Layouted),
+align_(align)
{
init();
set_text(text);
@@ -91,20 +91,20 @@
*/
void Textarea::set_textstyle(const TextStyle & style)
{
- if (m_textstyle == style)
+ if (textstyle_ == style)
return;
- if (m_layoutmode == AutoMove)
+ if (layoutmode_ == AutoMove)
collapse();
- m_textstyle = style;
+ textstyle_ = style;
rendered_text_ = UI::g_fh1->render(
- as_uifont(m_text,
- m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
- m_textstyle.fg));
+ as_uifont(text_,
+ textstyle_.font->size() - UI::g_fh1->fontset().size_offset(),
+ textstyle_.fg));
- if (m_layoutmode == AutoMove)
+ if (layoutmode_ == AutoMove)
expand();
- else if (m_layoutmode == Layouted)
+ else if (layoutmode_ == Layouted)
update_desired_size();
}
@@ -122,26 +122,26 @@
*/
void Textarea::set_text(const std::string & text)
{
- if (m_text == text)
+ if (text_ == text)
return;
- if (m_layoutmode == AutoMove)
+ if (layoutmode_ == AutoMove)
collapse(); // collapse() implicitly updates
- m_text = text;
+ text_ = text;
rendered_text_ = UI::g_fh1->render(
- as_uifont(m_text,
- m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
- m_textstyle.fg));
- if (m_layoutmode == AutoMove)
+ as_uifont(text_,
+ textstyle_.font->size() - UI::g_fh1->fontset().size_offset(),
+ textstyle_.fg));
+ if (layoutmode_ == AutoMove)
expand();
- else if (m_layoutmode == Layouted)
+ else if (layoutmode_ == Layouted)
update_desired_size();
}
const std::string& Textarea::get_text()
{
- return m_text;
+ return text_;
}
@@ -158,14 +158,14 @@
*/
void Textarea::draw(RenderTarget & dst)
{
- if (!m_text.empty()) {
+ if (!text_.empty()) {
Point anchor
- (static_cast<int>(m_align & UI::Align::kHCenter) ?
- get_w() / 2 : static_cast<int>(m_align & UI::Align::kRight) ? get_w() : 0,
- static_cast<int>(m_align & UI::Align::kVCenter) ?
- get_h() / 2 : static_cast<int>(m_align & UI::Align::kBottom) ? get_h() : 0);
+ (static_cast<int>(align_ & UI::Align::kHCenter) ?
+ get_w() / 2 : static_cast<int>(align_ & UI::Align::kRight) ? get_w() : 0,
+ static_cast<int>(align_ & UI::Align::kVCenter) ?
+ get_h() / 2 : static_cast<int>(align_ & UI::Align::kBottom) ? get_h() : 0);
- dst.blit(anchor, rendered_text_, BlendMode::UseAlpha, m_align);
+ dst.blit(anchor, rendered_text_, BlendMode::UseAlpha, align_);
}
}
@@ -180,14 +180,14 @@
int32_t w = get_w();
int32_t h = get_h();
- if (static_cast<int>(m_align & UI::Align::kHCenter))
+ if (static_cast<int>(align_ & UI::Align::kHCenter))
x += w >> 1;
- else if (static_cast<int>(m_align & UI::Align::kRight))
+ else if (static_cast<int>(align_ & UI::Align::kRight))
x += w;
- if (static_cast<int>(m_align & UI::Align::kVCenter))
+ if (static_cast<int>(align_ & UI::Align::kVCenter))
y += h >> 1;
- else if (static_cast<int>(m_align & UI::Align::kBottom))
+ else if (static_cast<int>(align_ & UI::Align::kBottom))
y += h;
set_pos(Point(x, y));
@@ -207,14 +207,14 @@
int w, h;
get_desired_size(&w, &h);
- if (static_cast<int>(m_align & UI::Align::kHCenter))
+ if (static_cast<int>(align_ & UI::Align::kHCenter))
x -= w >> 1;
- else if (static_cast<int>(m_align & UI::Align::kRight))
+ else if (static_cast<int>(align_ & UI::Align::kRight))
x -= w;
- if (static_cast<int>(m_align & UI::Align::kVCenter))
+ if (static_cast<int>(align_ & UI::Align::kVCenter))
y -= h >> 1;
- else if (static_cast<int>(m_align & UI::Align::kBottom))
+ else if (static_cast<int>(align_ & UI::Align::kBottom))
y -= h;
set_pos(Point(x, y));
@@ -233,11 +233,11 @@
w = fixed_width_ > 0 ? fixed_width_ : rendered_text_->width();
h = rendered_text_->height();
// We want empty textareas to have height
- if (m_text.empty()) {
+ if (text_.empty()) {
h = UI::g_fh1->render(
as_uifont(".",
- m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
- m_textstyle.fg))->height();
+ textstyle_.font->size() - UI::g_fh1->fontset().size_offset(),
+ textstyle_.fg))->height();
}
}
set_desired_size(w, h);
=== modified file 'src/ui_basic/textarea.h'
--- src/ui_basic/textarea.h 2016-01-28 21:27:04 +0000
+++ src/ui_basic/textarea.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -82,7 +82,7 @@
void draw(RenderTarget &) override;
void set_textstyle(const UI::TextStyle & style);
- const UI::TextStyle & get_textstyle() const {return m_textstyle;}
+ const UI::TextStyle & get_textstyle() const {return textstyle_;}
void set_font(const std::string & name, int size, RGBColor clr);
@@ -100,11 +100,11 @@
void collapse();
void expand();
- LayoutMode m_layoutmode;
- std::string m_text;
+ LayoutMode layoutmode_;
+ std::string text_;
const Image* rendered_text_;
- Align m_align;
- UI::TextStyle m_textstyle;
+ Align align_;
+ UI::TextStyle textstyle_;
uint32_t fixed_width_;
};
=== modified file 'src/ui_basic/unique_window.cc'
--- src/ui_basic/unique_window.cc 2014-07-20 07:46:24 +0000
+++ src/ui_basic/unique_window.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2007, 2009 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -77,19 +77,19 @@
const std::string & title)
:
Window (parent, name, 0, 0, w, h, title.c_str()),
- m_registry (reg),
- m_usedefaultpos(true)
+ registry_ (reg),
+ usedefaultpos_(true)
{
- if (m_registry) {
- delete m_registry->window;
+ if (registry_) {
+ delete registry_->window;
- m_registry->window = this;
- if (m_registry->valid_pos) {
- set_pos(Point(m_registry->x, m_registry->y));
- m_usedefaultpos = false;
+ registry_->window = this;
+ if (registry_->valid_pos) {
+ set_pos(Point(registry_->x, registry_->y));
+ usedefaultpos_ = false;
}
- if (m_registry->on_create) {
- m_registry->on_create();
+ if (registry_->on_create) {
+ registry_->on_create();
}
}
}
@@ -100,16 +100,16 @@
*/
UniqueWindow::~UniqueWindow()
{
- if (m_registry) {
- assert(m_registry->window == this);
-
- m_registry->window = nullptr;
- m_registry->x = get_x();
- m_registry->y = get_y();
- m_registry->valid_pos = true;
-
- if (m_registry->on_delete) {
- m_registry->on_delete();
+ if (registry_) {
+ assert(registry_->window == this);
+
+ registry_->window = nullptr;
+ registry_->x = get_x();
+ registry_->y = get_y();
+ registry_->valid_pos = true;
+
+ if (registry_->on_delete) {
+ registry_->on_delete();
}
}
}
=== modified file 'src/ui_basic/unique_window.h'
--- src/ui_basic/unique_window.h 2014-11-22 10:18:20 +0000
+++ src/ui_basic/unique_window.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006, 2008-2009 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -70,11 +70,11 @@
const std::string & title);
virtual ~UniqueWindow();
- bool get_usedefaultpos() {return m_usedefaultpos;}
+ bool get_usedefaultpos() {return usedefaultpos_;}
private:
- Registry * m_registry;
- bool m_usedefaultpos;
+ Registry * registry_;
+ bool usedefaultpos_;
};
}
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2016-01-31 21:03:15 +0000
+++ src/ui_basic/window.cc 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2011 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -81,18 +81,18 @@
_docked_left(false), _docked_right(false), _docked_bottom(false),
_drag_start_win_x(0), _drag_start_win_y(0),
_drag_start_mouse_x(0), _drag_start_mouse_y(0),
- m_pic_lborder
+ pic_lborder_
(g_gr->images().get("images/wui/window_left.png")),
- m_pic_rborder
+ pic_rborder_
(g_gr->images().get("images/wui/window_right.png")),
- m_pic_top
+ pic_top_
(g_gr->images().get("images/wui/window_top.png")),
- m_pic_bottom
+ pic_bottom_
(g_gr->images().get("images/wui/window_bottom.png")),
- m_pic_background
+ pic_background_
(g_gr->images().get("images/wui/window_background.png")),
- m_center_panel(nullptr),
- m_fastclick_panel(nullptr)
+ center_panel_(nullptr),
+ fastclick_panel_(nullptr)
{
set_title(title);
@@ -109,7 +109,7 @@
*/
void Window::set_title(const string & text)
{
- m_title = is_richtext(text) ? text : as_window_title(text);
+ title_ = is_richtext(text) ? text : as_window_title(text);
}
/**
@@ -122,7 +122,7 @@
{
assert(panel->get_parent() == this);
- m_center_panel = panel;
+ center_panel_ = panel;
update_desired_size();
}
@@ -131,9 +131,9 @@
*/
void Window::update_desired_size()
{
- if (m_center_panel) {
+ if (center_panel_) {
int innerw, innerh;
- m_center_panel->get_desired_size(&innerw, &innerh);
+ center_panel_->get_desired_size(&innerw, &innerh);
set_desired_size
(innerw + get_lborder() + get_rborder(),
innerh + get_tborder() + get_bborder());
@@ -146,9 +146,9 @@
*/
void Window::layout()
{
- if (m_center_panel && !_is_minimal) {
- m_center_panel->set_pos(Point(0, 0));
- m_center_panel->set_size(get_inner_w(), get_inner_h());
+ if (center_panel_ && !_is_minimal) {
+ center_panel_->set_pos(Point(0, 0));
+ center_panel_->set_size(get_inner_w(), get_inner_h());
}
}
@@ -179,9 +179,9 @@
* Moves the mouse to the child panel that is activated as fast click panel
*/
void Window::warp_mouse_to_fastclick_panel() {
- if (m_fastclick_panel) {
- Point pt(m_fastclick_panel->get_w() / 2, m_fastclick_panel->get_h() / 2);
- UI::Panel * p = m_fastclick_panel;
+ if (fastclick_panel_) {
+ Point pt(fastclick_panel_->get_w() / 2, fastclick_panel_->get_h() / 2);
+ UI::Panel * p = fastclick_panel_;
while (p->get_parent() && p != this) {
pt = p->to_parent(pt);
@@ -263,7 +263,7 @@
if (!is_minimal()) {
dst.tile
(Rect(Point(0, 0), get_inner_w(), get_inner_h()),
- m_pic_background, Point(0, 0));
+ pic_background_, Point(0, 0));
}
}
@@ -286,7 +286,7 @@
dst.blitrect // top left corner
(Point(0, 0),
- m_pic_top,
+ pic_top_,
Rect(Point(0, 0), pos, TP_B_PIXMAP_THICKNESS));
// top bar
@@ -294,7 +294,7 @@
for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(pos, 0),
- m_pic_top,
+ pic_top_,
Rect
(Point(HZ_B_CORNER_PIXMAP_LEN, 0),
HZ_B_MIDDLE_PIXMAP_LEN, TP_B_PIXMAP_THICKNESS));
@@ -304,17 +304,17 @@
assert(0 <= HZ_B_TOTAL_PIXMAP_LEN - width);
dst.blitrect
(Point(pos, 0),
- m_pic_top,
+ pic_top_,
Rect
(Point(HZ_B_TOTAL_PIXMAP_LEN - width, 0),
width, TP_B_PIXMAP_THICKNESS));
}
// draw the title if we have one
- if (!m_title.empty()) {
+ if (!title_.empty()) {
dst.blit
(Point(get_lborder() + get_inner_w() / 2, TP_B_PIXMAP_THICKNESS / 2),
- UI::g_fh1->render(m_title),
+ UI::g_fh1->render(title_),
BlendMode::UseAlpha,
UI::Align::kCenter);
}
@@ -330,7 +330,7 @@
static_assert(0 <= VT_B_PIXMAP_THICKNESS, "assert(0 <= VT_B_PIXMAP_THICKNESS) failed.");
dst.blitrect // left top thingy
(Point(0, TP_B_PIXMAP_THICKNESS),
- m_pic_lborder,
+ pic_lborder_,
Rect(Point(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
@@ -340,7 +340,7 @@
for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(0, pos),
- m_pic_lborder,
+ pic_lborder_,
Rect
(Point(0, VT_B_THINGY_PIXMAP_LEN),
VT_B_PIXMAP_THICKNESS, VT_B_MIDDLE_PIXMAP_LEN));
@@ -350,7 +350,7 @@
assert(0 <= VT_B_TOTAL_PIXMAP_LEN - height);
dst.blitrect
(Point(0, pos),
- m_pic_lborder,
+ pic_lborder_,
Rect
(Point(0, VT_B_TOTAL_PIXMAP_LEN - height),
VT_B_PIXMAP_THICKNESS, height));
@@ -362,7 +362,7 @@
dst.blitrect // right top thingy
(Point(right_border_x, TP_B_PIXMAP_THICKNESS),
- m_pic_rborder,
+ pic_rborder_,
Rect(Point(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
@@ -372,7 +372,7 @@
for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(right_border_x, pos),
- m_pic_rborder,
+ pic_rborder_,
Rect
(Point(0, VT_B_THINGY_PIXMAP_LEN),
VT_B_PIXMAP_THICKNESS, VT_B_MIDDLE_PIXMAP_LEN));
@@ -381,7 +381,7 @@
const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;
dst.blitrect
(Point(right_border_x, pos),
- m_pic_rborder,
+ pic_rborder_,
Rect
(Point(0, VT_B_TOTAL_PIXMAP_LEN - height),
VT_B_PIXMAP_THICKNESS, height));
@@ -392,14 +392,14 @@
dst.blitrect // bottom left corner
(Point(0, get_h() - BT_B_PIXMAP_THICKNESS),
- m_pic_bottom,
+ pic_bottom_,
Rect(Point(0, 0), pos, BT_B_PIXMAP_THICKNESS));
// bottom bar
for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(pos, get_h() - BT_B_PIXMAP_THICKNESS),
- m_pic_bottom,
+ pic_bottom_,
Rect
(Point(HZ_B_CORNER_PIXMAP_LEN, 0),
HZ_B_MIDDLE_PIXMAP_LEN, BT_B_PIXMAP_THICKNESS));
@@ -408,7 +408,7 @@
const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;
dst.blitrect
(Point(pos, get_h() - BT_B_PIXMAP_THICKNESS),
- m_pic_bottom,
+ pic_bottom_,
Rect
(Point(HZ_B_TOTAL_PIXMAP_LEN - width, 0),
width, BT_B_PIXMAP_THICKNESS));
=== modified file 'src/ui_basic/window.h'
--- src/ui_basic/window.h 2014-11-22 10:49:37 +0000
+++ src/ui_basic/window.h 2016-02-03 18:13:14 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2006-2008 by the Widelands Development Team
+ * Copyright (C) 2002-2016 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -26,7 +26,7 @@
/**
* Windows are cached by default.
*
- * The graphics (see m_pic_*) are used in the following manner: (Example)
+ * The graphics (see pic__*) are used in the following manner: (Example)
*
* top:
* <--20leftmostpixel_of_top-->
@@ -62,14 +62,14 @@
const std::string& title);
void set_title(const std::string &);
- const std::string & get_title() const {return m_title;}
+ const std::string & get_title() const {return title_;}
void set_center_panel(Panel * panel);
void move_out_of_the_way();
void move_inside_parent() override;
void center_to_parent();
void warp_mouse_to_fastclick_panel();
- void set_fastclick_panel(Panel * p) {m_fastclick_panel = p;}
+ void set_fastclick_panel(Panel * p) {fastclick_panel_ = p;}
bool is_minimal() const {return _is_minimal;}
void restore ();
@@ -100,16 +100,16 @@
int32_t _drag_start_win_x, _drag_start_win_y;
int32_t _drag_start_mouse_x, _drag_start_mouse_y;
- std::string m_title;
-
- const Image* m_pic_lborder;
- const Image* m_pic_rborder;
- const Image* m_pic_top;
- const Image* m_pic_bottom;
- const Image* m_pic_background;
-
- Panel * m_center_panel;
- Panel * m_fastclick_panel;
+ std::string title_;
+
+ const Image* pic_lborder_;
+ const Image* pic_rborder_;
+ const Image* pic_top_;
+ const Image* pic_bottom_;
+ const Image* pic_background_;
+
+ Panel * center_panel_;
+ Panel * fastclick_panel_;
};
}