Scroll to the dropped object when it's released outside of the current view of a GEF editor - drag-and-drop

I have a GEF editor with draggable figures. I have overriden the createChangeConstraintCommand of the main EditPart's XYLayoutEditPolicy.
This allows me to easily move (drag and drop) the figures.
The problem is, that if I drag one of them outside of the current view, although the scroll appears and the figure is moved, the view does not automatically scrolls to the dropped object.
Any idea how to implement this "auto-scroll" functionality? (It would be even nicer to have the "selected" (dragged/dropped) figure always visible in the view.)

Given the editpart object that has been dropped, you should use EditPartViewer#reveal(EditPart) method. Do this for example:
editpart.getViewer().reveal(editpart)

Related

Depending of drag and drop operation from anchor position in unreal engine 4

I have the problem with Drag-and-Drop Operation for UI elements:
i have created a test object to drag: DragTestObject_BP and have override the functions:
OnMouseBottonDown Function and OnDragDetected.
Recepient will be HUD_BP with overridden is OnDrop function.
The problem is, that first drag-and-drop operation is functioning without problem only, if the anchor for drag object is set for upper left corner. Otherwise the drag object has some wired offset.
Position on start:
Drag object jumped by first mouse click on it
Might be a bit late, but youll want to put the widget you're clicking to drag ("DragTestObject_BP") inside of another widget.
It's probably a good idea to remove any canvas panel in "DragTestObject_BP" as well.
This will make the origin of "DragTestObject_BP" where it is located visually, instead of using the location of the canvas panel which is the issue you seem to have run into.

How to implement a 'dynamic' drag and drop (like iOS/Android)?

I would like to implement a 'dynamic' drag and drop in a list. By 'dynamic' I mean that in the list in which the drag is happening, there's an empty space below the dragged element which 'follows it' as you drag through the list (to make it visually obvious where the dropped element will end up in the list). Like what you see in iOS/Android apps supporting D&D.
What I've tried is to use Component.dragEnter to insert an empty Component with the size of the dragged element below the dragged compoment. And as the drag moves through the list, remove the old Component and insert a new one in the new position (explanation of why I create a new Component in next paragraph). However, with the dynamic updates that CN1 does while dragging, and my own updates when moving the empty Component, I just cannot find a way to make it work so I get the right vusual behavior. One aspect making this more complex than you'd think at first is that CN1's built-in support for drag&drop makes the original dragged component invisible with setVisible(false) which means it leaves an empty space behind.
The reason I recreate a new empty Component is because the final drop() will happen on the empty Component, and my trick to make this work is to override drop() on the empty Component to call drop on the dropTarget that is (was) in the Component's position.
All in all, I've spend I don't know how many days trying to get this to work with no success so far. Let me know if anyone has a suggestion for a more straightforward approach?
Big thanks in advance!
The builtin support hides the original component but drags an image of it which you can customize by overriding getDragImage().
You can use custom code to highlight the drop location by using a drag over listener which you can accomplish by using addDragOverListener(ActionListener).

How to prevent splitted views from scrolling together when editing?

When I open one file in two split views in visual studio CODE, I can scroll them separately to a different position. I can edit in one view and see another position in the other view. However, when I hit return to add a new line, the other view suddenly jumps to that position, which is rather annoying.
Not sure, whether this is a bug or a feature. How can it be disabled?

Draggable window in a EditorWindow extended class

I want to make a complex GUI element consistent of buttons, text fields etc. I'd like to be able to move this group, but I can't find a way how.
I tried making a BeginArea, placing all the elements in it and moving the area. For that used a GUI.RepeatButton to check when the mouse button is pressed. It worked, but the update fires only twice and then stops. So I couldn't use this method for smooth dragging.
I've also tried Window to use it with GUI.DragWindow(), but it seems it doesn't work within classes that extend EditorWindow.
Is there a way to make a draggable group for a custom EditorWindow class?

XCode 4 Interface Builder: A better way to work with lots of overlapping views

In IB I have quite a few views that are shown. Many of them are hidden when the app loads, but are shown later when buttons are pressed. This is all fine, but when building this layout in IB it is extremely difficult to layout anything because there are so many overlapping views, some of which are partially transparent (ones that are set to hidden) and other are completely overlapping and covering others. This makes layout very hard.
What is the best method when laying out lots of views like this? Is there another way to break things up? Or better yet, can I hide a a view completely (like in photoshop) so that I can edit the ones underneath, then turn that layer back on?
Another option when trying to select a view that is obscured by another is the shortcut:
'ctrl' + 'shift' and click
It displays a list of all the views under the cursor.
I'm not aware of any way to hide objects in the canvas, but a useful trick for complex layouts is to double-click an item in the document tree to the left - this selects the item and puts focus on the canvas, you can the use the cursor keys to nudge it about.
This doesnt solve the problem of not being able to see things because there are, for example, five or six labels occupying the same space, but if that is the situation it may be a better idea to have a single label and change its contents in code.
I ran into this issue for an app I'm building that has an arial-view image of a park with clickable hotspots. When a hotspot is clicked a popup UIview is displayed with information about that spot in the park. I use the same VC/XIB for three parks. This makes the XIB really busy and hard to work with (i.e the same issue that you have) The detail UIViews make it hard to work with the views underneath. My workaround was to pick each detailed UIView that was hiding the part of the XIB I wanted to work on, and add 1000 to the UIView origin.x in the size inspector. This moved those UIViews enough out of the way for me to do what I needed to with the XIB. Then when I was done, I moved them back by x 1000. (I just needed to move them out horizontally to do what I needed to)
I know its clunky but given that XCode does not have a convenient way to hide portions of an XIB - it was the quickest approach I could think of!
One approach to handling overlapping items in IB is:
Ensure the groups of items that you want to hide are grouped into Views.
Give these Views names: e.g. ViewOptionA, ViewOptionB and ViewOptionC.
Can do this by clicking on name of view in the tree while it is selected and then typing new name.
When you want to hide one of those groups of items:
a) Select the View by either:
i) Clicking on it in the tree at the left or
ii) Ctrl-Shift Clicking in the layout editor and then select the view from the list.
b) In the Attributes Inspector set Alpha to 0.
When you want to unhide one of those groups of items:
As for 2) but set Alpha back to 1
[You do need to remember to unhide all views before you publish!
If you are forgetful like me then perhaps you could subclass UIView and set Alpha to 1. I haven't tried this subclassing idea yet.]