Skip to content

Commit

Permalink
fixed draggable entities
Browse files Browse the repository at this point in the history
  • Loading branch information
RonenNess committed Nov 26, 2021
1 parent 2a41b6e commit 1c9fc37
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions GeonBit.UI.Examples/GeonBitUI_Examples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ protected void InitExamplesAndUI()
{
// create panel and add to list of panels and manager
Panel panel = new Panel(new Vector2(520, -1));
panel.Draggable = true;
panels.Add(panel);
UserInterface.Active.AddEntity(panel);

Expand Down
4 changes: 2 additions & 2 deletions GeonBit.UI/Source/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,9 +1861,9 @@ virtual public Rectangle CalcDestRect()
if (_draggable)
{
// if need to init dragged offset, set it
// this trick is used so if an object is draggable, we first evaluate its position based on anchor etc, and we use that
// this trick is used so if an object is draggable, we first evaluate its position based on anchor, and we use that
// position as starting point for the dragging
if (_needToSetDragOffset)
if (_needToSetDragOffset && (parentDest.Width > 0) && (parentDest.Height > 0) && (ret.Height > 1))
{
_dragOffset.X = ret.X - parent_left;
_dragOffset.Y = ret.Y - parent_top;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,7 @@ For older MonoGame versions, see [tag 2.1.0.0](https://github.com/RonenNess/Geon
- Changed Button 'Value Changed' event to only emit if value actually changed.
- Changed CheckBox 'Value Changed' event to only emit if value actually changed.
- Fixed TextInput 'Value Changed' event to trigger when changing value externally.
- Fixed offset for draggable panels that are not aligned top-left and visible in first update frame (used to have bug that changed their position to top left).

## Credits

Expand Down

0 comments on commit 1c9fc37

Please sign in to comment.