testing loadingscreen animation
this adds a simple animation to the gui2 loadingscreen. It not very good yet, it more about testing whether animations are possible.
This commit is contained in:
parent
91130a3df2
commit
e1777a1f14
3 changed files with 34 additions and 1 deletions
|
@ -115,6 +115,28 @@
|
|||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
vertical_alignment = "center"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[label]
|
||||
text_alignment = "center"
|
||||
definition = "default_large"
|
||||
id = "test_animation"
|
||||
label = "...................."
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ REGISTER_DIALOG(loadscreen)
|
|||
tloadscreen::tloadscreen(boost::function<void()> f)
|
||||
: window_(NULL)
|
||||
, timer_id_(0)
|
||||
, animation_counter_(0)
|
||||
, work_(f)
|
||||
, worker_()
|
||||
, cursor_setter_()
|
||||
|
@ -78,6 +79,8 @@ void tloadscreen::pre_show(twindow& window)
|
|||
timer_id_ = add_timer(100, boost::bind(&tloadscreen::timer_callback, this, boost::ref(window)), true);
|
||||
cursor_setter_.reset(new cursor::setter(cursor::WAIT));
|
||||
progress_stage_label_ = &find_widget<tlabel>(&window, "status", false);
|
||||
animation_label_ = &find_widget<tlabel>(&window, "test_animation", false);
|
||||
|
||||
}
|
||||
|
||||
void tloadscreen::post_show(twindow& /*window*/)
|
||||
|
@ -109,7 +112,13 @@ void tloadscreen::timer_callback(twindow& window)
|
|||
{
|
||||
current_visible_stage_ = current_stage_;
|
||||
progress_stage_label_->set_label(current_visible_stage_);
|
||||
|
||||
}
|
||||
++animation_counter_;
|
||||
if (animation_counter_ % 2 == 0) {
|
||||
int animation_state = (animation_counter_ / 2) % 20;
|
||||
std::string s(20, ' ');
|
||||
s[animation_state] = '.';
|
||||
animation_label_->set_label(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
private:
|
||||
twindow* window_;
|
||||
size_t timer_id_;
|
||||
int animation_counter_;
|
||||
boost::function<void()> work_;
|
||||
boost::scoped_ptr<boost::thread> worker_;
|
||||
boost::scoped_ptr<cursor::setter> cursor_setter_;
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
void post_show(twindow& window);
|
||||
|
||||
tlabel* progress_stage_label_;
|
||||
tlabel* animation_label_;
|
||||
static tloadscreen* current_load;
|
||||
|
||||
//Note we cannot use std::strings here unless we we explicitly use mutexes.
|
||||
|
|
Loading…
Add table
Reference in a new issue