Allow changing of existing overlay values

Tue, 14 May 2013 02:28:28 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 14 May 2013 02:28:28 +0300
changeset 197
82a868e9e929
parent 196
47f4f4543152
child 198
f246725199dc

Allow changing of existing overlay values

src/gldraw.cpp file | annotate | diff | comparison | revisions
src/gldraw.h file | annotate | diff | comparison | revisions
src/radiobox.cpp file | annotate | diff | comparison | revisions
src/radiobox.h file | annotate | diff | comparison | revisions
--- a/src/gldraw.cpp	Tue May 14 01:22:40 2013 +0300
+++ b/src/gldraw.cpp	Tue May 14 02:28:28 2013 +0300
@@ -1313,7 +1313,28 @@
 	
 	connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ()));
 	connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ()));
+	connect (rb_camera, SIGNAL (valueChanged (int)), this, SLOT (fillDefaults (int)));
+	
 	slot_dimensionsChanged ();
+	fillDefaults (cam);
+}
+
+void OverlayDialog::fillDefaults (int newcam) {
+	overlayMeta& info = g_overlays[newcam];
+	
+	if (info.img != null) {
+		le_fpath->setText (info.fname);
+		sb_ofsx->setValue (info.ox);
+		sb_ofsy->setValue (info.oy);
+		dsb_lwidth->setValue (info.lw);
+		dsb_lheight->setValue (info.lh);
+	} else {
+		le_fpath->setText ("");
+		sb_ofsx->setValue (0);
+		sb_ofsy->setValue (0);
+		dsb_lwidth->setValue (0.0f);
+		dsb_lheight->setValue (0.0f);
+	} 
 }
 	
 str			OverlayDialog::fpath		() const { return le_fpath->text (); }
@@ -1379,6 +1400,7 @@
 	info.v0[y2d] = (info.oy * info.lh * negYFac) / img->height ();
 	info.v1[x2d] = info.v0[x2d] + info.lw;
 	info.v1[y2d] = info.v0[y2d] + info.lh;
+	info.fname = dlg.fpath ();
 	
 	// Set alpha of all pixels to 0.5
 	for (long i = 0; i < img->width (); ++i)
--- a/src/gldraw.h	Tue May 14 01:22:40 2013 +0300
+++ b/src/gldraw.h	Tue May 14 02:28:28 2013 +0300
@@ -156,6 +156,7 @@
 	void slot_fpath ();
 	void slot_help ();
 	void slot_dimensionsChanged ();
+	void fillDefaults (int newcam);
 };
 
 #endif // GLDRAW_H
\ No newline at end of file
--- a/src/radiobox.cpp	Tue May 14 01:22:40 2013 +0300
+++ b/src/radiobox.cpp	Tue May 14 02:28:28 2013 +0300
@@ -28,7 +28,7 @@
 	m_dir = makeDirection (orient);
 	
 	m_buttonGroup = new QButtonGroup;
-	m_curId = 0;
+	m_oldId = m_curId = 0;
 	m_coreLayout = null;
 	
 	m_coreLayout = new QBoxLayout (makeDirection (orient, true));
@@ -37,14 +37,15 @@
 	// Init the first row with a break
 	rowBreak ();
 	
-	connect (m_buttonGroup, SIGNAL (buttonPressed (QAbstractButton*)), this, SLOT (slot_buttonPressed (QAbstractButton*)));
 	connect (m_buttonGroup, SIGNAL (buttonPressed (int)), this, SLOT (slot_buttonPressed (int)));
+	connect (m_buttonGroup, SIGNAL (buttonReleased (int)), this, SLOT (slot_buttonReleased (int)));
 }
 
 RadioBox::RadioBox (const QString& title, initlist<char const*> entries, int const defaultId,
 	const Qt::Orientation orient, QWidget* parent) : QGroupBox (title, parent), m_defId (defaultId)
 {
 	init (orient);
+	m_oldId = m_defId;
 	
 	for (char const* entry : entries)
 		addButton (entry);
@@ -90,8 +91,14 @@
 
 void RadioBox::slot_buttonPressed (int btn) {
 	emit sig_buttonPressed (btn);
+	
+	m_oldId = m_buttonGroup->checkedId ();
 }
 
-void RadioBox::slot_buttonPressed (QAbstractButton* btn) {
-	emit sig_buttonPressed (btn);
+void RadioBox::slot_buttonReleased (int btn) {
+	emit buttonReleased (btn);
+	int newid = m_buttonGroup->checkedId ();
+	
+	if (m_oldId != newid)
+		emit valueChanged (newid);
 }
\ No newline at end of file
--- a/src/radiobox.h	Tue May 14 01:22:40 2013 +0300
+++ b/src/radiobox.h	Tue May 14 02:28:28 2013 +0300
@@ -93,7 +93,8 @@
 
 signals:
 	void sig_buttonPressed (int btn);
-	void sig_buttonPressed (QAbstractButton* btn);
+	void buttonReleased (int btn);
+	void valueChanged (int val);
 
 private:
 	std::vector<QRadioButton*> m_objects;
@@ -101,14 +102,14 @@
 	QBoxLayout* m_coreLayout;
 	QBoxLayout* m_currentLayout;
 	QBoxLayout::Direction m_dir;
-	int m_curId, m_defId;
+	int m_curId, m_defId, m_oldId;
 	QButtonGroup* m_buttonGroup;
 	
 	Q_DISABLE_COPY (RadioBox)
 
 private slots:
 	void slot_buttonPressed (int btn);
-	void slot_buttonPressed (QAbstractButton* btn);
+	void slot_buttonReleased (int btn);
 };
 
 #endif // RADIOBOX_H
\ No newline at end of file

mercurial