diff widgets/Pane.cpp @ 43:78515b1e29eb

* Rejig project file a bit to do pkg-config detection &c and change some HAVE_* symbol names accordingly * Add selection move/resize/delete * First stubs for add layer / pane commands
author Chris Cannam
date Wed, 01 Mar 2006 18:13:01 +0000
parents 1bdf285c4eac
children ad214997dddb
line wrap: on
line diff
--- a/widgets/Pane.cpp	Mon Feb 27 17:34:41 2006 +0000
+++ b/widgets/Pane.cpp	Wed Mar 01 18:13:01 2006 +0000
@@ -817,6 +817,12 @@
 bool
 Pane::editSelectionStart(QMouseEvent *e)
 {
+    if (!m_identifyFeatures ||
+	!m_manager ||
+	m_manager->getToolMode() != ViewManager::EditMode) {
+	return false;
+    }
+
     bool closeToLeft, closeToRight;
     Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight));
     if (s.isEmpty()) return false;
@@ -839,6 +845,42 @@
 Pane::editSelectionEnd(QMouseEvent *e)
 {
     if (m_editingSelection.isEmpty()) return false;
+
+    int offset = m_mousePos.x() - m_clickPos.x();
+    Layer *layer = getSelectedLayer();
+
+    if (offset == 0 || !layer) {
+	m_editingSelection = Selection();
+	return true;
+    }
+
+    int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
+    int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
+
+    long f0 = getFrameForX(p0);
+    long f1 = getFrameForX(p1);
+
+    Selection newSelection(f0, f1);
+    
+    if (m_editingSelectionEdge == 0) {
+	
+	layer->moveSelection(m_editingSelection, f0);
+	
+    } else {
+	
+	if (m_editingSelectionEdge < 0) {
+	    f1 = m_editingSelection.getEndFrame();
+	} else {
+	    f0 = m_editingSelection.getStartFrame();
+	}
+
+	newSelection = Selection(f0, f1);
+	layer->resizeSelection(m_editingSelection, newSelection);
+    }
+    
+    m_manager->removeSelection(m_editingSelection);
+    m_manager->addSelection(newSelection);
+
     m_editingSelection = Selection();
     return true;
 }