[Scummvm-git-logs] scummvm master -> 068df3e6756a6d1361b9fd0249834ca59bacc0d7
OMGPizzaGuy
noreply at scummvm.org
Thu Dec 22 03:46:17 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4637c0dbe3 ULTIMA8: Fix button notifications for up and double messages
068df3e675 ULTIMA8: Change gump dragging to handle directly rather than through the parent.
Commit: 4637c0dbe36fcff1c5b4387c3cfd987ab340c6dc
https://github.com/scummvm/scummvm/commit/4637c0dbe36fcff1c5b4387c3cfd987ab340c6dc
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-21T21:45:21-06:00
Commit Message:
ULTIMA8: Fix button notifications for up and double messages
Changed paths:
engines/ultima/ultima8/gumps/widgets/button_widget.cpp
diff --git a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
index d1bececca45..a5296b5f0b3 100644
--- a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
@@ -135,18 +135,19 @@ void ButtonWidget::onMouseUp(int button, int32 mx, int32 my) {
_shape = _shapeUp;
_frameNum = _frameNumUp;
}
- _parent->ChildNotify(this, BUTTON_UP);
+ if (PointOnGump(mx, my))
+ _parent->ChildNotify(this, BUTTON_UP);
}
}
void ButtonWidget::onMouseClick(int button, int32 mx, int32 my) {
- int gx = mx, gy = my;
- if (PointOnGump(gx, gy))
+ if (PointOnGump(mx, my))
_parent->ChildNotify(this, BUTTON_CLICK);
}
void ButtonWidget::onMouseDouble(int button, int32 mx, int32 my) {
- _parent->ChildNotify(this, BUTTON_DOUBLE);
+ if (PointOnGump(mx, my))
+ _parent->ChildNotify(this, BUTTON_DOUBLE);
}
void ButtonWidget::onMouseOver() {
Commit: 068df3e6756a6d1361b9fd0249834ca59bacc0d7
https://github.com/scummvm/scummvm/commit/068df3e6756a6d1361b9fd0249834ca59bacc0d7
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-21T21:45:21-06:00
Commit Message:
ULTIMA8: Change gump dragging to handle directly rather than through the parent.
This should help enable gump resizing by altering drag behavior at the borders.
Changed paths:
engines/ultima/ultima8/gumps/desktop_gump.cpp
engines/ultima/ultima8/gumps/desktop_gump.h
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/gumps/gump.h
engines/ultima/ultima8/gumps/slider_gump.cpp
engines/ultima/ultima8/gumps/slider_gump.h
engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
engines/ultima/ultima8/gumps/widgets/sliding_widget.h
engines/ultima/ultima8/kernel/mouse.cpp
diff --git a/engines/ultima/ultima8/gumps/desktop_gump.cpp b/engines/ultima/ultima8/gumps/desktop_gump.cpp
index 6773660d713..aae3efe1513 100644
--- a/engines/ultima/ultima8/gumps/desktop_gump.cpp
+++ b/engines/ultima/ultima8/gumps/desktop_gump.cpp
@@ -69,23 +69,6 @@ void DesktopGump::PaintChildren(RenderSurface *surf, int32 lerp_factor, bool sca
}
}
-bool DesktopGump::StartDraggingChild(Gump *gump, int32 mx, int32 my) {
- gump->ParentToGump(mx, my);
- Mouse::get_instance()->setDraggingOffset(mx, my);
- MoveChildToFront(gump);
- return true;
-}
-
-void DesktopGump::DraggingChild(Gump *gump, int mx, int my) {
- int32 dx, dy;
- Mouse::get_instance()->getDraggingOffset(dx, dy);
- gump->Move(mx - dx, my - dy);
-}
-
-void DesktopGump::StopDraggingChild(Gump *gump) {
-
-}
-
void DesktopGump::RenderSurfaceChanged(RenderSurface *surf) {
// Resize the desktop gump to match the RenderSurface
Rect new_dims;
diff --git a/engines/ultima/ultima8/gumps/desktop_gump.h b/engines/ultima/ultima8/gumps/desktop_gump.h
index 27c4f562546..586ecd95f8e 100644
--- a/engines/ultima/ultima8/gumps/desktop_gump.h
+++ b/engines/ultima/ultima8/gumps/desktop_gump.h
@@ -43,10 +43,6 @@ public:
void PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) override;
void PaintChildren(RenderSurface *surf, int32 lerp_factor, bool scaled) override;
- bool StartDraggingChild(Gump *gump, int32 mx, int32 my) override;
- void DraggingChild(Gump *gump, int mx, int my) override;
- void StopDraggingChild(Gump *gump) override;
-
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index d8e4298180d..a29d1bebcc4 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -27,6 +27,7 @@
#include "ultima/ultima8/games/game_data.h"
#include "ultima/ultima8/gumps/gump_notify_process.h"
#include "ultima/ultima8/kernel/kernel.h"
+#include "ultima/ultima8/kernel/mouse.h"
#include "ultima/ultima8/kernel/object_manager.h"
#include "ultima/ultima8/ultima8.h"
@@ -661,16 +662,23 @@ Gump *Gump::GetRootGump() {
}
-bool Gump::StartDraggingChild(Gump *gump, int32 mx, int32 my) {
+bool Gump::onDragStart(int32 mx, int32 my) {
+ if (IsDraggable() && _parent) {
+ ParentToGump(mx, my);
+ Mouse::get_instance()->setDraggingOffset(mx, my);
+ _parent->MoveChildToFront(this);
+ return true;
+ }
return false;
}
-void Gump::DraggingChild(Gump *gump, int mx, int my) {
- CANT_HAPPEN();
+void Gump::onDragStop(int32 mx, int32 my) {
}
-void Gump::StopDraggingChild(Gump *gump) {
- CANT_HAPPEN();
+void Gump::onDrag(int32 mx, int32 my) {
+ int32 dx, dy;
+ Mouse::get_instance()->getDraggingOffset(dx, dy);
+ Move(mx - dx, my - dy);
}
//
diff --git a/engines/ultima/ultima8/gumps/gump.h b/engines/ultima/ultima8/gumps/gump.h
index 8b4987ccc57..c7a7cdf95ad 100644
--- a/engines/ultima/ultima8/gumps/gump.h
+++ b/engines/ultima/ultima8/gumps/gump.h
@@ -381,12 +381,11 @@ public:
return _index;
}
- // Dragging
- //! Called when a child gump starts to be dragged.
- //! \return false if the child isn't allowed to be dragged.
- virtual bool StartDraggingChild(Gump *gump, int32 mx, int32 my);
- virtual void DraggingChild(Gump *gump, int mx, int my);
- virtual void StopDraggingChild(Gump *gump);
+ //! Called when a gump starts to be dragged.
+ //! \return false if the gump isn't allowed to be dragged.
+ virtual bool onDragStart(int32 mx, int32 my);
+ virtual void onDragStop(int32 mx, int32 my);
+ virtual void onDrag(int32 mx, int32 my);
//! This will be called when an item in this gump starts to be dragged.
//! \return false if the item isn't allowed to be dragged.
diff --git a/engines/ultima/ultima8/gumps/slider_gump.cpp b/engines/ultima/ultima8/gumps/slider_gump.cpp
index 00b102da9b8..7e421963a83 100644
--- a/engines/ultima/ultima8/gumps/slider_gump.cpp
+++ b/engines/ultima/ultima8/gumps/slider_gump.cpp
@@ -156,26 +156,38 @@ void SliderGump::InitGump(Gump *newparent, bool take_focus) {
}
void SliderGump::ChildNotify(Gump *child, uint32 message) {
- if (message == ButtonWidget::BUTTON_CLICK) {
- switch (child->GetIndex()) {
- case OK_INDEX:
+ switch (child->GetIndex()) {
+ case OK_INDEX:
+ if (message == ButtonWidget::BUTTON_CLICK)
Close();
- break;
- case LEFT_INDEX:
+ break;
+ case LEFT_INDEX:
+ if (message == ButtonWidget::BUTTON_UP) {
_value -= _delta;
- if (_value < _min) _value = _min;
+ if (_value < _min)
+ _value = _min;
setSliderPos();
- break;
- case RIGHT_INDEX:
+ }
+ break;
+ case RIGHT_INDEX:
+ if (message == ButtonWidget::BUTTON_UP) {
_value += _delta;
- if (_value > _max) _value = _max;
+ if (_value > _max)
+ _value = _max;
setSliderPos();
- break;
}
+ break;
+ case SLIDER_INDEX:
+ if (message == SlidingWidget::DRAGGING) {
+ int32 x, y;
+ child->getLocation(x, y);
+ setValueFromSlider(x);
+ setSliderPos();
+ }
+ break;
}
}
-
void SliderGump::Close(bool no_del) {
_processResult = _value;
@@ -189,28 +201,6 @@ void SliderGump::Close(bool no_del) {
ModalGump::Close(no_del);
}
-bool SliderGump::StartDraggingChild(Gump *gump, int32 mx, int32 my) {
- if (gump->GetIndex() == SLIDER_INDEX) {
- gump->ParentToGump(mx, my);
- Mouse::get_instance()->setDraggingOffset(mx, 0);
- return true;
- }
-
- return false;
-}
-
-void SliderGump::DraggingChild(Gump *gump, int mx, int my) {
- if (gump->GetIndex() == SLIDER_INDEX) {
- int32 dox, doy;
- Mouse::get_instance()->getDraggingOffset(dox, doy);
- setValueFromSlider(mx - dox);
- gump->Move(getSliderPos(), slidery);
- }
-}
-
-void SliderGump::StopDraggingChild(Gump *gump) {
-}
-
bool SliderGump::OnKeyDown(int key, int mod) {
switch (key) {
case Common::KEYCODE_LEFT:
diff --git a/engines/ultima/ultima8/gumps/slider_gump.h b/engines/ultima/ultima8/gumps/slider_gump.h
index 68f4b0a933a..760af669ba1 100644
--- a/engines/ultima/ultima8/gumps/slider_gump.h
+++ b/engines/ultima/ultima8/gumps/slider_gump.h
@@ -50,11 +50,6 @@ public:
void setUsecodeNotify(UCProcess *ucp);
- // Dragging
- bool StartDraggingChild(Gump *gump, int32 mx, int32 my) override;
- void DraggingChild(Gump *gump, int mx, int my) override;
- void StopDraggingChild(Gump *gump) override;
-
bool OnKeyDown(int key, int mod) override;
bool loadData(Common::ReadStream *rs, uint32 version);
diff --git a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
index bf79ac85d8c..cb97dffa265 100644
--- a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
@@ -52,6 +52,11 @@ uint16 SlidingWidget::TraceObjId(int32 mx, int32 my) {
return 0;
}
+void SlidingWidget::onDrag(int mx, int my) {
+ Gump::onDrag(mx, my);
+ _parent->ChildNotify(this, DRAGGING);
+}
+
void SlidingWidget::saveData(Common::WriteStream *ws) {
Gump::saveData(ws);
}
diff --git a/engines/ultima/ultima8/gumps/widgets/sliding_widget.h b/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
index 6a4762635f9..f0db83876cf 100644
--- a/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
+++ b/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
@@ -39,8 +39,14 @@ public:
void InitGump(Gump *newparent, bool take_focus = true) override;
uint16 TraceObjId(int32 mx, int32 my) override;
+ void onDrag(int32 mx, int32 my) override;
+
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
+
+ enum Message {
+ DRAGGING = 0
+ };
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index 8dc765d48f5..90ed1cf39bc 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -378,7 +378,7 @@ void Mouse::startDragging(int startx, int starty) {
assert(parent); // can't drag root gump
int32 px = startx, py = starty;
parent->ScreenSpaceToGump(px, py);
- if (gump->IsDraggable() && parent->StartDraggingChild(gump, px, py))
+ if (gump->IsDraggable() && gump->onDragStart(px, py))
_dragging = DRAG_OK;
else {
_dragging_objId = 0;
@@ -437,7 +437,7 @@ void Mouse::moveDragging(int mx, int my) {
assert(parent); // can't drag root gump
int32 px = mx, py = my;
parent->ScreenSpaceToGump(px, py);
- parent->DraggingChild(gump, px, py);
+ gump->onDrag(px, py);
} else {
// for an item, notify the gump it's on
if (item) {
@@ -479,7 +479,9 @@ void Mouse::stopDragging(int mx, int my) {
if (gump) {
Gump *parent = gump->GetParent();
assert(parent); // can't drag root gump
- parent->StopDraggingChild(gump);
+ int32 px = mx, py = my;
+ parent->ScreenSpaceToGump(px, py);
+ gump->onDragStop(mx, my);
} else if (item) {
// for an item: notify gumps
if (_dragging != DRAG_INVALID) {
More information about the Scummvm-git-logs
mailing list