It is currently March 28th, 2024, 12:31 pm

[CANCELED] Fileview Scrollbar...

Get help with creating, editing & fixing problems with skins
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Measures...

Post by exper1mental »

Brian wrote:I believe what is happening is your calc measure MeasureScrollBarHeight is trying to read the measures MeasureFolderCount and MeasureFileCount before the plugin is done gathering that information. So in essence, you are trying to divide by 0 because those measure are 0 until the plugin is done gathering the information.

Here is what I would suggest you do. Remove the group from your Calc measure, like this:

Code: Select all

[MeasureScrollBarHeight]
Measure=Calc
Formula=(420 / ((MeasureFolderCount + MeasureFileCount) / 25))
Disabled=1
Then in your FinishAction (on your MeasurePath measure), manually update the Calc measure. Like this:

Code: Select all

[MeasurePath]
Measure=Plugin
Plugin=FileView
Path="#StartMenuPath#"
ShowHidden=0
HideExtensions=1
Count=#ItemCount#
FinishAction=[!EnableMeasure MeasureScrollBarHeight][!UpdateMeterGroup StartMenu]
Disabled=1
Group=StartMenuMeasure
Its fixed! :yahoo:

Now I can finally start messing with the actual implementation of the scrolling bar.
Brian wrote:Hopefully that does it for you, if not, could you please post your entire skin (in .rmskin format) so that I (or others :)) can take a better look?

-Brian
I was hoping to avoid that if possible, as the .ini file in question has 2,100+ lines of code O.O (which is a headache to deal with till you know where everything is).

If I did do something like that, I'd probably upload a striped-down variant (after verifying that the problem still exists) only including the bare essentials for solving the problem.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Fileview Scrollbar...

Post by eclectic-tech »

EDIT: I missed your "solved" post... my apology for adding to an already solved issue.

---
See my measures below that work to develop a scrollbar.

I think it would be simpler to calculate your number of total pages, and divide that by the number of items displayed, to give you your position in the folder. The extra calculations in your current position measure, would be done in the actual bar meter for the scrollbar.

Here is what I have done using page changes (not indexes) and it works very well. With some minor changes you can get it to work with indexes also. Feel free to use any of it if it helps.

Code: Select all

[Variables]
NumberMenuItems=15
TotalPages=[mPages]
...

;----------------------------------------------------
; Measures
;----------------------------------------------------

[mPages]
Measure=Calc
Formula=Trunc((([mFolderCount]+[mFileCount])-1)/#NumberMenuItems#)
DynamicVariables=1
; Divides the total items by number on each page to determine how many pages are in the menu. 

[mPageNumber]
Measure=Calc
Formula=(#Page#+1)
DynamicVariables=1
; Used in string display so pages start at '1' and not '0'

[mPageTotal]
Measure=Calc
Formula=(#TotalPages#+1)
DynamicVariables=1
; Correction needed to have pages start at '1'

[mPagePositionPercent]
Measure=Calc
Formula=((mPageNumber/mPageTotal)*100)
MaxValue=100
DynamicVariables=1
; Calculates the bar graph height based on the current page number compared to (divided by) the total number of items in the menu. 

[mPath]
Measure=Plugin
Plugin=FileView
Path="#CurrentMenuPath#"
ShowDotDot=0
;SortAscending=0
;SortType=Type
;SortDateType=Created
;Recursive=1
;ShowFolder=0
;ShowFile=0
ShowHidden=0
HideExtensions=1
;Extensions="jpg;png"
Count=#NumberMenuItems#

[mFolderCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderCount

[mFileCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileCount

...
Image
The scrollbar is pretty transparent in this image, but is half way down...
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Scrollbar...

Post by exper1mental »

eclectic-tech wrote:If the number of files and folders is less than the "Count" of FileView, then you would be dividing by zero. See my measures below that work to develop a scrollbar.

I think it would be simpler to calculate your number of total pages, and divide that by the number of items displayed, to give you your position in the folder. The extra calculations in your current position measure, would be done in the actual bar meter for the scrollbar.

Here is what I have done using page changes (not indexes) and it works very well. With some minor changes you can get it to work with indexes also. Feel free to use any of it if it helps.

Code: Select all

[Variables]
NumberMenuItems=15
TotalPages=[mPages]
...

;----------------------------------------------------
; Measures
;----------------------------------------------------

[mPages]
Measure=Calc
Formula=Trunc((([mFolderCount]+[mFileCount])-1)/#NumberMenuItems#)
DynamicVariables=1
; Divides the total items by number on each page to determine how many pages are in the menu. 

[mPageNumber]
Measure=Calc
Formula=(#Page#+1)
DynamicVariables=1
; Used in string display so pages start at '1' and not '0'

[mPageTotal]
Measure=Calc
Formula=(#TotalPages#+1)
DynamicVariables=1
; Correction needed to have pages start at '1'

[mPagePositionPercent]
Measure=Calc
Formula=((mPageNumber/mPageTotal)*100)
MaxValue=100
DynamicVariables=1
; Calculates the bar graph height based on the current page number compared to (divided by) the total number of items in the menu. 

[mPath]
Measure=Plugin
Plugin=FileView
Path="#CurrentMenuPath#"
ShowDotDot=0
;SortAscending=0
;SortType=Type
;SortDateType=Created
;Recursive=1
;ShowFolder=0
;ShowFile=0
ShowHidden=0
HideExtensions=1
;Extensions="jpg;png"
Count=#NumberMenuItems#

[mFolderCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderCount

[mFileCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileCount

...
Image
The scrollbar is pretty transparent in this image, but is half way down...
k, I'll give that a shot if what I'm currently trying won't work.


I'm having a little trouble though getting the Bar to work correctly in displaying the percentage of the folder being displayed. Instead of showing the percentage of the folder it shows 100% being viewed all the time.

Note: Once I get this working I'll move on to getting Y to move accordingly.

Here is the bar and measures in question:

Code: Select all

[ScrollPosition]
Meter=Bar
MeasureName=MeasureScrollBarHeight
BarColor=150,150,150,200
SolidColor=100,100,100,255
x=r
y=(0*10)+#MenuY#+16
h=420
w=9
BarOrientation=Vertical
Flip=1
AntiAlias=1
Hidden=1

[MeasureScrollBarHeight]
Measure=Calc
Formula=(100 / ((MeasureFolderCount + MeasureFileCount) / #ItemCount#))
Disabled=1
FinishAction=[!UpdateMeter ScrollPosition]

[MeasureFolderCount]
Measure=Plugin
Plugin=FileView
Path=[MeasurePath]
Type=FolderCount
Disabled=1
Group=StartMenuMeasure

[MeasureFileCount]
Measure=Plugin
Plugin=FileView
Path=[MeasurePath]
Type=FileCount
Disabled=1
Group=StartMenuMeasure

[MeasurePath]
Measure=Plugin
Plugin=FileView
Path="#StartMenuPath#"
ShowHidden=0
HideExtensions=1
Count=#ItemCount#
FinishAction=[!EnableMeasure MeasureScrollBarHeight][!ShowMeter ScrollPosition][!UpdateMeterGroup StartMenu]
Disabled=1
Group=StartMenuMeasure
Variables (in case they are relevant):

Code: Select all

StartMenuPath=%SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs
MenuY=66
ItemCount=25
Stripped version of program is included in this RMskin (fileview won't display correctly if using XP):
Start Menu Scrolling Issue_3.0.rmskin
(577.02 KiB) Downloaded 102 times
Once the skin is loaded, click the arrow bar. You should see a stripped bar with arrows pointing in opposite directions. This is the background for the scrolling bar.

Move your mouse to the left of it and it should turn a solid dark grey (this is a bug relating to the striped down version, but not the full), which is supposed to be the secondary color of the bar (when I get the bar working this will be transparent).

If you try scrolling the bar will turn a solid light gray, but not in proportion to the amount of files being shown. This is the problem in question that I need help with.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Scrollbar...

Post by exper1mental »

eclectic-tech wrote:EDIT: I missed your "solved" post... my apology for adding to an already solved issue.
The "solved" issue was getting rid of the calc divide by zero error. I'm still working on getting the scrollbar to properly display the % of the page being viewed.

Unless anyone has a better idea or sees what I messed up I'm going to try using your posted code (which mine backed up in case someone does figure it out) and see if I can get it to work.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Scrollbar...

Post by exper1mental »

@ eclectic-tech, what does #Page# in

Code: Select all

[mPageNumber]
Measure=Calc
Formula=(#Page#+1)
DynamicVariables=1
; Used in string display so pages start at '1' and not '0'
equal?[/strike]

Nvm, downloaded your skin and dug out it from#@#Options/Variables.inc.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Scrollbar...

Post by exper1mental »

I think I found my problem, I was basing this off of someone else's code and in [FileCount] and [FolderCount] they used Type= instead of InfoType=.

I'm gonna kill myself if this doesn't work.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: Fileview Scrollbar...

Post by exper1mental »

I've decided to drop the ball on this one until I get some other stuff completed for this skin.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [CANCELED] Fileview Scrollbar...

Post by Virginityrocks »

I was working hard to get the scroll bar to work as well, and eventually decided to just quit. It's not important for my skin, but it really is handy. The only problem I'm having is getting MouseScrollUpAction and MouseScrollDownAction to behave properly with [!WriteKeyValue Variables ScrollPercent (ScrollPercent+1)] etc, but that does not work properly.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [CANCELED] Fileview Scrollbar...

Post by Brian »

You guys give up too easily! Just kidding. 8-)

The example below shows how you can create a scrollbar with some simple math. Of course it does have some pitfalls (which I will explain later).

Below is an updated version of my test skin (originally located here). It uses a little Lua to help catch some "out of bounds" conditions. Also, I am particularly proud the scroll bar's height because it is not a fixed, meaning it grows/shrinks depending on the amount of items in your list (just like a real scrollbar).

Here is the .ini file:

Code: Select all

[Rainmeter]
MouseScrollUpAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(-1)][!CommandMeasure mPath "IndexUp"][!UpdateMeasure mPath]
MouseScrollDownAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(1)][!CommandMeasure mPath "IndexDown"][!UpdateMeasure mPath]

[Variables]
IconSize=Large
Count=8

;----------------------------------------------------
; Styles
;----------------------------------------------------

[TextStyle]
FontColor=255,255,255,255
AntiAlias=1

[TextHighlight]
FontColor=150,150,255,255

[IconStyle]
X=5
Y=r
AntiAlias=1

[HighlightStyle]
SolidColor=0,0,0,1
X=5
Y=5R
W=365
H=([Index1Icon:H] > [Index1Info:H] ? [Index1Icon:H] : [Index1Info:H])
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# SolidColor "50,50,255,150"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# SolidColor ""][!UpdateMeter #CURRENTSECTION#][!Redraw]

[InfoStyle]
X=5R
Y=r
Text="%1 #CRLF#%2 #CRLF#%3 "
AutoScale=1
AntiAlias=1

;----------------------------------------------------
; Measures
;----------------------------------------------------

[mPath]
Measure=Plugin
Plugin=FileView
Path="C:\"
ShowDotDot=0
Count=#Count#
FinishAction=[!UpdateMeasureGroup Children][!UpdateMeasureGroup Scrollbar][!UpdateMeter *][!Redraw]

[mFolderCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderCount
Group=Children

[mFileCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileCount
Group=Children

[mFolderSize]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderSize
Group=Children

;----------------------------------------------------
; Index 1

[mIndex1Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=1
Group=Children

[mIndex1Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=1
Group=Children

[mIndex1Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=1
Group=Children

[mIndex1Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=1
Group=Children

;----------------------------------------------------
; Index 2

[mIndex2Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=2
Group=Children

[mIndex2Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=2
Group=Children

[mIndex2Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=2
Group=Children

[mIndex2Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=2
Group=Children

;----------------------------------------------------
; Index 3

[mIndex3Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=3
Group=Children

[mIndex3Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=3
Group=Children

[mIndex3Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=3
Group=Children

[mIndex3Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=3
Group=Children

;----------------------------------------------------
; Index 4

[mIndex4Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=4
Group=Children

[mIndex4Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=4
Group=Children

[mIndex4Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=4
Group=Children

[mIndex4Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=4
Group=Children

;----------------------------------------------------
; Index 5

[mIndex5Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=5
Group=Children

[mIndex5Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=5
Group=Children

[mIndex5Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=5
Group=Children

[mIndex5Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=5
Group=Children

;----------------------------------------------------
; Index 6

[mIndex6Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=6
Group=Children

[mIndex6Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=6
Group=Children

[mIndex6Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=6
Group=Children

[mIndex6Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=6
Group=Children

;----------------------------------------------------
; Index 7

[mIndex7Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=7
Group=Children

[mIndex7Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=7
Group=Children

[mIndex7Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=7
Group=Children

[mIndex7Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=7
Group=Children

;----------------------------------------------------
; Index 8

[mIndex8Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=8
Group=Children

[mIndex8Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=8
Group=Children

[mIndex8Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
Index=8
Group=Children

[mIndex8Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=8
Group=Children

;----------------------------------------------------
; Meters
;----------------------------------------------------

[Background]
Meter=Image
SolidColor=0,0,0,200
W=400
H=500

[PathTitle]
Meter=String
MeterStyle=TextStyle
Text=Path:

[Path]
Meter=String
MeasureName=mPath
MeterStyle=TextStyle | TextHighlight
Text="%1 "
X=R

[FolderCountTitle]
Meter=String
MeterStyle=TextStyle
X=0
Y=R
Text=Folders:

[FolderCount]
Meter=String
MeasureName=mFolderCount
MeterStyle=TextStyle | TextHighlight
X=R
Y=r

[FileCountTitle]
Meter=String
MeterStyle=TextStyle
X=10R
Y=r
Text=Files:

[FileCount]
Meter=String
MeasureName=mFileCount
MeterStyle=TextStyle | TextHighlight
X=R
Y=r

[FolderSizeTitle]
Meter=String
MeterStyle=TextStyle
X=10R
Y=r
Text=Size:

[FolderSize]
Meter=String
MeasureName=mFolderSize
MeterStyle=TextStyle | TextHighlight
X=R
Y=r
AutoScale=1

[Index1]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex1Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index1Icon]
Meter=Image
MeasureName=mIndex1Icon
MeterStyle=IconStyle

[Index1Info]
Meter=String
MeasureName=mIndex1Name
MeasureName2=mIndex1Size
MeasureName3=mIndex1Date
MeterStyle=TextStyle | InfoStyle

[Index2]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex2Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index2Icon]
Meter=Image
MeasureName=mIndex2Icon
MeterStyle=IconStyle

[Index2Info]
Meter=String
MeasureName=mIndex2Name
MeasureName2=mIndex2Size
MeasureName3=mIndex2Date
MeterStyle=TextStyle | InfoStyle

[Index3]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex3Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index3Icon]
Meter=Image
MeasureName=mIndex3Icon
MeterStyle=IconStyle

[Index3Info]
Meter=String
MeasureName=mIndex3Name
MeasureName2=mIndex3Size
MeasureName3=mIndex3Date
MeterStyle=TextStyle | InfoStyle

[Index4]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex4Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index4Icon]
Meter=Image
MeasureName=mIndex4Icon
MeterStyle=IconStyle

[Index4Info]
Meter=String
MeasureName=mIndex4Name
MeasureName2=mIndex4Size
MeasureName3=mIndex4Date
MeterStyle=TextStyle | InfoStyle

[Index5]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex5Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index5Icon]
Meter=Image
MeasureName=mIndex5Icon
MeterStyle=IconStyle

[Index5Info]
Meter=String
MeasureName=mIndex5Name
MeasureName2=mIndex5Size
MeasureName3=mIndex5Date
MeterStyle=TextStyle | InfoStyle

[Index6]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex6Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index6Icon]
Meter=Image
MeasureName=mIndex6Icon
MeterStyle=IconStyle

[Index6Info]
Meter=String
MeasureName=mIndex6Name
MeasureName2=mIndex6Size
MeasureName3=mIndex6Date
MeterStyle=TextStyle | InfoStyle

[Index7]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex7Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index7Icon]
Meter=Image
MeasureName=mIndex7Icon
MeterStyle=IconStyle

[Index7Info]
Meter=String
MeasureName=mIndex7Name
MeasureName2=mIndex7Size
MeasureName3=mIndex7Date
MeterStyle=TextStyle | InfoStyle

[Index8]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex8Name "FollowPath"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]

[Index8Icon]
Meter=Image
MeasureName=mIndex8Icon
MeterStyle=IconStyle

[Index8Info]
Meter=String
MeasureName=mIndex8Name
MeasureName2=mIndex8Size
MeasureName3=mIndex8Date
MeterStyle=TextStyle | InfoStyle


[PreviousFolder]
Meter=String
MeterStyle=TextStyle
FontSize=15
X=5
Y=10R
Text=Previous Folder
LeftMouseDoubleClickAction=[!CommandMeasure mPath "PreviousFolder"][!UpdateMeasure mPath][!CommandMeasure ScrollbarScript ResetPosition()]
MouseOverAction=[!SetOption #CURRENTSECTION# SolidColor "50,50,255,150"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# SolidColor ""][!UpdateMeter #CURRENTSECTION#][!Redraw]


[NumberItems]
Measure=Calc
Formula=mFolderCount + mFileCount
IfBelowValue=#Count#
IfBelowAction=[!HideMeterGroup Scrollbar][!UpdateMeterGroup Scrollbar][!Redraw]
IfAboveValue=#Count#
IfAboveAction=[!ShowMeterGroup Scrollbar][!UpdateMeterGroup Scrollbar][!Redraw]
Group=Scrollbar

[Size]
Measure=Calc
Formula=([Index1:H] * #Count#) - 2
DynamicVariables=1
Group=Scrollbar

[ScrollH]
Measure=Calc
Formula=Size * (#Count# / (NumberItems = 0 ? 1 : NumberItems))
Group=Scrollbar

[ScrollbarScript]
Measure=Script
ScriptFile=Scrollbar.lua

[IndexUp]
Meter=String
SolidColor=168,168,168,200
X=([Index1:X] + [Index1:W])
Y=[Index1:Y]
W=15
H=15
FontFace=Webdings
Text=5
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(-1)][!CommandMeasure mPath "IndexUp"][!UpdateMeasure mPath]
Group=ScrollBar

[CurrentPos]
Meter=Image
SolidColor=168,168,168
X=r
Y=R
W=15
H=[ScrollH]
DynamicVariables=1
Group=ScrollBar

[IndexDown]
Meter=String
SolidColor=168,168,168,200
X=r
Y=([Index8:Y] + [Index8:H] - 15)
W=15
H=15
FontFace=Webdings
Text=6
LeftMouseUpAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(1)][!CommandMeasure mPath "IndexDown"][!UpdateMeasure mPath]
DynamicVariables=1
Group=ScrollBar

[PageUp]
Meter=Image
SolidColor=168,168,168,150
X=r
Y=([IndexUp:Y] + [IndexUp:H])
W=15
H=([CurrentPos:Y] - [PageUp:Y])
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(-#Count#)][!CommandMeasure mPath "PageUp"][!UpdateMeasure mPath]
Group=ScrollBar

[PageDown]
Meter=Image
SolidColor=168,168,168,150
X=r
Y=([CurrentPos:Y] + [CurrentPos:H])
W=15
H=([IndexDown:Y] - [PageDown:Y])
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure ScrollbarScript UpdateCurrentPos(#Count#)][!CommandMeasure mPath "PageDown"][!UpdateMeasure mPath]
Group=ScrollBar
And the .lua file:

Code: Select all

function Initialize()
    currentPos = 0
end

function ResetPosition()
    currentPos = 0
    UpdateCurrentPos(0)
end

function UpdateCurrentPos(amount)
    currentPos = currentPos + amount
    if currentPos < 0 then
        currentPos = 0
    end

    count = SKIN:GetVariable('Count')
    maxItems = SKIN:GetMeasure('NumberItems'):GetValue()
    if currentPos ~= 0 and currentPos > (maxItems - count) then
        currentPos = maxItems - count
    end

    size = SKIN:GetMeasure('Size'):GetValue()
    SKIN:Bang('!SetOption', 'CurrentPos', 'Y', currentPos * (size / maxItems) ..'R')
end
First, I want to talk a little bit about this scrollbar. The scrollbar consists of 5 meters - 2 String meters that run the IndexUp/Down commands, 1 Image meter that represents the current "position" in the list, and 2 Image meters that represent the PageUp/Down commands (they are the dark grey meters in between the "position" meter and the IndexUp/Down meters.

Second, there are a couple of "helper" measures that calculate the size of the "position" meter and the overall size of the scrollbar scroll area.

Measure NumberItems just represents the amount of items that are in the list. Note: I placed "ShowDotDot=0" in my parent FileView plugin measure. The reason is because the ".." folder is not counted as a folder. If you are displaying this folder in your list, add 1 to the formula in this measure.

Measure [Size] represents the overall size of the scrollbar minus the height of the "arrow" String meters. I used a Calc because I did want to manually figure out the height I want since my test skin can change size depending on the size of the icon you want.

Measure ScrollH determines the height of the position meter. I think the formula is fairly easy to follow. Basically you take the number items you are displaying in your list divided by the number of items that are in the list then multiplying by the size of scrollbar. The conditional operator is just assure that there is no divide by 0 error.

Next is the Lua script. The function that does all the work is the UpdateCurrentPos function. This function makes sure the current position is not "out of bounds", then calculates and updates the [CurrentPos] meter using relative positioning.

Now, when you click on a meter that runs the IndexUp/Down or PageUp/Down commands, you should update the position of the scrollbar by calling the UpdateCurrentPos function. Likewise, when you navigate to another folder, you should reset the position of the scrollbar back to the top by calling the ResetPosition function.

Pretty easy huh!? :-)

There is one problem that I cannot solve at this time. When navigating a list that contains both files and folders, there is no way to tell if you are navigating to a new folder, or just trying to open a file. Since we are resetting the position of the scrollbar when double clicking on an item, the scrollbar resets. If you clicked on a folder, then all is well, but if you clicked on a file, then the scrollbar position does not represent the real position. I have no solution for this at this time.

-Brian
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University
Contact:

Re: [CANCELED] Fileview Scrollbar...

Post by exper1mental »

Brian wrote:You guys give up too easily! Just kidding. 8-)
The reason I "gave up" was b/c I simply didn't have the time to keep messing with this. A scrollbar wasn't a crucial part of what I was trying to do so it got bumped down the to-do list until more I have more time to kill.
Post Reply