Skip to content

Commit

Permalink
fix scroll is not working after disable scrollbar using scrollBarState
Browse files Browse the repository at this point in the history
  • Loading branch information
thisdp committed Oct 1, 2023
1 parent d7a6664 commit 66bac32
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Core/gridlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ function dgsCreateGridList(...)
scrollBarThick = scbThick,
scrollBarLength = {},
scrollBarState = {nil,nil},
wheelScrollable = {true,true},
scrollFloor = {false,false},--move offset ->int or float
scrollBarAlignment = {"right","bottom"},
scrollSize = 60, --60 pixels
Expand Down Expand Up @@ -459,6 +460,18 @@ function dgsGridListSetVerticalScrollPosition(gridlist,vertical)
return dgsScrollBarSetScrollPosition(scb[1],vertical)
end

function dgsGridListSetScrollBarState(gridlist,vertical,horizontal)
if not dgsIsType(gridlist,"dgs-dxgridlist") then error(dgsGenAsrt(gridlist,"dgsGridListSetScrollBarState",1,"dgs-dxgridlist")) end
dgsSetData(gridlist,"scrollBarState",{vertical,horizontal},true)
dgsSetData(gridlist,"configNextFrame",true)
return true
end

function dgsGridListGetScrollBarState(gridlist)
if not dgsIsType(gridlist,"dgs-dxgridlist") then error(dgsGenAsrt(gridlist,"dgsGridListGetScrollBarState",1,"dgs-dxgridlist")) end
return dgsElementData[gridlist].scrollBarState[1],dgsElementData[gridlist].scrollBarState[2]
end

function dgsAttachToGridList(element,gridlist,r,c)
if not isElement(element) then error(dgsGenAsrt(element,"dgsAttachToGridList",1,"element")) end
if dgsGetType(gridlist) ~= "dgs-dxgridlist" then error(dgsGenAsrt(gridlist,"dgsAttachToGridList",2,"dgs-dxgridlist")) end
Expand Down Expand Up @@ -2662,6 +2675,8 @@ dgsOnMouseScrollAction["dgs-dxgridlist"] = function(dgsEle,isWheelDown)
scrollbar = scrollbar1
elseif visibleScb2 and not visibleScb1 then
scrollbar = scrollbar2
elseif not visibleScb1 and not visibleScb2 then
scrollbar = scrollbar1
end
if scrollbar then
dgsSetData(scrollbar,"moveType","slow")
Expand Down
3 changes: 3 additions & 0 deletions Core/scalepane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function dgsCreateScalePane(...)
scrollBarThick = scbThick,
scrollBarAlignment = {"right","bottom"},
scrollBarState = {nil,nil}, --true: force on; false: force off; nil: auto
wheelScrollable = {true,true},
scrollBarLength = {},
horizontalMoveOffsetTemp = 0,
verticalMoveOffsetTemp = 0,
Expand Down Expand Up @@ -390,6 +391,8 @@ dgsOnMouseScrollAction["dgs-dxscalepane"] = function(dgsEle,isWheelDown)
scrollbar = scrollbar1
elseif visibleScb2 and not visibleScb1 then
scrollbar = scrollbar2
elseif not visibleScb1 and not visibleScb2 then
scrollbar = scrollbar1
end
if scrollbar then
dgsSetData(scrollbar,"moveType","slow")
Expand Down
5 changes: 4 additions & 1 deletion Core/scrollpane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dgsRegisterProperties("dgs-dxscrollpane",{
basePointOffset = { { PArg.Number, PArg.Number, PArg.Bool } },
minViewSize = { { PArg.Number, PArg.Number, PArg.Bool } },
scrollBarThick = { PArg.Number },
scrollBarState = { { PArg.Bool+PArg.Nil, PArg.Bool+PArg.Nil } },
scrollBarState = { { PArg.Bool+PArg.String+PArg.Nil, PArg.Bool+PArg.String+PArg.Nil } },
scrollBarLength = { { { PArg.Number, PArg.Bool }, { PArg.Number, PArg.Bool } }, { PArg.Nil, PArg.Nil } },
})
--Dx Functions
Expand Down Expand Up @@ -78,6 +78,7 @@ function dgsCreateScrollPane(...)
scrollBarThick = scbThick,
scrollBarAlignment = {"right","bottom"},
scrollBarState = {nil,nil}, --true: force on; false: force off; nil: auto
wheelScrollable = {true,true},
scrollBarLength = {},
maxChildSize = {0,0},
horizontalMoveOffset = 0,
Expand Down Expand Up @@ -438,6 +439,8 @@ dgsOnMouseScrollAction["dgs-dxscrollpane"] = function(dgsEle,isWheelDown)
scrollbar = scrollbar1
elseif visibleScb2 and not visibleScb1 then
scrollbar = scrollbar2
elseif not visibleScb1 and not visibleScb2 then
scrollbar = scrollbar1
end
if scrollbar then
dgsSetData(scrollbar,"moveType","slow")
Expand Down
2 changes: 2 additions & 0 deletions meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@
<export function="dgsGridListGetHorizontalScrollPosition" type="client" />
<export function="dgsGridListSetVerticalScrollPosition" type="client" />
<export function="dgsGridListGetVerticalScrollPosition" type="client" />
<export function="dgsGridListSetScrollBarState" type="client" />
<export function="dgsGridListGetScrollBarState" type="client" />
<export function="dgsGridListSetNavigationEnabled" type="client" />
<export function="dgsGridListGetNavigationEnabled" type="client" />
<export function="dgsAttachToGridList" type="client" />
Expand Down

0 comments on commit 66bac32

Please sign in to comment.