Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Core/GuiDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void DialogData::onMousePress(MousePress& evt) {
stopCapturingMouse();
recti r = rect_;
if (isMouseOver()) {
if (evt.button == Mouse::LMB && evt.unhandled()) {
if (evt.button == Mouse::LMB && !evt.handled) {
auto actionType = GetAction(evt.x, evt.y);

if (actionType != ACT_NONE || IsInside(r, evt.x, evt.y)) {
Expand All @@ -138,7 +138,7 @@ void DialogData::onMousePress(MousePress& evt) {
request_pin_ = true;
}
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
14 changes: 0 additions & 14 deletions src/Core/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,4 @@ void InputHandler::handleInputs(InputEvents& events) {
}
}

// ================================================================================================
// InputHandler :: events structs.

void MousePress::setHandled() { handled = true; }

MousePress::MousePress(Mouse::Code code, int x, int y, int keyflags,
bool doubleClick, bool handled)
: button(code),
x(x),
y(y),
keyflags(keyflags),
doubleClick(doubleClick),
handled(handled) {}

} // namespace Vortex
8 changes: 1 addition & 7 deletions src/Core/Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,12 @@ struct MouseMove {

/// Contains data from a mouse button press event.
struct MousePress {
MousePress(Mouse::Code code, int x, int y, int keyflags, bool doubleClick,
bool handled);
Mouse::Code button; ///< The mouse button that was pressed.
int x, y; ///< The position of the mouse cursor.
int keyflags; ///< Keyflag values of modifier keys that were down.
bool doubleClick; ///< True if the press is the second press of a double
///< click.
bool unhandled() const { return !handled; }
void setHandled();

private:
bool handled; ///< Used to track if the event is handled.
bool handled; ///< Used to track if the event is handled.
};

/// Contains data from a mouse button release event.
Expand Down
6 changes: 3 additions & 3 deletions src/Core/WidgetsColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,21 @@ void WgColorPicker::onMousePress(MousePress& evt) {
evt.button == Mouse::LMB) {
colorpicker_expanded_->startDrag(evt.x, evt.y);
startCapturingMouse();
evt.setHandled();
evt.handled = true;
} else {
delete colorpicker_expanded_;
colorpicker_expanded_ = nullptr;
stopCapturingFocus();
}
} else if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
startCapturingFocus();

colorpicker_expanded_ = new Expanded;
colorpicker_expanded_->tick(rect_, gui_);
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Core/WidgetsScroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void WgScrollbar::setPage(int size) { scrollbar_page_ = size; }

void WgScrollbar::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
uint32_t action = GetScrollbarActionAtPosition(evt.x, evt.y);
if (action) {
startCapturingMouse();
Expand All @@ -127,7 +127,7 @@ void WgScrollbar::onMousePress(MousePress& evt) {
scrollbar_action_ = ACT_DRAGGING_V;
}
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ void WgScrollRegion::onMouseScroll(MouseScroll& evt) {

void WgScrollRegion::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
uint32_t action = getScrollRegionActionAt_(evt.x, evt.y);
if (action) {
startCapturingMouse();
Expand All @@ -248,7 +248,7 @@ void WgScrollRegion::onMousePress(MousePress& evt) {
scroll_region_action_ = ACT_DRAGGING_V;
}
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/Core/WidgetsSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void WgSelectList::clearItems() { selectlist_items_.clear(); }

void WgSelectList::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();

// Handle interaction with the item list.
Expand All @@ -49,7 +49,7 @@ void WgSelectList::onMousePress(MousePress& evt) {
}
}
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down Expand Up @@ -177,12 +177,12 @@ void WgDroplist::onMousePress(MousePress& evt) {
recti r = selectlist_widget_->getRect();
if (evt.button == Mouse::RMB || !IsInside(r, evt.x, evt.y)) {
CloseDroplist();
evt.setHandled();
evt.handled = true;
}
} else if (isMouseOver()) {
int numItems = droplist_items_.size();
if (isEnabled() && numItems && evt.button == Mouse::LMB &&
evt.unhandled()) {
!evt.handled) {
int h = std::min(numItems * gSystem->applyScaleFactor(18) + 8,
gSystem->applyScaleFactor(128));
recti r = {rect_.x, rect_.y + rect_.h, rect_.w, h};
Expand All @@ -201,7 +201,7 @@ void WgDroplist::onMousePress(MousePress& evt) {
startCapturingMouse();
startCapturingFocus();
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down Expand Up @@ -312,7 +312,7 @@ void WgCycleButton::onMousePress(MousePress& evt) {
int numItems = cycle_items_.size();
if (isMouseOver()) {
if (numItems > 1 && isEnabled() && evt.button == Mouse::LMB &&
evt.unhandled()) {
!evt.handled) {
stopCapturingText();
startCapturingMouse();
if (evt.x > CenterX(rect_)) {
Expand All @@ -322,7 +322,7 @@ void WgCycleButton::onMousePress(MousePress& evt) {
}
onChange.call();
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Core/WidgetsSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ WgButton::WgButton(GuiContext* gui) : GuiWidget(gui) {}

void WgButton::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
isDown.set(true);
counter.set(counter.get() + 1);
onPress.call();
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down Expand Up @@ -98,12 +98,12 @@ WgCheckbox::WgCheckbox(GuiContext* gui) : GuiWidget(gui) {}

void WgCheckbox::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
value.set(!value.get());
onChange.call();
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down Expand Up @@ -161,11 +161,11 @@ void WgSlider::setRange(double begin, double end) {

void WgSlider::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
SliderDrag(evt.x, evt.y);
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Core/WidgetsText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void WgLineEdit::onKeyRelease(KeyRelease& evt) {

void WgLineEdit::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
if (isCapturingText() && evt.doubleClick) {
lineedit_cursor_.x = 0;
lineedit_cursor_.y = static_cast<int>(lineedit_text_.length());
Expand All @@ -149,7 +149,7 @@ void WgLineEdit::onMousePress(MousePress& evt) {

startCapturingMouse();
lineedit_blink_time_ = 0.f;
evt.setHandled();
evt.handled = true;
}
} else
deselect();
Expand Down Expand Up @@ -381,7 +381,7 @@ WgSpinner::WgSpinner(GuiContext* gui) : GuiWidget(gui) {

void WgSpinner::onMousePress(MousePress& evt) {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
spinner_lineedit_->deselect();
startCapturingMouse();
recti r = SpinnerButtonRect();
Expand All @@ -390,7 +390,7 @@ void WgSpinner::onMousePress(MousePress& evt) {
SpinnerUpdateValue(value.get() + spinner_step_size_ * sign);
spinner_repeat_timer_ = 0.5f;
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/ChartList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct DialogChartList::ChartButton : public GuiWidget {

void onMousePress(MousePress& evt) override {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
gSimfile->openChart(myChartIndex);
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/LabelBreakdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ struct DialogLabelBreakdown::LabelButton : public GuiWidget {

void onMousePress(MousePress& evt) override {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
startCapturingMouse();
gView->setCursorRow(myRow);
}
evt.setHandled();
evt.handled = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/TempoBreakdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ struct DialogTempoBreakdown::TempoList : public WgScrollRegion {

void onMousePress(MousePress& evt) override {
if (isMouseOver()) {
if (isEnabled() && evt.button == Mouse::LMB && evt.unhandled()) {
if (isEnabled() && evt.button == Mouse::LMB && !evt.handled) {
auto seg = getSegmentUnderMouse(gui_->getMousePos());
if (seg) {
gView->setCursorRow(seg->row);
evt.setHandled();
evt.handled = true;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Editor/Editing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ struct EditingImpl : public Editing {
// Finish tweaking.
int mode = gTempo->getTweakMode();
if ((evt.button == Mouse::LMB || evt.button == Mouse::RMB) && mode &&
evt.unhandled()) {
!evt.handled) {
gTempo->stopTweaking(evt.button == Mouse::LMB);
evt.setHandled();
evt.handled = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Editor/Menubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ struct MenuBarImpl : public Menubar {

void onMousePress(MousePress& evt) override {
#ifdef GL_MENU_BAR
if (evt.button != Mouse::LMB || !evt.unhandled()) return;
if (evt.button != Mouse::LMB || evt.handled) return;
auto handle_menu = [&](MenuItem* menu) {
int i = 0;
for (auto it : menu->getMenuData()) {
Expand All @@ -876,7 +876,7 @@ struct MenuBarImpl : public Menubar {
else {
Action::perform(it.action);
}
evt.setHandled();
evt.handled = true;
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/Editor/Minimap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ struct MinimapImpl : public Minimap {

void onMousePress(MousePress& evt) override {
if (evt.button == Mouse::LMB && !gTextOverlay->isOpen() &&
evt.unhandled()) {
!evt.handled) {
if (IsInside(rect_, evt.x, evt.y)) {
gView->setCursorOffset(myGetMapOffset(evt.y));
myIsDragging = true;
evt.setHandled();
evt.handled = true;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Editor/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ struct SelectionImpl : public Selection {

void onMousePress(MousePress& evt) override {
// Start dragging a selection box.
if (evt.button == Mouse::LMB && evt.unhandled()) {
if (evt.button == Mouse::LMB && !evt.handled) {
myIsDraggingSelection = true;
myDragSelectionX = evt.x;
myDragSelectionTor = gView->yToOffset(evt.y);
evt.setHandled();
evt.handled = true;
}

// Clear selection.
if (evt.button == Mouse::RMB && evt.unhandled()) {
if (evt.button == Mouse::RMB && !evt.handled) {
gNotes->deselectAll();
gTempoBoxes->deselectAll();
this->setRegion(0, 0);
evt.setHandled();
evt.handled = true;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Editor/TextOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ struct TextOverlayImpl : public TextOverlay {
gSystem->setCursor(Cursor::HAND);
MousePress* mp = nullptr;
if (gSystem->getEvents().next(mp)) {
if (mp->unhandled()) {
mp->setHandled();
if (!mp->handled) {
mp->handled = true;
gSystem->openWebpage(
reinterpret_cast<const char*>(supportLink));
}
Expand All @@ -533,8 +533,8 @@ struct TextOverlayImpl : public TextOverlay {
gSystem->setCursor(Cursor::HAND);
MousePress* mp = nullptr;
if (gSystem->getEvents().next(mp)) {
if (mp->unhandled()) {
mp->setHandled();
if (!mp->handled) {
mp->handled = true;
gSystem->openWebpage(
reinterpret_cast<const char*>(githubLink));
}
Expand Down
Loading
Loading