Skip to content

Hotfix OSD Drag\Drop for multiline elements #1165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 16, 2018

Conversation

frozenskys
Copy link
Contributor

Fixes #1159
Please test...

Copy link
Member

@mikeller mikeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the stray spaces.

@@ -1391,17 +1391,25 @@ OSD.GUI.preview = {
},
onDragStart: function(e) {
var ev = e.originalEvent;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray space.

@@ -1428,16 +1441,16 @@ OSD.GUI.preview = {
overflows_line = FONT.constants.SIZES.LINE - ((position % FONT.constants.SIZES.LINE) + display_item.preview.length);
if (overflows_line < 0) {
position += overflows_line;
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd think I'd know better having developed python for several years!

@mikeller mikeller added this to the 10.5.0 milestone Aug 15, 2018
@mikeller
Copy link
Member

Hmm, this improves it, but I am not sure that it is completely the way it should be. When grabbing a large element on a side, the element will jump to be centered around the mouse cursor once the grabbing has completed, which is unintuitive:

out-3.ogv.zip

I think that instead of this, the mouse cursor should stay on whatever position on the element it is on when the element is grabbed.

@frozenskys
Copy link
Contributor Author

frozenskys commented Aug 15, 2018

@mikeller I thought I'd fixed that - are you using the standalone or chrome app - and what OS?

Basically most of the code in onDragStart is working out the pixel offset so this doesn't happen. I'm using the standalone app on Windows 10 64Bit and it's working OK, I'm assuming this is an OS difference.

  onDragStart: function(e) {
    var ev = e.originalEvent;
    var display_item = OSD.data.display_items[$(ev.target).data('field').index];
    var xPos = ev.currentTarget.dataset.x;
    var yPos = ev.currentTarget.dataset.y;
    var offsetX = 6;
    var offsetY = 9;

    if (display_item.preview.constructor === Array) {
        var arrayElements = display_item.preview;
        var limits = OSD.searchLimitsElement(arrayElements);
        xPos -= limits.minX;
        yPos -= limits.minY;
        offsetX += (xPos) * 12;
        offsetY += (yPos) * 18;
    }
    ev.dataTransfer.setDragImage($(this).data('field').preview_img, offsetX, offsetY);
  },

@mikeller
Copy link
Member

Tried another time, to check if there was console output. This time it worked fine. No idea what was wrong the last time, but it's all good now, thanks!

@mikeller mikeller merged commit 02f4860 into betaflight:master Aug 16, 2018
@frozenskys frozenskys deleted the hotfix-osddragdrop branch August 16, 2018 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants