Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
42:1bdf285c4eac | 43:78515b1e29eb |
---|---|
815 } | 815 } |
816 | 816 |
817 bool | 817 bool |
818 Pane::editSelectionStart(QMouseEvent *e) | 818 Pane::editSelectionStart(QMouseEvent *e) |
819 { | 819 { |
820 if (!m_identifyFeatures || | |
821 !m_manager || | |
822 m_manager->getToolMode() != ViewManager::EditMode) { | |
823 return false; | |
824 } | |
825 | |
820 bool closeToLeft, closeToRight; | 826 bool closeToLeft, closeToRight; |
821 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight)); | 827 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight)); |
822 if (s.isEmpty()) return false; | 828 if (s.isEmpty()) return false; |
823 m_editingSelection = s; | 829 m_editingSelection = s; |
824 m_editingSelectionEdge = (closeToLeft ? -1 : closeToRight ? 1 : 0); | 830 m_editingSelectionEdge = (closeToLeft ? -1 : closeToRight ? 1 : 0); |
837 | 843 |
838 bool | 844 bool |
839 Pane::editSelectionEnd(QMouseEvent *e) | 845 Pane::editSelectionEnd(QMouseEvent *e) |
840 { | 846 { |
841 if (m_editingSelection.isEmpty()) return false; | 847 if (m_editingSelection.isEmpty()) return false; |
848 | |
849 int offset = m_mousePos.x() - m_clickPos.x(); | |
850 Layer *layer = getSelectedLayer(); | |
851 | |
852 if (offset == 0 || !layer) { | |
853 m_editingSelection = Selection(); | |
854 return true; | |
855 } | |
856 | |
857 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; | |
858 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | |
859 | |
860 long f0 = getFrameForX(p0); | |
861 long f1 = getFrameForX(p1); | |
862 | |
863 Selection newSelection(f0, f1); | |
864 | |
865 if (m_editingSelectionEdge == 0) { | |
866 | |
867 layer->moveSelection(m_editingSelection, f0); | |
868 | |
869 } else { | |
870 | |
871 if (m_editingSelectionEdge < 0) { | |
872 f1 = m_editingSelection.getEndFrame(); | |
873 } else { | |
874 f0 = m_editingSelection.getStartFrame(); | |
875 } | |
876 | |
877 newSelection = Selection(f0, f1); | |
878 layer->resizeSelection(m_editingSelection, newSelection); | |
879 } | |
880 | |
881 m_manager->removeSelection(m_editingSelection); | |
882 m_manager->addSelection(newSelection); | |
883 | |
842 m_editingSelection = Selection(); | 884 m_editingSelection = Selection(); |
843 return true; | 885 return true; |
844 } | 886 } |
845 | 887 |
846 void | 888 void |