projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TimeMarker: Renamed get_label_rect, and made it take a const QRectF&
[pulseview.git]
/
pv
/
view
/
cursorheader.cpp
diff --git
a/pv/view/cursorheader.cpp
b/pv/view/cursorheader.cpp
index 861cd70f535249209268e6cc24b078e6a4f1ba62..2835750b9647bcd2a5fd41a490cb13dadbafb7db 100644
(file)
--- a/
pv/view/cursorheader.cpp
+++ b/
pv/view/cursorheader.cpp
@@
-18,22
+18,25
@@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "cursorheader.h"
+#include "cursorheader.h
pp
"
-#include "view.h"
+#include "ruler.hpp"
+#include "view.hpp"
#include <QApplication>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QApplication>
#include <QFontMetrics>
#include <QMouseEvent>
-#include <pv/widgets/popup.h>
+#include <pv/widgets/popup.h
pp
>
using std::shared_ptr;
using std::shared_ptr;
+using std::vector;
namespace pv {
namespace view {
const int CursorHeader::Padding = 20;
namespace pv {
namespace view {
const int CursorHeader::Padding = 20;
+const int CursorHeader::BaselineOffset = 5;
int CursorHeader::calculateTextHeight()
{
int CursorHeader::calculateTextHeight()
{
@@
-44,22
+47,22
@@
int CursorHeader::calculateTextHeight()
CursorHeader::CursorHeader(View &parent) :
MarginWidget(parent),
CursorHeader::CursorHeader(View &parent) :
MarginWidget(parent),
-
_dragging
(false),
-
_textHeight
(calculateTextHeight())
+
dragging_
(false),
+
textHeight_
(calculateTextHeight())
{
setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
{
{
setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
{
- return QSize(0,
_textHeight + Padding
);
+ return QSize(0,
textHeight_ + Padding + BaselineOffset
);
}
void CursorHeader::clear_selection()
{
}
void CursorHeader::clear_selection()
{
-
CursorPair &cursors = _view.cursors(
);
- cursors.first()->select(false);
-
cursors.second()
->select(false);
+
const vector< shared_ptr<TimeItem> > items(view_.time_items()
);
+ for (auto &i : items)
+
i
->select(false);
update();
}
update();
}
@@
-68,10
+71,14
@@
void CursorHeader::paintEvent(QPaintEvent*)
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
+ // The cursor labels are not drawn with the arrows exactly on the
+ // bottom line of the widget, because then the selection shadow
+ // would be clipped away.
+ const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset);
+
// Draw the cursors
// Draw the cursors
- if (_view.cursors_shown()) {
- _view.cursors().draw_markers(p, rect(), 0); //prefix);
- }
+ if (view_.cursors_shown())
+ view_.cursors()->draw_markers(p, r);
}
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
}
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
@@
-79,37
+86,37
@@
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
if (!(e->buttons() & Qt::LeftButton))
return;
if (!(e->buttons() & Qt::LeftButton))
return;
- if ((e->pos() -
_mouse_down_point
).manhattanLength() <
+ if ((e->pos() -
mouse_down_point_
).manhattanLength() <
QApplication::startDragDistance())
return;
QApplication::startDragDistance())
return;
-
_dragging
= true;
+
dragging_
= true;
- if (shared_ptr<TimeMarker> m =
_grabbed_marker
.lock())
- m->set_time(
_view
.offset() +
- ((double)e->x() + 0.5) *
_view
.scale());
+ if (shared_ptr<TimeMarker> m =
grabbed_marker_
.lock())
+ m->set_time(
view_
.offset() +
+ ((double)e->x() + 0.5) *
view_
.scale());
}
void CursorHeader::mousePressEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::LeftButton) {
}
void CursorHeader::mousePressEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::LeftButton) {
-
_mouse_down_point
= e->pos();
+
mouse_down_point_
= e->pos();
-
_grabbed_marker
.reset();
+
grabbed_marker_
.reset();
clear_selection();
clear_selection();
- if (
_view
.cursors_shown()) {
-
CursorPair &cursors = _view.cursors(
);
- if (cursors
.first()->get_
label_rect(
+ if (
view_
.cursors_shown()) {
+
shared_ptr<CursorPair> cursors(view_.cursors()
);
+ if (cursors
->first()->
label_rect(
rect()).contains(e->pos()))
rect()).contains(e->pos()))
-
_grabbed_marker = cursors.
first();
- else if (cursors
.second()->get_
label_rect(
+
grabbed_marker_ = cursors->
first();
+ else if (cursors
->second()->
label_rect(
rect()).contains(e->pos()))
rect()).contains(e->pos()))
-
_grabbed_marker = cursors.
second();
+
grabbed_marker_ = cursors->
second();
}
}
- if (shared_ptr<TimeMarker> m =
_grabbed_marker
.lock())
+ if (shared_ptr<TimeMarker> m =
grabbed_marker_
.lock())
m->select();
selection_changed();
m->select();
selection_changed();
@@
-120,16
+127,16
@@
void CursorHeader::mouseReleaseEvent(QMouseEvent *)
{
using pv::widgets::Popup;
{
using pv::widgets::Popup;
- if (!
_dragging
)
- if (shared_ptr<TimeMarker> m =
_grabbed_marker
.lock()) {
- Popup *const p = m->create_popup(&
_view
);
- p->set_position(mapToGlobal(QPoint(m->get_x(),
-
height())
), Popup::Bottom);
+ if (!
dragging_
)
+ if (shared_ptr<TimeMarker> m =
grabbed_marker_
.lock()) {
+ Popup *const p = m->create_popup(&
view_
);
+ const QPoint arrpos(m->get_x(), height() - BaselineOffset);
+
p->set_position(mapToGlobal(arrpos
), Popup::Bottom);
p->show();
}
p->show();
}
-
_dragging
= false;
-
_grabbed_marker
.reset();
+
dragging_
= false;
+
grabbed_marker_
.reset();
}
} // namespace view
}
} // namespace view