Redimensionnement correct de la toolbar
This commit is contained in:
		
							parent
							
								
									2426addc11
								
							
						
					
					
						commit
						6c6411f34a
					
				|  | @ -49,6 +49,11 @@ public: | |||
|      * Récupère la fenêtre de la barre d'outils | ||||
|      */ | ||||
|     sfg::Window::Ptr getWindow(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Récupère la taille désirée par la barre d'outils | ||||
|      */ | ||||
|     float getWidth(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -330,10 +330,9 @@ void Editor::draw() { | |||
|     widget_timer.draw(sf::Vector2f(window_size.x / 2 - 50, 0)); | ||||
| 
 | ||||
|     // on redimensionne la toolbar pour qu'elle occupe l'espace droite
 | ||||
|     const sfg::Window::Ptr& toolbar_window = toolbar.getWindow(); | ||||
|     toolbar_window->SetAllocation(sf::FloatRect( | ||||
|         window_size.x - 200, 0, | ||||
|         200, window_size.y | ||||
|     toolbar.getWindow()->SetAllocation(sf::FloatRect( | ||||
|         window_size.x - toolbar.getWidth(), 0, | ||||
|         toolbar.getWidth(), window_size.y | ||||
|     )); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,6 +29,9 @@ Toolbar::Toolbar(Editor& editor) : editor(editor) { | |||
|     toolbar_box->PackEnd(save_button); | ||||
| 
 | ||||
|     // ajout des créateurs de blocs
 | ||||
|     toolbar_box->PackEnd(sfg::Separator::Create()); | ||||
|     toolbar_box->PackEnd(sfg::Label::Create(L"Type d'objet à placer")); | ||||
| 
 | ||||
|     addCreator(L"Bloc normal", std::bind(&Toolbar::createBlock, this)); | ||||
|     addCreator(L"Caisse", std::bind(&Toolbar::createMovableBlock, this)); | ||||
|     addCreator(L"Joueur", std::bind(&Toolbar::createPlayer, this)); | ||||
|  | @ -54,16 +57,15 @@ Toolbar::Toolbar(Editor& editor) : editor(editor) { | |||
| 
 | ||||
|     // création de la fenêtre de la barre d'outils
 | ||||
|     scrolled_zone = sfg::ScrolledWindow::Create(); | ||||
|     toolbar_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); | ||||
| 
 | ||||
|     scrolled_zone->SetScrollbarPolicy( | ||||
|         sfg::ScrolledWindow::ScrollbarPolicy::VERTICAL_AUTOMATIC | | ||||
|         sfg::ScrolledWindow::ScrollbarPolicy::HORIZONTAL_NEVER | ||||
|     ); | ||||
| 
 | ||||
|     scrolled_zone->AddWithViewport(toolbar_box); | ||||
| 
 | ||||
| 	toolbar_window = sfg::Window::Create(sfg::Window::Style::BACKGROUND); | ||||
|     toolbar_window->Add(scrolled_zone); | ||||
|     toolbar_window->SetPosition(sf::Vector2f(0, 0)); | ||||
| } | ||||
| 
 | ||||
| void Toolbar::addCreator(sf::String label, std::function<Object::Ptr()> creator) { | ||||
|  | @ -122,3 +124,7 @@ Object::Ptr Toolbar::createObject() { | |||
| sfg::Window::Ptr Toolbar::getWindow() { | ||||
|     return toolbar_window; | ||||
| } | ||||
| 
 | ||||
| float Toolbar::getWidth() { | ||||
|     return scrolled_zone->GetRequisition().x; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue