Window Size/Pos Tracking

This commit is contained in:
mwalker33 2020-04-13 09:32:47 +10:00
commit 69eef755d3
5 changed files with 53 additions and 27 deletions

View file

@ -24,7 +24,7 @@
#include "cmdparser.h" #include "cmdparser.h"
#include <ctype.h> #include <ctype.h>
//#include "proxgui.h" //#include "proxgui.h"
extern void SetWindowsPosition (void); //extern void SetWindowsPosition (void);
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
// Load all settings into memory (struct) // Load all settings into memory (struct)
@ -445,7 +445,7 @@ static int CmdPrefSet (const char *Cmd)
// Need to work out how to change live.... // Need to work out how to change live....
// calling data plot seems to work // calling data plot seems to work
//plotwidget->MoveWindows (); //plotwidget->MoveWindows ();
SetWindowsPosition(); // SetWindowsPosition();
showPlotPosState (); showPlotPosState ();
break; break;
case prefOVERLAY: case prefOVERLAY:
@ -468,7 +468,7 @@ static int CmdPrefSet (const char *Cmd)
if (y != -99999) session.window_overlay_ypos = y; if (y != -99999) session.window_overlay_ypos = y;
if (h != -99999) session.window_overlay_hsize = h; if (h != -99999) session.window_overlay_hsize = h;
if (w != -99999) session.window_overlay_wsize = w; if (w != -99999) session.window_overlay_wsize = w;
SetWindowsPosition(); // SetWindowsPosition();
showOverlayPosState (); showOverlayPosState ();
// Need to work out how to change live.... // Need to work out how to change live....
break; break;

View file

@ -54,9 +54,6 @@ extern "C" void MainGraphics(void) {
gui->MainLoop(); gui->MainLoop();
} }
extern "C" void SetWindowsPosition (void) {
gui->SetWindowsPosition ();
}
extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) { extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
#ifdef Q_WS_X11 #ifdef Q_WS_X11

View file

@ -24,7 +24,6 @@ void ShowGraphWindow(void);
void HideGraphWindow(void); void HideGraphWindow(void);
void RepaintGraphWindow(void); void RepaintGraphWindow(void);
void MainGraphics(void); void MainGraphics(void);
void SetWindowsPosition (void);
void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop); void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
void ExitGraphics(void); void ExitGraphics(void);
#ifndef MAX_GRAPH_TRACE_LEN #ifndef MAX_GRAPH_TRACE_LEN

View file

@ -128,10 +128,30 @@ ProxGuiQT::~ProxGuiQT(void) {
plotapp = NULL; plotapp = NULL;
} }
} }
void ProxGuiQT::SetWindowsPosition (void)
{ // -------------------------------------------------
plotwidget->SetWindowsPosition (); // Slider Widget form based on a class to enable
// Event override functions
// -------------------------------------------------
SliderWidget::SliderWidget() {
// Set the initail postion and size from settings
if (session.preferences_loaded)
setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize);
else
resize(800, 400);
} }
void SliderWidget::resizeEvent (QResizeEvent *event) {
session.window_overlay_hsize = event->size().height();
session.window_overlay_wsize = event->size().width();
}
void SliderWidget::moveEvent (QMoveEvent *event) {
session.window_overlay_xpos = event->pos().x();
session.window_overlay_ypos = event->pos().y();
}
//-------------------- //--------------------
void ProxWidget::applyOperation() { void ProxWidget::applyOperation() {
//printf("ApplyOperation()"); //printf("ApplyOperation()");
@ -179,7 +199,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
resize(800, 400); resize(800, 400);
// Setup the controller widget // Setup the controller widget
controlWidget = new QWidget(); controlWidget = new SliderWidget ();//new QWidget();
opsController = new Ui::Form(); opsController = new Ui::Form();
opsController->setupUi(controlWidget); opsController->setupUi(controlWidget);
//Due to quirks in QT Designer, we need to fiddle a bit //Due to quirks in QT Designer, we need to fiddle a bit
@ -192,7 +212,6 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
opsController->horizontalSlider_askedge->setValue(25); opsController->horizontalSlider_askedge->setValue(25);
opsController->horizontalSlider_window->setValue(4000); opsController->horizontalSlider_window->setValue(4000);
QObject::connect(opsController->pushButton_apply, SIGNAL(clicked()), this, SLOT(applyOperation())); QObject::connect(opsController->pushButton_apply, SIGNAL(clicked()), this, SLOT(applyOperation()));
QObject::connect(opsController->pushButton_sticky, SIGNAL(clicked()), this, SLOT(stickOperation())); QObject::connect(opsController->pushButton_sticky, SIGNAL(clicked()), this, SLOT(stickOperation()));
QObject::connect(opsController->horizontalSlider_window, SIGNAL(valueChanged(int)), this, SLOT(vchange_autocorr(int))); QObject::connect(opsController->horizontalSlider_window, SIGNAL(valueChanged(int)), this, SLOT(vchange_autocorr(int)));
@ -200,6 +219,8 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int))); QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int)));
QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int))); QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int)));
controlWidget->setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize);
// Set up the plot widget, which does the actual plotting // Set up the plot widget, which does the actual plotting
plot = new Plot(this); plot = new Plot(this);
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
@ -213,9 +234,8 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
// shows plot window on the screen. // shows plot window on the screen.
show(); show();
if (session.preferences_loaded) // Set Slider/Overlay position if no settings.
controlWidget->setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize); if (!session.preferences_loaded){
else {
// Move controller widget below plot // Move controller widget below plot
controlWidget->move(x(), y() + frameSize().height()); controlWidget->move(x(), y() + frameSize().height());
controlWidget->resize(size().width(), 200); controlWidget->resize(size().width(), 200);
@ -261,15 +281,14 @@ void ProxWidget::showEvent(QShowEvent *event) {
controlWidget->show(); controlWidget->show();
plot->show(); plot->show();
} }
void ProxWidget::SetWindowsPosition(void) { void ProxWidget::moveEvent(QMoveEvent *event) {
session.window_plot_xpos = event->pos().x();
// plotwidget->update(); session.window_plot_ypos = event->pos().y();
if (session.preferences_loaded) {
setGeometry (session.window_plot_xpos,session.window_plot_ypos,session.window_plot_wsize,session.window_plot_hsize); }
controlWidget->setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize); void ProxWidget::resizeEvent(QResizeEvent *event) {
update(); session.window_plot_hsize = event->size().height();
controlWidget->update(); session.window_plot_wsize = event->size().width();
}
} }
//----------- Plotting //----------- Plotting

View file

@ -56,9 +56,19 @@ class Plot: public QWidget {
}; };
class ProxGuiQT; class ProxGuiQT;
// Added class for SliderWidget to allow move/resize event override
class SliderWidget : public QWidget {
protected:
void resizeEvent (QResizeEvent *event);
void moveEvent (QMoveEvent *event);
public:
SliderWidget();
};
/** /**
* The window with plot and controls * The window with plot and controls
*/ */
class ProxWidget : public QWidget { class ProxWidget : public QWidget {
Q_OBJECT; //needed for slot/signal classes Q_OBJECT; //needed for slot/signal classes
@ -66,8 +76,8 @@ class ProxWidget : public QWidget {
ProxGuiQT *master; ProxGuiQT *master;
Plot *plot; Plot *plot;
Ui::Form *opsController; Ui::Form *opsController;
QWidget *controlWidget; // QWidget *controlWidget;
SliderWidget *controlWidget;
public: public:
ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL); ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
~ProxWidget(void); ~ProxWidget(void);
@ -78,6 +88,8 @@ class ProxWidget : public QWidget {
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
void hideEvent(QHideEvent *event); void hideEvent(QHideEvent *event);
void moveEvent(QMoveEvent *event);
void resizeEvent(QResizeEvent *event);
// void mouseMoveEvent(QMouseEvent *event); // void mouseMoveEvent(QMouseEvent *event);
// void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); } // void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
// void keyPressEvent(QKeyEvent *event); // void keyPressEvent(QKeyEvent *event);
@ -88,7 +100,6 @@ class ProxWidget : public QWidget {
void vchange_askedge(int v); void vchange_askedge(int v);
void vchange_dthr_up(int v); void vchange_dthr_up(int v);
void vchange_dthr_down(int v); void vchange_dthr_down(int v);
void SetWindowsPosition(void);
}; };
class WorkerThread : public QThread { class WorkerThread : public QThread {