DHorizontalScroller: Added draggable elements support #835

Merged
merged 2 commits into from Apr 18, 2015

Projects

None yet

3 participants

@KrakenZ
Contributor
KrakenZ commented Nov 13, 2014
  • Changed the canvas panel into a DDragBase to support draggable elements.
  • Made left and right buttons aligned on bottom.
-- If set to true, will automatically move the dragged element.
DHorizontalScroller:SetUseLiveDrag( bool )

-- By default, the DHorizontalScroller doesn't allow dragging elements.
-- If you call this with a string, all childrens will be draggable.
DHorizontalScroller:MakeDroppable( string )

-- Show / Hide the pink drop targets ( default is false )
DHorizontalScroller:[Set/Get]ShowDropTargets( bool )

-- To be overridden. Called when an internal draggable element got modified (i.e moved).
DHorizontalScroller:OnDragModified()

Here is what it looks like on the tabs of a simple DPropertySheet with the following used functions

MyDPropertySheet.tabScroller:MakeDroppable( "Tabs" )
MyDPropertySheet.tabScroller:SetUseLiveDrag( true )

Example

@KrakenZ KrakenZ DHorizontalScroller: Added draggable elements support
* Changed the canvas panel into a **DDragBase** to support draggable elements.
* Made left and right buttons aligned on bottom.

```lua
-- If set to true, will automatically move the dragged element.
DHorizontalScroller:[Set/Get]UseLiveDrag( bool )

-- By default, the DHorizontalScroller doesn't allow dragging elements.
-- If you call this with a string, all childrens will be draggable.
DHorizontalScroller:MakeDroppable( string )

-- Show / Hide the pink drop targets
DHorizontalScroller:SetShowDropTargets( bool )

-- To be overridden. Called when an internal draggable element got modified (i.e moved).
DHorizontalScroller:OnDragModified()
```

Here is what it looks like on the tabs of a simple DPropertySheet with the following used functions
```lua
MyDPropertySheet.tabScroller:MakeDroppable( "Tabs" )
MyDPropertySheet.tabScroller:SetUseLiveDrag( true )
```
![Example](http://i.imgur.com/hYOajAI.gif)
f658ed6
@KrakenZ
Contributor
KrakenZ commented Nov 13, 2014

Here is another example:

local Frame = vgui.Create( "DFrame" )
Frame:SetSize( 500, 500 )
Frame:Center()
Frame:MakePopup()
Frame:SetSkin( "Default" )
Frame:SetSizable( true )

local scroll = vgui.Create( "DHorizontalScroller", Frame )
scroll:Dock( FILL )
scroll:SetUseLiveDrag( true )
scroll:MakeDroppable( "DropName" )
scroll:SetShowDropTargets( true )

for i=0, 10 do
    local btn = vgui.Create( "DPanel" )
    btn:SetBackgroundColor( Color( math.random( 100,255 ), math.random( 100,255 ), math.random( 100,255 ) ) )

    scroll:AddPanel( btn )
end

Example

@robotboy655 robotboy655 added the pending label Nov 14, 2014
@KrakenZ KrakenZ closed this Jan 15, 2015
@Kefta
Contributor
Kefta commented Jan 16, 2015

Why did you close this?

@KrakenZ
Contributor
KrakenZ commented Jan 16, 2015

If you could have uses for this I can re-open it.
Some lines needs to be changed btw

@Kefta
Contributor
Kefta commented Jan 17, 2015

I would use this personally, just to allow for draggable elements. I think this is a useful feature

@KrakenZ KrakenZ reopened this Jan 18, 2015
@robotboy655 robotboy655 merged commit 3f1149c into garrynewman:master Apr 18, 2015
@ghost
ghost commented Jun 1, 2015

Oh that's awesome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment