doodle  0.2
Intended to support teaching C++, doodle is a simple library that helps make a window and makes it easy to do some drawing.
window.hpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------*
2  Copyright (C) 2021 Rudy Castan
3 
4  This file is distributed WITHOUT ANY WARRANTY. See the file
5  `License.md' for details.
6 *--------------------------------------------------------------*/
7 #pragma once
8 
9 #include <doodle/eventhook.hpp>
10 
11 #include <functional>
12 #include <string>
13 
14 namespace doodle
15 {
51  bool create_window() noexcept;
79  bool create_window(const std::string& title) noexcept;
107  bool create_window(int desired_width, int desired_height) noexcept;
136  bool create_window(const std::string& title, int desired_width, int desired_height) noexcept;
137 
173  bool create_window(const std::string& title, int desired_width, int desired_height, int screen_x,
174  int screen_y) noexcept;
175 
202  bool is_window_closed() noexcept;
203 
227  void update_window() noexcept;
228 
265  void close_window() noexcept;
266 
301  void set_window_title(const std::string& new_title) noexcept;
336  bool is_full_screen() noexcept;
370  void toggle_full_screen() noexcept;
400  extern bool WindowIsFocused;
436  void set_callback_window_resized(std::function<void(int, int)>&& callback) noexcept;
471  void set_callback_window_closed(std::function<void(void)>&& callback) noexcept;
510  void set_callback_window_focus_changed(std::function<void(bool)>&& callback) noexcept;
511 
542  void show_cursor(bool show_it = true) noexcept;
543 
544 }
545 
546 
588 EVENT_HOOK void on_window_resized(int new_width, int new_height);
621 EVENT_HOOK void on_window_closed();
663 EVENT_HOOK void on_window_focus_changed(bool is_focused);
void set_callback_window_closed(std::function< void(void)> &&callback) noexcept
The provided callback function will be called when the user uses the OS to close the window.
bool is_full_screen() noexcept
Is the window a fullscreen window?
EVENT_HOOK void on_window_closed()
The declaration of the optional on_window_closed function to implement in your doodle program.
EVENT_HOOK void on_window_focus_changed(bool is_focused)
The declaration of the optional on_window_focus_changed function to implement in your doodle program.
bool create_window() noexcept
Create a default window.
void set_callback_window_resized(std::function< void(int, int)> &&callback) noexcept
The provided callback function is called whenever the window is resized by the user.
void set_window_title(const std::string &new_title) noexcept
Set a new title for the window.
bool is_window_closed() noexcept
Is the window closed?
void show_cursor(bool show_it=true) noexcept
This function will allow you to hide or show the mouse cursor.
void close_window() noexcept
Programmatically close the window.
void toggle_full_screen() noexcept
Switch back and forth between fullscreen and windowed mode.
void update_window() noexcept
Update the doodle application.
EVENT_HOOK void on_window_resized(int new_width, int new_height)
The declaration of the optional on_window_resized function to implement in your doodle program.
bool WindowIsFocused
Confirms if the window a doodle program is in is "focused," meaning that the doodle will accept mouse...
void set_callback_window_focus_changed(std::function< void(bool)> &&callback) noexcept
THe provided callback function will be called when the window gains or loses focus.
Definition: angle.hpp:11