void Bouton::ajuster ( ) { sf::Vector2i tailleTexte = {m_texte.getGlobalBounds().width, m_texte.getGlobalBounds().height} ; sf::Vector2i tailleIcone = {m_icone.getSize().x, m_icone.getSize().y} ; m_size.x = ( tailleTexte.x > tailleIcone.x ) ? tailleTexte.x + 2*m_marge.x : tailleIcone.x + 2*m_marge.x ; m_size.y = ( tailleTexte.y > tailleIcone.y ) ? tailleTexte.y + 2*m_marge.y : tailleIcone.y + 2*m_marge.y ; actualiser(); }
Plante::Racine::Racine ( Plante* plante ) : m_parent ( plante ) , m_angle ( rand()% 360 ) { int rayon = 1; m_shape.setRadius ( rayon ); m_shape.setOrigin ( rayon,rayon ); m_shape.setFillColor ( sf::Color ( 78, 193, 68) ); actualiser(); }
void Plante::Racine::pousser ( ) { float val = ( rand()% 10000 ) / 100. ; float max = 2. / m_shape.getRadius (); bool test = ( val < max ); float increment = 0.1; std::string txtTmp ="test : " + toString( test ) + "\nrayon : " + toString( m_shape.getRadius () ) + "\nmax : " + toString( max ) + "\nval : " + toString( val ); m_parent->m_texte.setString( txtTmp ); if (test) { m_shape.setRadius ( m_shape.getRadius () + increment ); actualiser(); } }
Plante::Plante ( std::shared_ptr<Etage> etage ) : m_etageParent ( etage ) , m_age ( 0 ) //, m_age ( rand()% 1000 ) { int rayon = 6; m_shape.setRadius ( rayon ); m_shape.setOrigin ( rayon,rayon ); m_shape.setFillColor ( sf::Color( 150, 80,50) ); m_texte.setCharacterSize ( 10 ); m_texte.setColor ( sf::Color( 255 , 255, 255, 100 ) ); m_texte.setFont ( app::Config::ms_polices.get ( app::Config::Polices::police_1 ) ); actualiser(); }
VueGraphique::VueGraphique(int argc, char ** argv, Controleur & controleur) : Vue(controleur), _kit(argc, argv) { // la fenêtre principale _window.set_title("Viewer de bouteilles"); _window.set_size_request(400, 300); _window.set_resizable(false); _window.set_border_width(5); // ScrolledWindow : la fenêtre avec scrolling contenant le TextView _scrolledWindow.add(_textView); _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _box.pack_start(_scrolledWindow); _window.add(_box); _window.show_all(); actualiser(); // TODO virer ca, c'etait juste pour tester }
Bouton::Bouton ( ) : m_etat ( Repos ) , m_alphaRepos ( 50 ) , m_alphaSurvol ( 200 ) , m_alphaPresse ( 255 ) { sf::Vector2i marge = { 5, 5 }; /// Initialisation du texte SFML. m_texte.setCharacterSize ( 10 ); m_texte.setColor ( sf::Color (200,200,200) ); m_texte.setFont ( app::Config::ms_polices.get( app::Config::Polices::police_1 ) ); /// Initialisation du fond SFML. m_fond.setFillColor ( { 150, 150, 150 } ); m_fond.setOutlineColor ( { 150, 150, 150 } ); m_fond.setOutlineThickness ( 1 ); setEtat ( ); actualiser(); }
void MainWindow::on_lineEdit_returnPressed() { control.checkString(); actualiser(); }
void Bouton::setTextePolice (sf::Font& police) { m_texte.setFont( police ); actualiser (); }
void Bouton::setTexteStyle ( sf::Text::Style style ) { m_texte.setStyle( style ); actualiser (); }
void Bouton::setTexteTaille (float taille) { m_texte.setCharacterSize( taille ); actualiser (); }
void Bouton::setTexte (std::string texte) { m_texte.setString( texte ); actualiser (); }