B4A Library [Class] Multi Type SlidingPanels

[Class/Library] Multi Type SlidingPanels

I wanted to make one SlidingPanels that it could be used in multiple ways. Now that I have finished writing the code I put at your disposal.

At the moment you can do these variants SlidingPanels:

- Classic full screen mode.
- Sliding panels with smaller screen.
- Sliding panels with smaller screen and with zoom!
- With or without friction.

Methods:
- Click.
- Change.

Methods:
- JumpToPanel () - Runs the SlidingPanels up to a specific Panel.
- GetCurrentPanel - Returns the number of the current Panel.
- GetSlidingInProgress - Return if the SlidingPaneles is in progress.
- SetSpeedScroll () - Sets the speed of sliding.

It is possible to easily create a page counter thanks to the events.

[UPDATE V1.10]
- Added the ability to use the touch events of Activity, which is useful when you must insert many objects on the panels. Recommended this mode.
- Added the field area to be used for zooming.

[UPDATE V1.10a]
- Minor bug fix for small display.

[UPDATE V1.20]
- Added the LongClick event.
- Changed the type of data sent with the Click events and LongClick.
- Minor improvements.

[UPDATE V1.21]
- Bugfix in FullScreen mode (loop setup).

IMPORTANT
For most fluidity add this code to the Manifest:
B4X:
SetActivityAttribute(Main, android:hardwareAccelerated, "true")

For suggestions and bug reports please do not hesitate to post it here.
 

Attachments

  • Screenshot_2012-11-14-18-22-53 (ridotta).jpg
    Screenshot_2012-11-14-18-22-53 (ridotta).jpg
    11.4 KB · Views: 2,271
  • Screenshot_2012-11-14-18-23-10 (ridotta).jpg
    Screenshot_2012-11-14-18-23-10 (ridotta).jpg
    13.3 KB · Views: 2,151
  • Screenshot_2012-11-14-18-24-18 (ridotta).jpg
    Screenshot_2012-11-14-18-24-18 (ridotta).jpg
    33.7 KB · Views: 2,168
  • Screenshot_2012-11-15-10-02-38 (ridotta).png
    Screenshot_2012-11-15-10-02-38 (ridotta).png
    18.7 KB · Views: 1,919
  • SlidingPanels_1.21.zip
    69.1 KB · Views: 1,224
Last edited:

erfan

Member
Licensed User
Longtime User
thanks man

no. i just tried "[Class]SlidingPanels "

now i tried with activity touch and it works find

thanks
 
Last edited:

CapReed

Member
Licensed User
Longtime User
Hi all,

I have a problem that has caused me to lose much time today along :BangHead:

Suppose I'm on the panel number 0, and I want to commute to the panel number three, WITHOUT PASSING panel number 1 and number 2 panel.

Could you tell me which modification needs to be done in class to avoid receiving the intermediate panels? That is, you can go directly from the panel 0 to 3 without intermediate transitions for panels 2 and 3.

Thank you very much for this great example.

(excuse my bad english ...) :(



UPDATE!!!
I finally managed to solve it. The solution is in the SUB:

Sub PanelToCentre (PanelNumber As Int, Speed ​​As Int)
Move.PanelNumber = **** HERE WE TARGET PANEL NUMBER ****
Move.Start = CalcCenterPosition (PanelNumber, CurrentPanel)
Move.Destination = Display.Width / 2
Speed ​​= Speed ​​/ Display.Width * Abs (Move.Destination-Move.Start)
If UseFriction = FRICTION_DEC Then
Move.Increase = 1
else
Move.Increase = (Move.Destination-Move.Start) / (Speed/Timer1.Interval)
End If
SlidingInProgress = True
Timer1.Enabled = True
End Sub

Thank you for all!
 
Last edited:

me68

Member
Licensed User
Longtime User
Hello Dominex!

I use your SlidingPanels in our app and it is a famous feeling scrolling trough the panels - thanks! We have 11 panels in the meantime.

pict_130807_152315.png


Now i added a panel as cockpit view of the car (an ev-car Citroen C-Zero/Peugeot iOn/Mitsubishi i-MiEV).

pict_130807_151603.png


Now i want to maximize this panel to full screen by double click. If maximized the way back should be another double click.

Is this possible and how?


Martin
 

Dominex

Active Member
Licensed User
Longtime User
Hi all,

I have a problem that has caused me to lose much time today along :BangHead:

Suppose I'm on the panel number 0, and I want to commute to the panel number three, WITHOUT PASSING panel number 1 and number 2 panel.

Could you tell me which modification needs to be done in class to avoid receiving the intermediate panels? That is, you can go directly from the panel 0 to 3 without intermediate transitions for panels 2 and 3.

Thank you very much for this great example.

(excuse my bad english ...) :(



UPDATE!!!
I finally managed to solve it. The solution is in the SUB:



Thank you for all!
Well, I'm glad you solved your problem.
 

me68

Member
Licensed User
Longtime User
Hello Dominex!

I solved it by myself in the meantime.

I made a Sub MaximizeRestorePanels

B4X:
Private Sub MaximizeRestorePanels
    Dim j As Int
    Dim iWidthTemp As Int
    Dim iWidthDelta As Int
   
    If Display.Width = GetDeviceLayoutValues.Width Then
        vWidth = iWidth
        vHeight = iHeight
 
        Display.Left = iLeft
        Display.Top = iTop
        Display.Width = iWidth
        Display.Height = iHeight
       
        For j = 0 To Panels.Length - 1
            Panels(j).width = vWidth
            Panels(j).height = vHeight
            Panels(j).GetView(0).Width = vWidth
            Panels(j).GetView(0).height = vHeight
            Panels(j).GetView(0).Invalidate
            If Panels(j).GetView(0).tag = "Pnl_Cockpit" Then
                Panels(j).GetView(0).top = 0
                CallSub2(Main, "UpdatePanelCockpit", True)
                CallSub2(Main, "UpdatePanelTripTimer", True)
            End If
        Next
        'Display.Invalidate
        'Panels(CurrentPanel).GetView(0).Invalidate
    Else
        vWidth = GetDeviceLayoutValues.Width
        vHeight = GetDeviceLayoutValues.Height
 
        iLeft = Display.Left
        iTop = Display.top
        iWidth = Display.Width
        iHeight = Display.Height
 
        Display.Left = 0
        Display.top = 0
        Display.Width = vWidth
        Display.Height = vHeight
        Display.BringToFront
 
        For j = 0 To Panels.Length - 1
            Panels(j).width = vWidth
            Panels(j).height = vHeight
           
            Panels(j).GetView(0).Width = vWidth
            Panels(j).GetView(0).height = vHeight
            Panels(j).GetView(0).Invalidate
            If Panels(j).GetView(0).tag = "Pnl_Cockpit" Then
                iWidthTemp = vHeight * iWidth / iHeight
                iWidthDelta = vWidth - iWidthTemp
               
                Panels(j).GetView(0).Height = Panels(j).GetView(0).Height + iWidthDelta
                Panels(j).GetView(0).top = - iWidthDelta / 2
               
                CallSub2(Main, "UpdatePanelCockpit", True)
                CallSub2(Main, "UpdatePanelTripTimer", True)
            End If
        Next
        'Display.Invalidate
        'Panels(CurrentPanel).GetView(0).Invalidate
    End If
End Sub

And i use a second timer for DoubleClick time

B4X:
Case ACTION_UP
        tsClick1 = DateTime.Now
        If tsClick1 - tsClick2 < cTimeDoubleClick Then
            DoubleClick = True
            LongClick = False
            TimerLC.Enabled = False
            MaximizeRestorePanels
            PanelToCentre(CurrentPanel,Velocity * 10)
           
            If SubExists(vModule,vEventName&"_DoubleClick") Then
                vTouchData.Tag = Panels(Touched).Tag
                CallSub2(vModule,vEventName&"_DoubleClick",vTouchData)
            End If
            Return
        End If
        tsClick2 = tsClick1

Thank you for sharing your source!


Martin :)
 

JMB

Active Member
Licensed User
Longtime User
Hi there,

Probably being stupid, but couldn't get the files to work - when I try to run match demo, it can't find any of your portaxx.jpg files.

JMB
 

Dominex

Active Member
Licensed User
Longtime User
Hi there,

Probably being stupid, but couldn't get the files to work - when I try to run match demo, it can't find any of your portaxx.jpg files.

JMB
Hi,

you must excuse me, it's my fault, in the last update missing the images. :(

Redownload the file.
 

DonManfred

Expert
Licensed User
Longtime User
Hello @Dominex
i just found your library... REALLY NICE. Thanx fo sharing!

I have a little problem with it....

the SD (Dim SD As SlidingPanels) is put on a panel which is part of a layout.
I have created two CustomListViews by code created and i´m using them

B4X:
SD.Initialize("SD",300,PanelMain,Me,False) 'Initialize the Class.
clvalbum.Initialize(Me,"clvAlbum")
clvvideos.Initialize(Me,"clvVideos")
'[..]
SD.ModeFullScreen(3,True) 'Creates the mode of SlidingPanels.
'---Add elements to Panels---
Dim c As Int
For c = 0 To maxPnl-1
SD.panels(c).Color = Colors.RGB(Rnd(0,256),Rnd(0,256),Rnd(0,256))
SD.panels(c).RemoveAllViews
If c = 0 Then
    SD.Panels(c).LoadLayout("panelclv")
    clvalbum = clv1 ' clv1 is in panelclv
    clvalbum.AsView.Color = Colors.RGB(Rnd(0,256),Rnd(0,256),Rnd(0,256))
End If
If c = 1 Then
    SD.Panels(c).LoadLayout("panelclv")
    clvvideos = clv1
    clvvideos.AsView.Color = Colors.RGB(Rnd(0,256),Rnd(0,256),Rnd(0,256))
End If

It works so far. I can see all i wanted to see. All click-events are fired... I also can jump to an other panel (in this case i have 0 and 1) with
B4X:
SD.JumpToPanel(1, 300, 100)

BUT i cannot swipe the thing with my fingers....

I think it´s cause i´m loading a layout onto the panel?

How can i get this to work?

Any useful tips are badly appreciated :)
 

rafaelbr20

Member
Licensed User
Longtime User
Hi Dominex !!
Very nice library !! Very useful !

I´m having a problem because i added 2 imagens on each panel, and when the finger goes on top the image and try to slide it fails , but when the finger goes on top of the panel it goes well !

I tried to send panels to front, back, and images to front and back but didin´t work!

I would like the panels slide right when i click anywhere !!

I identified that when I take the click event of the image it works, i think i has some conflict between Touch_Activity and img_Click.

Do you have any idea to help me ?

Thanks so much !

Rafael
 

Attachments

  • Screenshot_2014-04-12-12-28-57.png
    Screenshot_2014-04-12-12-28-57.png
    154.7 KB · Views: 292
Last edited:

rafaelbr20

Member
Licensed User
Longtime User
He used the version TouchActivity?
Thanks for your reply !

Yes, i Did ! See code bellow !

B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim SD As SlidingPanels
Private imgFundoMar As ImageView
    Private imgFazenda As ImageView
    Private imgQuiz As ImageView
    Private imgPuzzle As ImageView

SD.Initialize("SD",300,Activity,Me,True) 'Initialize the Class.
SD.ModeLittlePanels(2,100%x,65%y,Activity.Height/6*4,0dip,False) 'Creates the mode of SlidingPanels.
SD.panels(0).Color = Colors.ARGB(45,255,255,255)
SD.panels(1).Color = Colors.ARGB(45,255,255,255)

SD.panels(0).AddView(imgFundoMar,20%x,0dip,larguraBotoesInicial,alturaBotoesInicial)
SD.panels(0).AddView(imgFazenda,60%x,0dip,larguraBotoesInicial,alturaBotoesInicial)
SD.panels(1).AddView(imgQuiz, 20%x,0dip,larguraBotoesInicial,alturaBotoesInicial)
SD.panels(1).AddView(imgPuzzle,60%x,0dip,larguraBotoesInicial,alturaBotoesInicial)

SD.Start(0) 'Start the SlidingPanels.
SD.Panels(0).SendToBack
SD.Panels(1).SendToBack

end Sub

Sub Activity_Touch (Action As Int, X As Float, Y As Float)
    'This line should be added if you use the option ActivityTouch.
    SD.Panels_Touch(Action,X,Y)
End Sub

Sub imgFundoMar_Click
    cliqueBotaoPrincipal("frmFundoMar",imgFundoMar)
End Sub

Sub imgPuzzle_Click
    cliqueBotaoPrincipal("frmquebraCabecas",imgPuzzle)
End Sub

Sub imgQuiz_Click
    cliqueBotaoPrincipal("frmQuizzAnimais",imgQuiz)   
End Sub
Sub imgFazenda_Click
    cliqueBotaoPrincipal("frmFazenda",imgFazenda)
End Sub
 
Last edited:

rafaelbr20

Member
Licensed User
Longtime User
The images on the panel have their own click event?
Because if so the event of the images may take precedence.

Exactly !!! They have their own click event !

So there's nothing can i do ? Raising some event or something like that ?

Thanks again for your help !!
 
Top