I am trying to align objects to an image and have added an image with css, no problem there. The only issue is that the window size appears to be slightly larger than the preferred size.
I have constrained the window size in project attributes and the height and width of the main form reports what I expect the size to be. If you compare the image in the app window with the image in the designer, the image appears to be slightly bigger in the app window.
Example project attached.
[Edit] example ImageSize1 uses an absolute sized image with on repeat in the css.
Just to clarify it appears that the window in the app is larger than the preferred size, even though the returned values are as they should be.
There is no css file in either zip but it is not necessary to see the problem. It seems that specifying MainForm.Resizable=False causes an increase in size of 10 pixels in both dimensions. Without it the size is correct.
EDIT: The css file is there but in the wrong folder. It and the background should be added to the Files folder and the path in the xml changed to <URL value="@HST.css" />
The incorrect values show up if you do the logging after Showing the Form not before. As far as I can see it is a bug in JavaFX itself. Here is a crude workaround to get a non-resizable window of the required size.
B4X:
#Region Project Attributes
#MainFormWidth: 200
#MainFormHeight: 210
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim MainFormWidth As Int = 200
Dim MainFormHeight As Int = 210
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Resizable=False
MainForm.Show
Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
MainForm.WindowWidth = MainForm.WindowWidth - (MainForm.RootPane.Width - MainFormWidth)
MainForm.WindowHeight = MainForm.WindowHeight - (MainForm.RootPane.Height - MainFormHeight)
Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
End Sub
The incorrect values show up if you do the logging after Showing the Form not before. As far as I can see it is a bug in JavaFX itself. Here is a crude workaround to get a non-resizable window of the required size.
B4X:
#Region Project Attributes
#MainFormWidth: 200
#MainFormHeight: 210
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim MainFormWidth As Int = 200
Dim MainFormHeight As Int = 210
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Resizable=False
MainForm.Show
Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
MainForm.WindowWidth = MainForm.WindowWidth - (MainForm.RootPane.Width - MainFormWidth)
MainForm.WindowHeight = MainForm.WindowHeight - (MainForm.RootPane.Height - MainFormHeight)
Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
End Sub