B4A Library [Class] Floating Windows

Ondra

Member
Licensed User
Longtime User
APP from GP is useless for me, because I need code. My program is very similar to this class. I need add only that function. Because in this program panels covers each other, I need all of them visible all the time. But still maintain move and resize functions
 

Informatix

Expert
Licensed User
Longtime User
Since panels are rectangles, it's very simple to detect collisions: check whether the coordinates of the first panel are between the coordinates of the other panel. For example, if X1 or X1+Width1 is between X2 and X2+Width, and Y1 or Y1+Height is between Y2 and Y2+Height, then you know that the first panel si colliding the second panel.
 

TheMightySwe

Active Member
Licensed User
Longtime User

Thraka

Member
Licensed User
Longtime User
Does anyone have layout issues with this class? It seems AutoScaleAll in the layout script on some of my views and depending on the device, will push items off the size of the window. I'm not sure what to do.

I'm using anchors to do the layout. The layout script only has AutoScaleAll in it. If I do a non-anchored layout and use the layout script completely, things look fine.
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
The floating windows are made of several panels and these panels are resized in a classic manner: by changing their height or width, so I can't see an obvious reason why these panels should not work properly. But I admit I don't use AutoScaleAll and anchors so I didn't check any compatibility. Anyway, you have the source code of the class, so try some changes and let me know if you find a fix.
 

Thraka

Member
Licensed User
Longtime User
I did strip out a lot of stuff from the class to simplify, removed the docking stuff for example. It's very basic now. Just size the dialog, set the content pop it up. So I'm not sure why it happens either. It's really hard to make popups look similar on different form factors. The bane of android I guess.
 

Informatix

Expert
Licensed User
Longtime User
A lot of people complains about the difficulty with Android to have the same layout on all devices, properly sized. Personaly, I never had any problem because I always created layouts for the smallest screen that should display them and, by using either the dip or % unit depending on what I want to achieve, I got exactly the same layout on all devices, whatever maybe the screen ratio, the resolution or the density. I never used anchors or other "automatic" functions. I don't mean it's always simple, but I do not really understand why that seems so difficult for many developers. A thing is sure: if you want to have a lot of troubles to create a layout for different devices, add AutoScaleAll to your script. This function is evil !
 

winjiadh

Active Member
Licensed User
Longtime User
I have a question,
how can you just let it copy itself? like this code
B4X:
Sub Globals
    Dim Win As ClsFloatingWindow
End Sub
Sub Entering_DockA(Window As ClsFloatingWindow, DockRect As Rect)
       ColorWindow(DockRect)
    Win.AddView(Win,200dip, 100%y - 90dip,90dip,90dip, True )
End Sub
In Demo sample, I drag the win to panel,how to copy a new win ?
thabk you
 

Informatix

Expert
Licensed User
Longtime User
I'm not sure to understand the question. If you want to copy an existing window, then create a new one and copy the settings.
 

winjiadh

Active Member
Licensed User
Longtime User
Right
I want to copy an existing FloatingWindow, How to create a new one and copy the settings?
use the avitvity?
I want move the FloatingWindow into the DockA,and the same time rebuild a new FloatingWindow,same as the moveing FloatingWindow
I use the code like this
B4X:
Sub Globals
    Dim Win As ClsFloatingWindow
    Dim pnl(6) As Panel
    Dim lbl As Label
End Sub
and in the sub Entering_DockA, I add the code
B4X:
Sub Entering_DockA(Window As ClsFloatingWindow, DockRect As Rect)
    ColorWindow(DockRect)
Activity.AddView(Win,200dip, 100%y - 90dip,90dip,90dip, True )
End Sub
but
Parsing code. 0.11
Compiling code. Error
Error compiling program.
Error description: Too many parameters.
Occurred on line: 141
Activity.AddView(Win,200dip, 100%y - 90dip,90dip,90dip, True )
Word: _c
need you help,thanks
 

Informatix

Expert
Licensed User
Longtime User
I'm sorry but I can only repeat what I said: create a new window with the same settings. There's no Copy or Clone function.
 

winjiadh

Active Member
Licensed User
Longtime User
yes,my english is poor
can you tell me how did I can do
"create a new window with the same settings"
thanks
 

winjiadh

Active Member
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
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…