MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / stateResizing

Function stateResizing

src/OpenLoco/src/Input/MouseInput.cpp:713–822  ·  view source on GitHub ↗

0x004C7722

Source from the content-addressed store, hash-verified

711
712 // 0x004C7722
713 static void stateResizing(MouseButton button, int32_t x, int32_t y)
714 {
715 auto w = WindowManager::find(_dragWindowType, _dragWindowNumber);
716 if (w == nullptr)
717 {
718 state(State::reset);
719 return;
720 }
721
722 bool notMaximised = false;
723 int dx = 0, dy = 0;
724 switch (button)
725 {
726 case MouseButton::released:
727 notMaximised = true;
728 break;
729
730 case MouseButton::leftReleased:
731 state(State::normal);
732 Ui::ToolTip::setTooltipTimeout(0);
733 Ui::ToolTip::setWidgetIndex(_pressedWidgetIndex);
734 Ui::ToolTip::setWindowType(_dragWindowType);
735 Ui::ToolTip::setWindowNumber(_dragWindowNumber);
736
737 // Do not toggle maximised if the window has been resized.
738 if (w->hasFlags(Ui::WindowFlags::hasBeenResized))
739 {
740 notMaximised = true;
741 break;
742 }
743
744 // Un-maximise window; restore previous window size.
745 if (w->hasFlags(Ui::WindowFlags::maximised))
746 {
747 x = w->var_88A - w->width + _dragLast.x;
748 y = w->var_88C - w->height + _dragLast.y;
749 w->flags &= ~Ui::WindowFlags::maximised;
750 notMaximised = true;
751 break;
752 }
753
754 // Maximise window. Store previous window size.
755 w->var_88A = w->width;
756 w->var_88C = w->height;
757 x = _dragLast.x - w->x - w->width + Ui::width();
758 y = _dragLast.y - w->y - w->height + Ui::height() - 27;
759 w->flags |= Ui::WindowFlags::maximised;
760 if (y >= Ui::height() - 2)
761 {
762 _dragLast.x = x;
763 _dragLast.y = y;
764 return;
765 }
766
767 dx = x - _dragLast.x;
768 dy = y - _dragLast.y;
769
770 if (dx == 0 && dy == 0)

Callers 1

handleMouseFunction · 0.85

Calls 13

findFunction · 0.85
setTooltipTimeoutFunction · 0.85
setWidgetIndexFunction · 0.85
setWindowTypeFunction · 0.85
setWindowNumberFunction · 0.85
widthFunction · 0.85
heightFunction · 0.85
callOnResizeMethod · 0.80
callPrepareDrawMethod · 0.80
updateScrollWidgetsMethod · 0.80
stateFunction · 0.50
hasFlagsMethod · 0.45

Tested by

no test coverage detected