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,719
Last edited:

JdV

Active Member
Licensed User
Longtime User
Samsung Mini Mode

Hello

Does this library allow apps to be written that are similar to the 'mini mode' apps on Samsung's Galaxy Tab?

Are apps that are written to use this library able to show the user's current screen (home screen or screen within another program) behind the app that uses this library?

Regards

Joe
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hello

Does this library allow apps to be written that are similar to the 'mini mode' apps on Samsung's Galaxy Tab?

Are apps that are written to use this library able to show the user's current screen (home screen or screen within another program) behind the app that uses this library?

Regards

Joe

I don't know what are "mini mode apps" but don't hesitate to send me a Galaxy Tab to let me know. :)
I suppose you're talking about floating apps. It's different from floating windows (it's the same difference between MDI and SDI in the Windows world) and I don't know at all how that can be done. I saw somewhere that a B4A user is trying to wrap the StandOut library. That's probably what you're looking for.
 

JdV

Active Member
Licensed User
Longtime User
I don't know what are "mini mode apps" but don't hesitate to send me a Galaxy Tab to let me know. :)
I suppose you're talking about floating apps. It's different from floating windows (it's the same difference between MDI and SDI in the Windows world) and I don't know at all how that can be done. I saw somewhere that a B4A user is trying to wrap the StandOut library. That's probably what you're looking for.

Thanks for the quick reply.

Yes, that's pretty much what I was talking about!

It doesn't look like a B4A library had been released for StandOut.

I guess as a workaround I could have a transparent activity with no title bar. I would imagine there is a drawback in that users can't really interact with the items behind my 'floating' app.

Regards

Joe
 

Informatix

Expert
Licensed User
Longtime User
New version (v1.1):
The class has been splitted in two: ClsFloatingWindow and ClsActionBar.
This version includes a lot of changes (new events, new functions, better event management, pin button...) and it is not compatible with the previous version.
 

awama

Active Member
Licensed User
Longtime User
Black Screen

Windroid was now born. Great work!

But I have a problem. If I long press on the button "Hide All", "Rearrange", ... then hangs on my phone. I get a black screen. (Galaxy S2 ICS 4.0.3)

How do I get the number of the window that has been moved?

Thank you.
Walter
 

Informatix

Expert
Licensed User
Longtime User
Windroid was now born. Great work!

But I have a problem. If I long press on the button "Hide All", "Rearrange", ... then hangs on my phone. I get a black screen. (Galaxy S2 ICS 4.0.3)

How do I get the number of the window that has been moved?

Thank you.
Walter

I have no problem with the emulator for 4.0.3. So I have no idea of what's happening. What version of B4A and Reflector lib do you have ?
Tell me if removing the following code in the ActionBar class solves the problem (in the AddButton function):
B4X:
   If OnLongClickSub = "" Then
      Dim r As Reflector
      r.Target = pnl
      r.SetOnLongClickListener("")
   End If

When you move a window, that fires an event onMove. You can listen these events by calling SetOnMoveListener("After_Move"). Your listener must be declared this way:
Sub After_Move(Window As ClsFloatingWindow)
The parameter sent back by the event is the window view.

The demo shows how to use that.
 

awama

Active Member
Licensed User
Longtime User
problem solved

Hi,

update to the latest reflection library solved the problem without removing the code

AND

removing the code before has solved the problem with the old reflection library

Thanks for the quick help
Walter
 

awama

Active Member
Licensed User
Longtime User
Touch a point in the screen and the window is moving?

Hi,

I want to touch with a finger any point on the screen, and the window should automatically move to that point. What have I doing?
Thank you for a solution.
Walter
 

Informatix

Expert
Licensed User
Longtime User
Hi,

I want to touch with a finger any point on the screen, and the window should automatically move to that point. What have I doing?
Thank you for a solution.
Walter

There are two problems here:
1) where is your finger ?
2) how to move the window to that place ?

1) When your finger touches a panel or the Activity background, the Touch event returns its position (X is the position from the left, Y from the top).

2) If your finger is on the parent view of the window, that's very easy: call the function Move. If your finger is on another view, you have to transfer the window, which is not feasible without modifying the class. EDIT: with version 1.2, you can do it now easily. With the function AsPanel, you can remove the window from a panel and add it to another.
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
New version (v1.2):

Fixed bugs in getContentHeight and Content_Touch

Added a resize button

Added three functions:
- EnableResizeButton(Enabled As Boolean)
- ChangeResizeIcon(NewIcon As Object)
- AsPanel As Panel

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 (thanks to Pythagoras)

Added five parameters:
- MinimumWidthAfterResize As Int
- MinimumHeightAfterResize As Int
- MaximumWidthAfterResize As Int
- MaximumHeightAfterResize As Int
- MinimumCoveredSurfaceForDocking As Int (percentage is expected)

Updated the demos
 

Informatix

Expert
Licensed User
Longtime User
One of the bugs I fixed was a bit unexpected and took me at least an hour to find it: Sender (the object that raises the event) is resetted to null after a CallSub in the event. Thus, if you do:
B4X:
If SubExists... then CallSub...
If Sender Is EditText then
you will never satisfy the last condition.

PS: Starting tomorrow, I will publish tutorials to show how to use my classes and my libraries to replicate the UI of some applications made by professionals. That will show you some advanced techniques. For copyright reasons, that will be only text and screenshots. ;-)
 

awama

Active Member
Licensed User
Longtime User
Problems with docking on edges with new version 12

hi,

I have generated docking areas at the edges of Windows Parent.(fw11)
Now I have replaced ClsFloatingWindow.bas (v11) by ClsFloatingWindow.bas (v12).
Now, the windows dock not exactly at the edges but only offset. This only affects the WindowsParent edge "docking areas". Inside, they dock properly. In the docking areas list the values ​​are correct. Is there a bug in the new version? Thanks for looking and for your amazing work.
Walter
 

awama

Active Member
Licensed User
Longtime User
incorrect coordinates in Sub After_Dock

Hi,

I've found a problem. I have to check whether the window is in the correct area.
In version 1.1, the query worked for the correct coordinates of the window when docked. With v1.21 the window coordinates are different from the "docking area" coordinates in "Sub After_Dock". Can you check that. Thank you.

'works with clsfw 1.1 but not with 1.21
Sub ColorWindow(Window As ClsFloatingWindow, DockRect As Rect)
' We color the window with the panel color
For i = 1 To 4
If Window.getLeft = DockRect.Left AND Window.getTop = DockRect.Top Then
'ChangeGradient(pnl(i).Tag)
Exit
End If
Next
End Sub

Sub After_Dock(Window As ClsFloatingWindow, DockRect As Rect)

' We color the window with the panel color
ColorWindow(Window, DockRect)

End Sub
 

Informatix

Expert
Licensed User
Longtime User
Version 1.23

New version:

Fixed five bugs (yes five... :BangHead:):
- the undocked flag was not set when the window was moved programmatically;
- if MinimumCoveredSurfaceForDocking was used (>0), the sticky edges didn't have the expected behavior under certain circumstances;
- the sticky areas could appear even though the window was docked;
- StillVisible was not taken into account by the sticky edges;
- GetTag didn't return an object.

Removed a limitation:
- one panel was not enough for the sticky edges.
 

ScriptBasic

Member
Licensed User
Longtime User
I just tried compiling the FloatWinDemo1 example and get the following error. (running B4A 2.02)

B4X:
Compiling code.                         Error
Error parsing program.
Error description: Unknown type: reflector
Are you missing a library reference?
Occurred on line: 535
Dim r As Reflector

FloatWinDemo2 returns a similar error.

Update

I didn't install the Reflection library was the problem. Everything is working fine now.
 
Last edited:
Top