kwave  18.07.70
MouseMark.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  MouseMark.cpp - Handling of mouse selection
3  -------------------
4  begin : Sun Nov 12 2000
5  copyright : (C) 2000 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QtGlobal>
21 
22 #include "libgui/MouseMark.h"
23 
24 //****************************************************************************
26  :m_initial(0), m_last(0)
27 {
28 }
29 
30 //****************************************************************************
32 {
33 }
34 
35 //****************************************************************************
37 {
38  m_initial = l;
39  m_last = r;
40 }
41 
42 //****************************************************************************
44 {
45  return qMin(m_initial, m_last);
46 }
47 
48 //****************************************************************************
50 {
51  return qMax(m_initial, m_last);
52 }
53 
54 //****************************************************************************
56 {
57  const sample_index_t d_last =
58  (x > m_last) ? (x - m_last) : (m_last - x);
59  const sample_index_t d_first =
60  (x > m_initial) ? (x - m_initial) : (m_initial - x);
61  if (d_last > d_first)
62  m_initial = m_last;
63  m_last = x;
64 }
65 
66 //****************************************************************************
68 {
69  m_last = x;
70 }
71 
72 //****************************************************************************
73 //****************************************************************************
sample_index_t m_initial
Definition: MouseMark.h:83
void set(sample_index_t l, sample_index_t r)
Definition: MouseMark.cpp:36
sample_index_t right() const
Definition: MouseMark.cpp:49
void grep(sample_index_t x)
Definition: MouseMark.cpp:55
quint64 sample_index_t
Definition: Sample.h:28
virtual ~MouseMark()
Definition: MouseMark.cpp:31
sample_index_t m_last
Definition: MouseMark.h:86
void update(sample_index_t x)
Definition: MouseMark.cpp:67
sample_index_t left() const
Definition: MouseMark.cpp:43