Hi RASHAD and Andre,
thank you for your examples, but it does not really fit my needs. I can not pre-calculate the sizes during runtime, as I include the XML during compile-time (IncludeBinary). I might use some kind of place-holders replacement (like I do for language strings) but I do not like to handle lots of elements like this as it complicates the source very much.
This also does not solve my problem of images and ImageGadgets() not resizing depending on DPI settings. I also would have to resize the image manually and set width and height manually.
By the way, the IsProcessDPIAware() function always returns 1 for me, so the API SetProcessDPIAware() is never called. Don't know why it is activated for me all the time (PB 5.30, 32 Bit). But I do not care as I like to have all my programs to be DPI aware anyway.
Also,
I believe the reason of a layout engine is to prevent such manual calculation! What is the benefit of such engine if I need to calculate sizes and borders manually to support modern UI?
Example:
Code: Select all
CompilerIf #PB_Compiler_Unicode
#XmlEncoding = #PB_UTF8
CompilerElse
#XmlEncoding = #PB_Ascii
CompilerEndIf
#Dialog = 0
#Xml = 0
#Image = 0
XML$ = "<window id='#PB_Any' name='test' text='test' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
" <vbox expand='item:2'>"+
" <image name='imgTest' height='50' flags='' />"+
" <vbox>"+
" <button text='Example UI content' />"+
" <button text='Example UI content' />"+
" </vbox>"+
" </vbox>"+
"</window>"
If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
; create some image with content
CreateImage(#Image, 1024, 50, 24, RGB(255,255,255))
StartDrawing(ImageOutput(#Image))
Line(0,0,ImageWidth(#Image), ImageHeight(#Image), RGB(255,0,0))
StopDrawing()
; update image gadget with image
imgGad = DialogGadget(#Dialog, "imgTest")
SetGadgetState(imgGad, ImageID(#Image))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Error -Dialog- : " + DialogError(#Dialog)
EndIf
Else
Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
As you can see, the buttons fonts and borders etc are scaling, but the image does not scale. If a layout is based on such picture (like a nice header with logo or some special divider image), it looks really weird on displays with 150 or even more DPI (4K Monitors are coming). If I do not set the image height with a fixed value, the image is not displayed (height=0). As I load the image and the XML from binary content during runtime, I do not like to parse the XML to set sizes during runtime. A layout engine is to help me on such and not to force me doing the DPI calculations by myself.
There are two solutions (I guess):
1) The XML Dialog engine also multiplies the width/height/minwidth/minheight/maxwidth/maxheight values with the DPI factor. It also scales the content of images and canvas automatically.
2) The XML Dialog engine is using the current image-size to re-calculate the complete layout after I changed the image content.
Solution 2 would let me scale the image manually (what I would accept). But sadly, the layout does not care about the image sizes after it is once calculated. This also would not fix the issue for several other things using fixed values (width/height/minwidth/minheight/maxwidth/maxheight).
Sadly, both solutions need Fred to enhance the layout engine.
I reported several problems in the past. Most of them regarding the XML layout, but he never changed anything
http://www.purebasic.fr/english/viewtop ... =7&t=57737
http://www.purebasic.fr/english/viewtop ... =7&t=57280
http://www.purebasic.fr/english/viewtop ... =3&t=60506
http://www.purebasic.fr/english/viewtop ... =7&t=60380
http://www.purebasic.fr/english/viewtop ... =7&t=59929
http://www.purebasic.fr/english/viewtop ... 13&t=59261
http://www.purebasic.fr/english/viewtop ... =3&t=57704
I think the XML Dialog is not really usable in the moment as it has too many open issues
Kukulkan