B4A Library [Class] Floating Windows

Hello,

With this class, you can create floating windows, move them with the finger, dock them, stick them to an edge, maximize them, customize their action bar... You fill them as you fill a panel.

This class needs the Reflection library.

img1.jpg puzzle.png

v1.1:
The class has been splitted in two: ClsFloatingWindow and ClsActionBar.
This version includes a lot of changes.

v1.2:
Fixed bugs
Added a resize button
Added new functions and parameters
Added animations for docking areas and sticky edges
Changed the parameters returned by the custom buttons so as to be consistent with the ready-made buttons
Improved management of overlapping special areas
Improved the formula used to detect a move

v1.21:
Fixed a conflict between StillVisible and the special areas

v1.22:
Fixed two bugs in CheckSpecialAreas (thanks to Awama)

v1.23:
Fixed five bugs (yes, five... :()

v1.24:
Updated the ActionBar class required by this class.

v1.25:
Fixed a bug in the computation of covered areas while docking a window;
Updated the ActionBar class required by this class;
No more warnings with B4A v2.7.

v1.26:
Updated the ActionBar class required by this class.

Fred
 

Attachments

  • FloatingWindows v1.26.zip
    32.6 KB · Views: 1,722
Last edited:

Informatix

Expert
Licensed User
Longtime User
thanks
I know how to create a new window
but I have a other question
in your sample, I run the FloatWinDemo2.b4a
in the code
B4X:
Sub After_Undock(Window As ClsFloatingWindow)
    ' We return to the initial size and title
    Win.Resize(90dip, 90dip)
    Win.SetTitleText("Drag me")
    ' We center the window in the docking area
    Win.Move(Win.getLeft + 10dip, Win.getTop + 10dip, True)
    Win.Close
End Sub
I add the "win.close"
But running
when I move the window from dock the Error on
only use the win.hide
can you tell me how to use the win.close
After_Undock is an event raised when you leave a dock area. At this moment, the finger is on the screen, moving the window. It's normal that you get an error if you try to close the window. You have to wait until the finger is up. You can also modify the class to cancel the touch event. But what do you want to do exactly because I cannot see why you want to close a window while undocking?
 

winjiadh

Active Member
Licensed User
Longtime User
hank you for your reply
I made a sample, including AddWin added a process
Want to do after this win into the dock, the bottom of the screen to create a win
B4X:
Sub AddWin
    Dim Win As ClsFloatingWindow
    Win.Initialize(Activity, 0, 0, 120dip, 90dip, Me)
    Win.SetTitleText("Drag me")
    Win.StillVisible = 90dip
    Win.TouchSlop = 0 'The window will start to move immediately after a finger move
    SetBackimg
    ' Docking areas and sticky edge
    Dim wRect As Rect, Left, Top, p As Int
    wRect.Initialize(Left, Top, Left + 110dip, Top + 110dip)
    Win.AddDockingArea(wRect)
    Win.Move(100dip, 100%y - 90dip, True)
    Win.AddStickyEdge(3, 100%y)
    Win.SetOnStickListener("After_Stick")
    Win.SetOnEnterDockAreaListener("Entering_DockA")
    Win.SetOnDockListener("After_Dock")
    Win.SetOnUndockListener("After_Undock")
End Sub
I'm ready, but the problem is here
This win is the more the more, so I hope when win removed from the dock, closed out the win
Hope to get your help, I how to define when finger is up, closed out the win?
 

Informatix

Expert
Licensed User
Longtime User
hank you for your reply
I made a sample, including AddWin added a process
Could you post this sample ?
Want to do after this win into the dock, the bottom of the screen to create a win
B4X:
Sub AddWin
    Dim Win As ClsFloatingWindow
    Win.Initialize(Activity, 0, 0, 120dip, 90dip, Me)
    Win.SetTitleText("Drag me")
    Win.StillVisible = 90dip
    Win.TouchSlop = 0 'The window will start to move immediately after a finger move
    SetBackimg
    ' Docking areas and sticky edge
    Dim wRect As Rect, Left, Top, p As Int
    wRect.Initialize(Left, Top, Left + 110dip, Top + 110dip)
    Win.AddDockingArea(wRect)
    Win.Move(100dip, 100%y - 90dip, True)
    Win.AddStickyEdge(3, 100%y)
    Win.SetOnStickListener("After_Stick")
    Win.SetOnEnterDockAreaListener("Entering_DockA")
    Win.SetOnDockListener("After_Dock")
    Win.SetOnUndockListener("After_Undock")
End Sub
I'm ready, but the problem is here
This win is the more the more, so I hope when win removed from the dock, closed out the win
Hope to get your help, I how to define when finger is up, closed out the win?
I'm sorry but I don't have a clear understanding of your intent (and the automatic translator that you use does not help). Maybe a practical example could help me to understand.
 

winjiadh

Active Member
Licensed User
Longtime User
thanks
I upload the new files to you ,but the filles on error when I close the win.
I need you help
when win removed from the dock, closed the win
 

Attachments

  • newFloatWinDemo2.zip
    19.6 KB · Views: 276

Informatix

Expert
Licensed User
Longtime User
thanks
I upload the new files to you ,but the filles on error when I close the win.
I need you help
when win removed from the dock, closed the win
You uploaded my own demo! Without further explanations or a demo more explicit (what's your app intended for? why the user should do this?), I cannot help. Closing the window while undocking is extremely simple: Win.Close in After_Undock and Return just after CallSub2(wModule, OnUndockWinSub, Me) in the class (or replace CallSub2... by Close and Return), so I don't think that is what you're really asking.
 

ttsolution

Member
Licensed User
Longtime User
Hi all,

I added some small adjust to the class for modal window.

Jonh,
 

Attachments

  • ClsFloatingWindow.bas
    31.4 KB · Views: 257

Informatix

Expert
Licensed User
Longtime User
Hi all,

I added some small adjust to the class for modal window.

Jonh,
Technically, what you did is a blocking window, not a modal window (you don't stop the code execution while the window is displayed).
As you deactivated the MoveWin function so the window cannot move, what's the reason to use this class? There are better alternatives to display a modal dialog, e.g. my BetterDialogs library. I'm curious to know the reason.
 

ttsolution

Member
Licensed User
Longtime User
Hi all,

Using the BetterDialog Lib. How can we trap the PositiveButton Click Event ? I need to check user input before close the dialog

Many thanks,

Jonh.
 

billmoultrie

Member
Licensed User
Longtime User
I am using Informatix's puzzle version of his demo (the 9 square matrix).
I am trying to slide a tile from its original position to the adjacent tile and get them to swap their position.
This means I have to detect the movement of the tile, which I can with UnDock.
But I can not see how to swap the stickyedge addresses so that when the animation begins they will change places.

Can anyone help.
 
Top