# class glw::Window

## Overview

Implements GLFW functions in object style programming. More…

    #include <Window.h>

    class Window: public glw::WindowEventObserver {
    public:
        // structs

        struct InitParameters;

        // fields

        static constexpr uint8_t max_observer_priority = 15u;

        // construction

        Window();
        Window(const InitParameters& params);
        ~Window();

        // methods

        void ObserverRegister(WindowEventObserver* object, const uint8_t priority = glw::Window::max_observer_priority);
        void ObserverRemove(WindowEventObserver* object);
        bool IsVisible() const;
        bool IsMaximized() const;
        bool IsIconified() const;
        bool IsFullscreen();
        bool IsInitialized();
        bool ShouldClose();
        void SetShouldClose();
        bool IsContextShared();
        GLFWwindow* GetWindowPtr();
        glm::vec2 GetMousePosition() const;
        glm::ivec2 GetPosition() const;
        glm::uvec2 GetResolution() const;
        uint32_t GetWidth() const;
        uint32_t GetHeight() const;
        glm::vec2 GetContentScaling() const;
        glm::uvec2 GetUnscaledResolution() const;
        void SetWindowedMode(int width, int height, int posx = 0, int posy = 0);
        void SetFullscreenMode();
        void PollEvents();
        void SwapBuffers();
        void SetContextConditional();
        void UnsetContextConditional();

    protected:
        // methods

        bool Initialize(const InitParameters& init);
    };

### Inherited Members

    protected:
        // methods

        virtual void OnMouseMove(double xpos, double ypos);
        virtual void OnMouseDown(int button, int mods);
        virtual void OnMouseUp(int button, int mods);
        virtual void OnMouseWheel(double xoffset, double yoffset);
        virtual void OnCharacter(char codepoint);
        virtual void OnKeyDown(int key, int mods, bool is_repeat);
        virtual void OnKeyUp(int key, int mods);
        virtual void OnTouch(unsigned int num_of_contacts, unsigned int* id, double* xpos, double* ypos, double* cwidth, double* cheight);
        virtual void OnTouchGestBegin();
        virtual void OnTouchGestEnd();
        virtual void OnTouchGestZoom(double distance, double xpos, double ypos);
        virtual void OnTouchGestPan(double distance, double xpos, double ypos);
        virtual void OnWindowMove(int xpos, int ypos);
        virtual void OnWindowRefresh();
        virtual void OnWindowResize(int width, int height);
        virtual void OnContentScale(float xscale, float yscale);
        virtual void OnFramebufferResize(int width, int height);
        virtual void OnWindowIconify(int is_iconified);
        virtual void OnWindowFocus(int is_focused);
        virtual void OnWindowClose();
        virtual void OnFilesDropped(const std::vector<std::string>& files);

## Detailed Documentation

Implements GLFW functions in object style programming.

### Methods

    void ObserverRegister(WindowEventObserver* object, const uint8_t priority = glw::Window::max_observer_priority)

Registers observer for window callback events. Priority parameter sets ordering update - the lower number = the sooner notified

    void ObserverRemove(WindowEventObserver* object)

Unregisters observer for window callback events.

    GLFWwindow* GetWindowPtr()

Returns pointer to raw GLFW window.

    glm::vec2 GetMousePosition() const

Returns position of mouse, relative to the window position.

    glm::ivec2 GetPosition() const

Returns screen position of window client area.

    glm::uvec2 GetResolution() const

Returns resolution of window rendering buffer.

    uint32_t GetWidth() const

Returns width of window rendering buffer.

    uint32_t GetHeight() const

Returns height of window rendering buffer.

    glm::vec2 GetContentScaling() const

The content scale is the ratio between the current DPI and the platform’s default DPI.

The content scale may depend on both the monitor resolution and pixel density and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution.

On systems where each monitors can have its own content scale, the window content scale will depend on which monitor the system considers the window to be on.

    glm::uvec2 GetUnscaledResolution() const

Window resolution modulated by a content scaling factor.

    bool Initialize(const InitParameters& init)

Window initialization procedure. When creating derived class, this method needs to be called at some point in window creation!