本文整理汇总了C++中twindow::invalidate_layout方法的典型用法代码示例。如果您正苦于以下问题:C++ twindow::invalidate_layout方法的具体用法?C++ twindow::invalidate_layout怎么用?C++ twindow::invalidate_layout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twindow
的用法示例。
在下文中一共展示了twindow::invalidate_layout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pre_show
void pre_show(twindow& window)
{
LOG_CHAT_LOG << "Entering tchat_log::view::pre_show" << std::endl;
controller_.update_view_from_model(true);
window.invalidate_layout(); // workaround for assertion failure
LOG_CHAT_LOG << "Exiting tchat_log::view::pre_show" << std::endl;
}
示例2: update_selected_tod_info
void teditor_settings::update_selected_tod_info(twindow& window)
{
bool custom = custom_tod_toggle_->get_value();
if (custom) {
current_tod_label_->set_label(_("Custom setting"));
} else {
std::stringstream ss;
ss << (current_tod_ + 1);
ss << "/" << tods_.size();
ss << ": " << get_selected_tod().name;
current_tod_label_->set_label(ss.str());
/**
* @todo Implement the showing of the ToD icon.
*
* Note at the moment the icon is a label widget, should become an
* image widget.
*/
//current_tod_image_->set_icon_name(get_selected_tod().image);
custom_tod_red_->set_value(get_selected_tod().red);
custom_tod_green_->set_value(get_selected_tod().green);
custom_tod_blue_->set_value(get_selected_tod().blue);
custom_tod_red_field_->set_cache_value(get_selected_tod().red);
custom_tod_green_field_->set_cache_value(get_selected_tod().green);
custom_tod_blue_field_->set_cache_value(get_selected_tod().blue);
}
custom_tod_red_->set_active(custom);
custom_tod_green_->set_active(custom);
custom_tod_blue_->set_active(custom);
current_tod_label_->set_active(!custom);
update_tod_display(window);
window.invalidate_layout();
}
示例3: update_relation
void tlobby_player_info::update_relation(twindow& w)
{
add_to_friends_->set_active(false);
add_to_ignores_->set_active(false);
remove_from_list_->set_active(false);
switch(info_.relation) {
case user_info::FRIEND:
relation_->set_label(_("On friends list"));
add_to_ignores_->set_active(true);
remove_from_list_->set_active(true);
break;
case user_info::IGNORED:
relation_->set_label(_("On ignores list"));
add_to_friends_->set_active(true);
remove_from_list_->set_active(true);
break;
case user_info::NEUTRAL:
relation_->set_label(_("Neither a friend nor ignored"));
add_to_friends_->set_active(true);
add_to_ignores_->set_active(true);
break;
case user_info::ME:
relation_->set_label(_("You"));
break;
default:
relation_->set_label(_("Error"));
}
w.invalidate_layout();
}
示例4: update_tod_display
void tcustom_tod::update_tod_display(twindow& window)
{
image::set_color_adjustment(tod_red_field_->get_value(),
tod_green_field_->get_value(),
tod_blue_field_->get_value());
if(!display_) {
return;
}
// Prevent a floating slice of window appearing alone over the
// theme UI sidebar after redrawing tiles and before we have a
// chance to redraw the rest of this window.
window.undraw();
// NOTE: We only really want to re-render the gamemap tiles here.
// Redrawing everything is a significantly more expensive task.
// At this time, tiles are the only elements on which ToD tint is
// meant to have a visible effect. This is very strongly tied to
// the image caching mechanism.
//
// If this ceases to be the case in the future, you'll need to call
// redraw_everything() instead.
// invalidate all tiles so they are redrawn with the new ToD tint next
display_->invalidate_all();
// redraw tiles
display_->draw(false);
window.invalidate_layout();
}
示例5: pre_show
void pre_show(twindow& window)
{
model_.clear_sides();
controller_.show_sides_list();
model_.clear_nicks();
controller_.update_view_from_model();
window.invalidate_layout(); // workaround for assertion failure
}
示例6: update_current_generator_label
void teditor_generate_map::update_current_generator_label(twindow& window)
{
std::stringstream ss;
ss << lexical_cast<std::string>(current_map_generator_ + 1);
ss << "/" << lexical_cast<std::string>(map_generators_.size());
ss << ": " << get_selected_map_generator()->name() << ", " << get_selected_map_generator()->config_name();
current_generator_label_->set_label(ss.str());
window.invalidate_layout();
}
示例7: display_savegame
void tgame_load::display_savegame(twindow& window)
{
const int selected_row = savegame_list_->get_selected_row();
twidget& preview_pane =
find_widget<twidget>(&window, "preview_pane", false);
if (selected_row == -1) {
preview_pane.set_visible(twidget::HIDDEN);
} else if (current_page_ == LOCAL_PAGE) {
preview_pane.set_visible(twidget::VISIBLE);
savegame::save_info& game = games_[selected_row];
filename_ = game.name;
config cfg_summary;
std::string dummy;
try {
savegame::manager::load_summary(game.name, cfg_summary, &dummy);
} catch(game::load_game_failed&) {
cfg_summary["corrupt"] = "yes";
}
find_widget<timage>(&window, "imgLeader", false).
set_label(cfg_summary["leader_image"]);
find_widget<tminimap>(&window, "minimap", false).
set_map_data(cfg_summary["map_data"]);
find_widget<tlabel>(&window, "lblScenario", false).set_label(game.name);
std::stringstream str;
str << format_time_local(cfg_summary["create"].to_long()) << "\n";
str << _("Total time") << ": " << format_time_elapse(cfg_summary["duration"].to_int());
str << "(" << help::tintegrate::generate_format(cfg_summary["hash"].to_int(), "yellow") << ")";
evaluate_summary_string(str, cfg_summary);
find_widget<tlabel>(&window, "lblSummary", false).set_label(str.str());
window.invalidate_layout();
} else if (current_page_ == NETWORK_PAGE) {
preview_pane.set_visible(twidget::VISIBLE);
savegame::www_save_info& game = www_saves_[selected_row];
filename_ = game.name;
find_widget<tminimap>(&window, "minimap", false).set_map_data("");
find_widget<tlabel>(&window, "lblScenario", false).set_label(game.name);
find_widget<tlabel>(&window, "lblSummary", false).set_label("");
}
}
示例8: campaign_selected
void tcampaign_selection::campaign_selected(twindow& window, tlistbox& list, const int type)
{
const int selected_row = list.get_selected_row();
tscrollbar_panel& multi_page = find_widget<tscrollbar_panel>(&window, "campaign_details", false);
tscroll_label& label = find_widget<tscroll_label>(&window, "description", false);
label.set_label(campaigns_[selected_row].description);
tcontrol& image = find_widget<tcontrol>(&window, "image", false);
image.set_label(campaigns_[selected_row].image);
window.invalidate_layout();
}
示例9: show_preferences_button_callback
void tlobby_main::show_preferences_button_callback(twindow& window)
{
if(preferences_callback_) {
preferences_callback_();
/**
* The screen size might have changed force an update of the size.
*
* @todo This might no longer be needed when gui2 is done.
*/
window.invalidate_layout();
wesnothd_connection_.send_data(config("refresh_lobby"));
}
}
示例10: update_tip
void ttitle_screen::update_tip(twindow& window, const bool previous)
{
next_tip_of_day(tips_, previous);
const config *tip = get_tip_of_day(tips_);
assert(tip);
find_widget<tlabel>(&window, "tip", false).set_label((*tip)["text"]);
find_widget<tlabel>(&window, "source", false).set_label((*tip)["source"]);
/**
* @todo Convert the code to use a multi_page so the invalidate is not
* needed.
*/
window.invalidate_layout();
}
示例11: refresh_according_to_hero
//.........这里部分代码省略.........
replaced_hero = &u.second();
}
} else if (prev_captain_ == 2) {
if (u.third().valid()) {
replaced_hero = &u.third();
}
}
if (!replaced_hero && curr == candidate_heros_.size()) {
sprintf(id, "candidate_hero%u", curr);
toggle = find_widget<ttoggle_button>(&window, id, false, false);
toggle->set_value(false);
return;
} else if (u.type()->require() == unit_type::REQUIRE_LEADER) {
if (replaced_hero && replaced_hero->official_ == hero_official_leader) {
sprintf(id, "candidate_hero%u", curr);
toggle = find_widget<ttoggle_button>(&window, id, false, false);
toggle->set_value(false);
return;
}
} else if (u.type()->require() == unit_type::REQUIRE_FEMALE) {
if (replaced_hero && curr != candidate_heros_.size() && candidate_heros_[curr]->gender_ != hero_gender_female) {
bool other_has_female = false;
if (candidate_heros_[curr]->official_ != hero_official_leader) {
if (u.master().number_ != replaced_hero->number_ && u.master().gender_ == hero_gender_female) {
other_has_female = true;
}
if (!other_has_female && u.second().valid() && u.second().number_ != replaced_hero->number_ && u.second().gender_ == hero_gender_female) {
other_has_female = true;
}
if (!other_has_female && u.third().valid() && u.third().number_ != replaced_hero->number_ && u.third().gender_ == hero_gender_female) {
other_has_female = true;
}
} else {
other_has_female = candidate_heros_[curr]->gender_ == hero_gender_female;
}
if (!other_has_female) {
sprintf(id, "candidate_hero%u", curr);
toggle = find_widget<ttoggle_button>(&window, id, false, false);
toggle->set_value(false);
return;
}
}
}
// replace!!
std::vector<hero*> used_heros;
used_heros.push_back(&u.master());
if (u.second().valid()) {
used_heros.push_back(&u.second());
}
if (u.third().valid()) {
used_heros.push_back(&u.third());
}
if (prev_captain_ < (int)used_heros.size()) {
used_heros.erase(used_heros.begin() + prev_captain_);
}
if (curr != candidate_heros_.size()) {
used_heros.push_back(candidate_heros_[curr]);
}
// sort
std::sort(used_heros.begin(), used_heros.end(), sort_recruit(u.type()));
u.replace_captains(used_heros);
// update candidate heros
if (replaced_hero) {
if (curr != candidate_heros_.size()) {
candidate_heros_[curr] = replaced_hero;
} else {
candidate_heros_.push_back(replaced_hero);
}
// sort
// std::sort(candidate_heros_.begin(), candidate_heros_.end(), compare_leadership);
} else if (curr != candidate_heros_.size()) {
candidate_heros_.erase(candidate_heros_.begin() + curr);
}
sprintf(id, "candidate_hero%u", curr);
toggle = find_widget<ttoggle_button>(&window, id, false, false);
toggle->set_value(false);
refresh_buttons_from_armory_cfg(window);
if (rpg::stratum == hero_stratum_citizen) {
bool found = false;
for (size_t i = reserve_heros_; i < candidate_heros_.size(); i ++) {
if (candidate_heros_[i] == rpg::h) {
found = true;
break;
}
}
tbutton* ok = find_widget<tbutton>(&window, "ok", false, false);
ok->set_active(!found);
}
window.invalidate_layout();
}
示例12: refresh_according_to_troop
void tcamp_armory::refresh_according_to_troop(twindow& window, const int curr)
{
std::stringstream str;
size_t i;
if (candidate_troops_.empty()) {
return;
}
if (prev_troop_ == curr) {
if (prev_troop_ != -1) {
str.str("");
str << "candidate_troop" << prev_troop_;
ttoggle_button* prev_troop = find_widget<ttoggle_button>(&window, str.str(), false, false);
prev_troop->set_value(true);
}
return;
}
if (prev_troop_ != -1) {
str.str("");
str << "candidate_troop" << prev_troop_;
ttoggle_button* prev_troop = find_widget<ttoggle_button>(&window, str.str(), false, false);
prev_troop->set_value(false);
prev_troop->set_dirty();
window.invalidate_layout();
}
// current troop
str.str("");
str << "candidate_troop" << curr;
ttoggle_button* curr_troop = find_widget<ttoggle_button>(&window, str.str(), false, false);
// curr_troop->set_value(true);
curr_troop->set_dirty();
// remember this index
prev_troop_ = curr;
unit& u = *candidate_troops_[curr];
ttoggle_button* toggle = NULL;
toggle = find_widget<ttoggle_button>(&window, "hero0", false, false);
for (i = 0; i < 6; i ++) {
toggle->canvas()[i].set_variable("image", variant(u.master().image()));
}
toggle->set_value(false);
toggle = find_widget<ttoggle_button>(&window, "hero1", false, false);
for (i = 0; i < 6; i ++) {
if (u.second().valid()) {
toggle->canvas()[i].set_variable("image", variant(u.second().image()));
} else {
toggle->canvas()[i].set_variable("image", variant(""));
}
}
toggle->set_value(false);
toggle = find_widget<ttoggle_button>(&window, "hero2", false, false);
for (i = 0; i < 6; i ++) {
if (u.third().valid()) {
toggle->canvas()[i].set_variable("image", variant(u.third().image()));
} else {
toggle->canvas()[i].set_variable("image", variant(""));
}
}
toggle->set_value(false);
int last_captain;
if (u.second().valid()) {
toggle->set_active(true);
if (u.third().valid()) {
last_captain = 2;
} else {
last_captain = 1;
}
} else {
toggle->set_active(false);
last_captain = 0;
}
if (prev_captain_ == 0) {
prev_captain_ = -1;
}
refresh_according_to_captain(window, (last_captain + 1) % 3);
// image of arms
toggle = find_widget<ttoggle_button>(&window, "arms_image", false, false);
update_troop_ui2(toggle, &u);
toggle->set_active(false);
tlabel* label;
/* // leadership
label = find_widget<tlabel>(&window, "tip_leadership", false, true);
label->set_label(lexical_cast<std::string>(u.leadership_));
// force
label = find_widget<tlabel>(&window, "tip_force", false, true);
label->set_label(lexical_cast<std::string>(u.force_));
// intellect
//.........这里部分代码省略.........
示例13: handle_nicks_list_item_clicked
void handle_nicks_list_item_clicked(twindow& window)
{
controller_.handle_nicks_list_item_clicked();
window.invalidate_layout(); // workaround for assertion failure
}
示例14: fill_exile_table
//.........这里部分代码省略.........
tlistbox* list = find_widget<tlistbox>(&window, "type_list", false, true);
list->clear();
const std::vector<tgroup::tmember>& exiles = group_.exiles();
for (std::vector<tgroup::tmember>::const_iterator it = exiles.begin(); it != exiles.end(); ++ it) {
const tgroup::tmember& m = *it;
hero& h = *m.h;
/*** Add list item ***/
string_map list_item;
std::map<std::string, string_map> list_item_item;
strstr.str("");
strstr << (std::distance(exiles.begin(), it) + 1);
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("index", list_item));
strstr.str("");
strstr << h.image();
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("icon", list_item));
// name
strstr.str("");
if (h.utype_ != HEROS_NO_UTYPE) {
const unit_type* ut = unit_types.keytype(h.utype_);
strstr << tintegrate::generate_img(ut->icon()) << "\n";
}
strstr << h.name();
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("name", list_item));
// level
strstr.str("");
if (m.level / game_config::levels_per_rank >= 2) {
strstr << _("rank^Gold");
} else if (m.level / game_config::levels_per_rank >= 1) {
strstr << _("rank^Silver");
} else {
strstr << _("rank^Copper");
}
strstr << "(" << (m.level % game_config::levels_per_rank + 1) << ")";
list_item["label"] = "--";
list_item_item.insert(std::make_pair("level", list_item));
// cost
strstr.str("");
value = h.cost_;
strstr << value;
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("cost", list_item));
// leadership
strstr.str("");
strstr << fxptoi9(h.leadership_);
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("leadership", list_item));
// charm
strstr.str("");
strstr << fxptoi9(h.charm_);
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("charm", list_item));
// feature
strstr.str("");
strstr << hero::feature_str(h.feature_);
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("feature", list_item));
// tactic
strstr.str("");
if (h.tactic_ != HEROS_NO_TACTIC) {
strstr << unit_types.tactic(h.tactic_).name();
} else if (m.base->tactic_ != HEROS_NO_TACTIC) {
strstr << tintegrate::generate_format(unit_types.tactic(m.base->tactic_).name(), "red");
}
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("tactic", list_item));
list->add_row(list_item_item);
tgrid* grid = list->get_row_grid(list->get_item_count() - 1);
ttoggle_panel* toggle = dynamic_cast<ttoggle_panel*>(grid->find("_toggle", true));
toggle->set_data(h.number_);
}
if (cursel >= (int)exiles.size()) {
cursel = (int)exiles.size() - 1;
}
if (!exiles.empty()) {
list->select_row(cursel);
}
selected_number_ = exiles.size()? exiles[cursel].h->number_: HEROS_INVALID_NUMBER;
refresh_title_flag(window);
set_2button_active(window);
window.invalidate_layout();
}
示例15: filter
void filter(twindow& window)
{
controller_.filter();
window.invalidate_layout(); // workaround for assertion failure
}