Horizon
window_state_store.hpp
1 #pragma once
2 #include "sqlite.hpp"
3 
4 namespace Gtk {
5 class Window;
6 }
7 
8 namespace horizon {
9 class WindowState {
10 public:
11  WindowState(int ax, int ay, int aw, int ah, bool m = false) : x(ax), y(ay), width(aw), height(ah), maximized(m){};
12  WindowState(){};
13  int x = 0;
14  int y = 0;
15  int width = 1024;
16  int height = 768;
17  bool maximized = false;
18 };
19 
20 class WindowStateStore {
21 public:
22  WindowStateStore(Gtk::Window *w, const std::string &window_name);
23  bool get_default_set() const;
24 
25 private:
26  SQLite::Database db;
27  const std::string window_name;
28  Gtk::Window *win = nullptr;
29  WindowState window_state;
30 
31  bool load(const std::string &win, WindowState &ws);
32  void save(const std::string &win, const WindowState &ws);
33 
34  void apply(const WindowState &ws);
35  bool default_set = false;
36 };
37 } // namespace horizon