From e3b65f1c9d922480fc5895731cde8d1294f66edc Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Tue, 6 Dec 2022 18:07:50 +0100 Subject: [PATCH] saving and restoring windows position and size on exit and startup --- ChangeLog | 3 ++ configuration.cc | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ debayer.h | 2 ++ 3 files changed, 77 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1ab0397..7e915a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2022-12-06: +- saving and restoring windows position and size on exit and startup + 2022-12-04: - RAW8 format support for SVB camera, also fixed RGB24 format - many bug fixes for RGB conversions diff --git a/configuration.cc b/configuration.cc index 6f2e376..164a889 100644 --- a/configuration.cc +++ b/configuration.cc @@ -108,6 +108,43 @@ void Configuration::SaveConfig(std::string filename) { jp.AddObject(je); } + // + // save windows position + for (i = 0; i < 5; i++) { + int x, y, w, h; + string name; + + switch (i) { + case 0: + name = "window-main"; + break; + case 1: + name = "window-input"; + break; + case 2: + name = "window-output"; + break; + case 3: + name = "window-detect"; + break; + case 4: + name = "window-histogram"; + break; + } + + + GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), name.c_str())); + if (wnd) { + gtk_window_get_position (GTK_WINDOW(wnd), &x, &y); + gtk_window_get_size (GTK_WINDOW(wnd), &w, &h); + + jp.AddObject(name+"_x", x); + jp.AddObject(name+"_y", y); + jp.AddObject(name+"_w", w); + jp.AddObject(name+"_h", h); + } + } + // // save config if (jp.SaveToFile(filename)) { @@ -185,6 +222,41 @@ void Configuration::LoadConfig(std::string filename) { ctrli++; } } + + // + // load windows position + for (i = 0; i < 5; i++) { + int x, y, w, h; + string name; + + switch (i) { + case 0: + name = "window-main"; + break; + case 1: + name = "window-input"; + break; + case 2: + name = "window-output"; + break; + case 3: + name = "window-detect"; + break; + case 4: + name = "window-histogram"; + break; + } + + if (jp.GetValueInt(name+"_x", &x) && jp.GetValueInt(name+"_y", &y) && + jp.GetValueInt(name+"_w", &w) && jp.GetValueInt(name+"_h", &h)) { + + GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), name.c_str())); + if (wnd) { + gtk_window_move (GTK_WINDOW(wnd), x, y); + gtk_window_resize (GTK_WINDOW(wnd), w, h); + } + } + } } }; diff --git a/debayer.h b/debayer.h index 37816ea..2621019 100644 --- a/debayer.h +++ b/debayer.h @@ -1,6 +1,8 @@ #ifndef _DEBAYER_H_ #define _DEBAYER_H_ +#include + void debayer_grbg16_simple (uint16_t * src, int src_w, int src_h, uint8_t * dst, int dst_w, int dst_h); void debayer_grbg8_simple (uint8_t * src, int src_w, int src_h,