|
|
@ -9,34 +9,49 @@ ActionToolbar::ActionToolbar() : left_buttons_count(0) { |
|
|
|
toolbar_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); |
|
|
|
toolbar_window->Add(toolbar_box); |
|
|
|
|
|
|
|
// ajout du timer et des espaceurs
|
|
|
|
// ajout du timer, des boutons et des espaceurs
|
|
|
|
sfg::Alignment::Ptr left_spacer = sfg::Alignment::Create(); |
|
|
|
sfg::Alignment::Ptr right_spacer = sfg::Alignment::Create(); |
|
|
|
|
|
|
|
timer_buttons_box = sfg::Box::Create(sfg::Box::Orientation::VERTICAL); |
|
|
|
timer_button_up = createButton("arrow_up"); |
|
|
|
timer_button_down = createButton("arrow_down"); |
|
|
|
timer_label = sfg::Label::Create("00:00"); |
|
|
|
timer_label->SetClass("timer"); |
|
|
|
|
|
|
|
left_spacer->SetRequisition(sf::Vector2f(5.f, 1.f)); |
|
|
|
timer_label->SetClass("timer"); |
|
|
|
right_spacer->SetRequisition(sf::Vector2f(5.f, 1.f)); |
|
|
|
|
|
|
|
timer_buttons_box->PackEnd(timer_button_up, false, false); |
|
|
|
timer_buttons_box->PackEnd(timer_button_down, false, false); |
|
|
|
|
|
|
|
toolbar_box->PackEnd(left_spacer, true, false); |
|
|
|
toolbar_box->PackEnd(timer_label); |
|
|
|
toolbar_box->PackEnd(timer_label, false, false); |
|
|
|
toolbar_box->PackEnd(timer_buttons_box, false, false); |
|
|
|
timer_buttons_box->Show(false); |
|
|
|
toolbar_box->PackEnd(right_spacer, true, false); |
|
|
|
|
|
|
|
// pour les styles
|
|
|
|
toolbar_window->SetId("action_toolbar"); |
|
|
|
} |
|
|
|
|
|
|
|
sfg::Button::Ptr ActionToolbar::addButton( |
|
|
|
std::string name, Utility::Direction direction, |
|
|
|
int position, std::function<void()> callback |
|
|
|
) { |
|
|
|
sfg::Button::Ptr ActionToolbar::createButton(std::string name) { |
|
|
|
// création d'un bouton avec pour image l'image passée
|
|
|
|
sfg::Button::Ptr button = sfg::Button::Create(""); |
|
|
|
button->SetClass("notext"); |
|
|
|
button->SetClass("icon"); |
|
|
|
button->SetImage(sfg::Image::Create( |
|
|
|
*ResourceManager::get().getImage("toolbar/icon_" + name + ".tga") |
|
|
|
)); |
|
|
|
|
|
|
|
return button; |
|
|
|
} |
|
|
|
|
|
|
|
sfg::Button::Ptr ActionToolbar::addButton( |
|
|
|
std::string name, Utility::Direction direction, |
|
|
|
int position, std::function<void()> callback |
|
|
|
) { |
|
|
|
sfg::Button::Ptr button = createButton(name); |
|
|
|
|
|
|
|
// liaison du bouton avec la callback, s'il y en a une
|
|
|
|
if (callback) { |
|
|
|
button->GetSignal(sfg::Widget::OnLeftClick).Connect(callback); |
|
|
@ -44,7 +59,7 @@ sfg::Button::Ptr ActionToolbar::addButton( |
|
|
|
|
|
|
|
// ajout du bouton à la barre selon la position donnée
|
|
|
|
if (direction == Utility::Direction::WEST) { |
|
|
|
position += left_buttons_count + 3; |
|
|
|
position += left_buttons_count + 4; |
|
|
|
} else { |
|
|
|
left_buttons_count++; |
|
|
|
} |
|
|
@ -85,3 +100,18 @@ void ActionToolbar::setTime(int set_time) { |
|
|
|
|
|
|
|
timer_label->SetText(minutes + ":" + seconds); |
|
|
|
} |
|
|
|
|
|
|
|
void ActionToolbar::setTimeEditable( |
|
|
|
std::function<void()> up_callback, |
|
|
|
std::function<void()> down_callback |
|
|
|
) { |
|
|
|
// si on passe des callbacks vides, on désactive l'édition du temps
|
|
|
|
if (!up_callback || !down_callback) { |
|
|
|
timer_buttons_box->Show(false); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
timer_buttons_box->Show(true); |
|
|
|
timer_button_up->GetSignal(sfg::Widget::OnLeftClick).Connect(up_callback); |
|
|
|
timer_button_down->GetSignal(sfg::Widget::OnLeftClick).Connect(down_callback); |
|
|
|
} |
|
|
|