MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / mousePressEvent

Method mousePressEvent

src/openms_gui/source/VISUAL/MultiGradientSelector.cpp:102–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 }
101
102 void MultiGradientSelector::mousePressEvent(QMouseEvent * e)
103 {
104 if (e->button() != Qt::LeftButton)
105 {
106 e->ignore();
107 return;
108 }
109
110 left_button_pressed_ = true;
111
112 // select lever
113 // Starting with the rightmost lever, the first lever that overlaps the mouse pointer is selected (only lever with higher index can overlap lever with lower index).
114 for (Int i = (Int)gradient_.size() - 1; i >= 0; --i)
115 {
116 Int pos = Int(float(gradient_.position(i)) / 100.0 * gradient_area_width_ + margin_ + 1);
117
118 // mouse pointer over lever?
119 if (e->x() >= pos - 3 && e->x() <= pos + 4 && e->y() >= height() - margin_ - lever_area_height_ + 8 && e->y() <= height() - margin_ - lever_area_height_ + 15)
120 {
121 selected_ = gradient_.position(i);
122 selected_color_ = gradient_.color(i);
123 repaint();
124 return;
125 }
126 }
127
128 //create new lever
129 if (e->x() >= margin_ && e->x() <= width() - margin_ && e->y() >= height() - margin_ - lever_area_height_ && e->y() <= height() - margin_)
130 {
131 Int pos = Int(100 * (e->x() - margin_) / float(gradient_area_width_));
132 gradient_.insert(pos, selected_color_);
133 selected_ = pos;
134 repaint();
135 }
136 }
137
138 void MultiGradientSelector::mouseMoveEvent(QMouseEvent * e)
139 {

Callers

nothing calls this directly

Calls 4

colorMethod · 0.80
sizeMethod · 0.45
positionMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected