Skip to content
Snippets Groups Projects
Select Git revision
  • f6c022ad02aa2ead458ceefde98dc0191ba9f3ed
  • master default protected
  • refactoring
  • push_test
  • qpong_opengl
  • push_to_gitlab
  • feature_imgui_opengl
  • feature_google_test_integration
  • feature_config
  • merge_ci_and_googletest
  • feature_pixbuf
  • feature_heapBuffer
12 results

QWindow.hpp

Blame
  • Armin Co's avatar
    Armin Co authored
    All core QPong code is in a namespace now.
    80b7608b
    History
    QWindow.hpp 1.63 KiB
    ///
    /// @file       QWindow.hpp
    /// @author     Armin Co
    ///
    
    #ifndef Q_WINDOW_HPP
    #define Q_WINDOW_HPP
    
    #include <thread>
    #include <map>
    #include <memory>
    #include <gtkmm.h>
    
    #include "Particle.hpp"
    #include "ParticleImage.hpp"
    #include "QDrawingArea.hpp"
    
    /// @brief Definition of the QPong window
    ///
    class QWindow : public Gtk::Window
    {
    public:
    
        /// @brief Constructor of the window
        ///
        QWindow();
    
        /// @brief Virtual destructor of the window.
        ///
        virtual ~QWindow(){}
    
        /// @brief Sends a signal to GTK to update drawing areas.
        void updateView();
    
    protected:
        /// @brief signal handlers
        ///
        void onButtonPress();
        bool onKeyPress(GdkEventKey* event);
    
    private:
        /// @brief Updates the QDrawingArea for position and momentum.
        ///
        void updateImage();
    
        /// @brief Update all labels from the gui.
        ///
        void updateGui();
    
        /// @brief Loop throug iteratins of the simulation
        ///
        void simulation();
    
        Gtk::Box m_box;
        Gtk::VBox m_vBox;
        Gtk::HBox m_hBox;
        Gtk::Box m_fpsBox;
    
        Gtk::Label m_label;
        Gtk::Button m_button;
    
        Gtk::Label m_renderRate;
        Gtk::Label m_proppergatingRate;
    
        Gtk::Box m_scoreBox;
        Gtk::Label m_scorePlayerOne;
        Gtk::Label m_scorePlayerTwo;
    
        Glib::Dispatcher m_guiDispatcher;
        Glib::Dispatcher m_areaDispatcher;
    
        QDrawingArea m_positionArea;
        QDrawingArea m_momentumArea;
    
        QPong::Particle *m_particle;
        std::thread m_propagatingThread;
        ParticleImage *m_momentum;
        ParticleImage *m_position;
        ParticleImage *m_obstacle;
    
        std::map<QPong::Player::Id, std::shared_ptr<QPong::Player>> m_players;
    };
    
    #endif