[Done] DPI awareness : very big problem

Just starting out? Need help? Post your questions and find answers here.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

[Done] DPI awareness : very big problem

Post by Olli »

Hello !

As the title says it, the problem is around the DPI.

By introducing, I thank to bitBlazer, Thorsten1867 and C87 who answered by several technic ways. This header will be modificated to show the useful links which have been given in this subject.


(Thanks to bitBlazer who answered first below
DPI Search on this site)




(Initial message)

First, I apologize to all the pbTeam : "DPI" is a too short term to research rightly on the forum. It is already a problem which breaks the dynamic of the help. Very important for the future : be careful to the short terms which describe a breakthrough or new feature in the language.

Second, the essential : all the help around the gadgets is K.O.

So, after the collective help in the forum which is K.O. (I do not talk about the people, but the technical research a new user cannot absolutely use ("DPI", too short term, being absolutely away in the forum search system) ), it is the documentation which is K.O..

This doc is the result of a very long time of work to be quick and immediate, and made the commercial power of pureBasic : have everything ready immediately after a F1, a source code example copied from the doc to the IDE in less than 3 seconds, this example is executed, tested and discovered by the beginner.

Now, cause of this DPI, all this dynamic has been terminated K.O. .

Knock out ! Just test the canvasGadget with container : the result is bad.

Test the spinGadget : the number is cut.

Etc... (It is not a judgement)

Solution :

For the help on the forum, as the short terms (3 characters) seems a search limit, a sticky section must be made for all short terms : title = << For "DPI" and all short important terms in coding. >>
Else this problem will persist. It is a commercial problem. All the links about DPI should reachable from such a help message, as an index.

For the doc help, as it is not possible to reinvent the wheel, and redo all the help pages, examples after examples, I think the IDE must be modified and updated quickly to control this DPI feature. So, the doc problem is moved to the IDE system.

For the IDE, first, I see a open source status has been switch ed with contributing coders : my message keeps the same logic, it is not against anybody, one person, two persons or everybody. Absolutely not, I just observe this DPI feature, I have not followed since the release including it, has switched to the K.O. status. So, please, the remark is a suggesting, and just a suggesting, not a judgement :

A "DPI active" or a "DPI {light on/off image}" must be displayed on the top of IDE : when we click on a source file name in the IDE, we must immediately know if the source code will be executed with or without DPI awareness.

And, before the end of this message, before the "finally", on the technical aspect, a constant must be reachable as the other options (source code file name, OS, etc...)
#PB_Editor_Yes_we_DPI
or
#PB_Compiler_Travail_Famille_DPI (oula... ptêt pas quand même)
or
#PB_DPI_Now
or
whatever, everything which is boolean and which tells the coder if yes or no, this thing is on or off.


Now, finally, whoever you are, if you are not happy after having read this message, express yourself, you are free, and I do not think I will answer to the negative remarks. I think I have said everything above. I have just a big internal alarm which switched on, around this DPI feature I find very good, but if Microsoft did not call it "scale" or other term longer than 3 characters, it was certainly again a commercial option to put K.O. everything which grew around it.

Thank you, and certainly sorry (for my tone, my vocabulary and my translating quality).

PS:
DPI : Windows IDE bug : temporary fix
Last edited by Olli on Sat Jun 25, 2022 9:33 pm, edited 4 times in total.
Bitblazer
Enthusiast
Enthusiast
Posts: 732
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: DPI awareness : very big problem

Post by Bitblazer »

Olli wrote: Fri Jun 24, 2022 11:48 pm First, I apologize to all the pbTeam : "DPI" is a too short term to research rightly on the forum. It is already a problem which breaks the dynamic of the help.
The solution to any of these forum limitations is to use the google advanced search and narrow your results by ... site or domain https://www.purebasic.fr/english/.
webpage - discord chat links -> purebasic GPT4All
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: DPI awareness : very big problem

Post by Olli »

I immediately inserted it above ! Thank you for it ! Now I ve no time anymore, but, far from my computer, I imagine a short tool can be made in the tool option of the IDE could do the affair to warn on the fly if the active source code is or is not on DPI aware status... If nobody makes for the three next days, I think I will give a code for a tool to integrate...
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: DPI awareness : very big problem

Post by Thorsten1867 »

Code: Select all

  
  Procedure.i dpiX(Num.i)
    ProcedureReturn DesktopScaledX(Num)
  EndProcedure
  
  Procedure.i dpiY(Num.i)
    ProcedureReturn DesktopScaledY(Num)
  EndProcedure
  
  
  Procedure TextHeight_(Text.s)
	  ProcedureReturn DesktopUnscaledY(TextHeight(Text))
	EndProcedure
	
	Procedure TextWidth_(Text.s)
	  ProcedureReturn DesktopUnscaledX(TextWidth(Text))
	EndProcedure  
	
	Procedure DrawText_(X.i, Y.i, Text.s, FrontColor.i=#PB_Default, BackColor.i=#PB_Default)
	  Define.i PosX
	  
	  If FrontColor = #PB_Default
	    PosX = DrawText(dpiX(X), dpiY(Y), Text)
	    ProcedureReturn DesktopUnscaledX(PosX)
	  ElseIf BackColor = #PB_Default
	    PosX = DrawText(dpiX(X), dpiY(Y), Text, FrontColor)
	    ProcedureReturn DesktopUnscaledX(PosX)
	  Else
	    PosX = DrawText(dpiX(X), dpiY(Y), Text, FrontColor, BackColor)
	    ProcedureReturn DesktopUnscaledX(PosX)
	  EndIf 
	  
	EndProcedure
  
  
  Procedure Box_(X.i, Y.i, Width.i, Height.i, Color.i, Rounded.i=#False)
		If Rounded
			RoundBox(dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height), dpiX(Rounded), dpiY(Rounded), Color)
		Else
			Box(dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height), Color)
		EndIf
	EndProcedure
	
	Procedure LineXY_(x1.i, y1.i, x2.i, y2.i, Color.i=#PB_Default)
	  If Color.i=#PB_Default
	    LineXY(dpiX(x1), dpiY(y1), dpiX(x2), dpiY(y2))
	  Else
	    LineXY(dpiX(x1), dpiY(y1), dpiX(x2), dpiY(y2), Color)
	  EndIf   
	EndProcedure
	
	Procedure Line_(X.i, Y.i, Width.i, Height.i, Color.i=#PB_Default)
	  If Color = #PB_Default
	    Line(dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height))
	  Else  
	    Line(dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height), Color)
	  EndIf   
	EndProcedure  
	
	Procedure DrawImage_(ImageID.i, X.i, Y.i, Width.i=#PB_Default, Height.i=#PB_Default)
	  If Width = #PB_Default And Height = #PB_Default
	    DrawImage(ImageID, dpiX(X), dpiY(Y))
	  Else
	    DrawImage(ImageID, dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height))
	  EndIf  
	EndProcedure  
	
	Procedure DrawAlphaImage_(Image.i, X.i, Y.i, Alpha.i)
  	DrawAlphaImage(Image, dpiX(X), dpiY(Y), Alpha)
  EndProcedure

	Procedure FillArea_(X.i, Y.i, OutlineColor.i, FillColor.i=#PB_Default)
	  FillArea(dpiX(X), dpiY(Y), OutlineColor, FillColor)
	EndProcedure  
	
	Procedure ClipOutput_(X, Y, Width, Height)
    ClipOutput(dpiX(X), dpiY(Y), dpiX(Width), dpiY(Height)) 
  EndProcedure
  
  Procedure UnclipOutput_()
    UnclipOutput() 
  EndProcedure
	
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
punak
User
User
Posts: 63
Joined: Tue Sep 07, 2021 12:08 pm

Re: DPI awareness : very big problem

Post by punak »

@Thorsten1867 : thank you these codes are very helpful, do the functions you wrote cover the entire vector drawing library? or do you have to make it more complete?
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: DPI awareness : very big problem

Post by Thorsten1867 »

Code: Select all

X = DesktopUnscaledX(GetGadgetAttribute(GNum, #PB_Canvas_MouseX))
  	  Y = DesktopUnscaledY(GetGadgetAttribute(GNum, #PB_Canvas_MouseY))
With dpiX() and dpiY() you can create the required replacement functions yourself.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

Re: DPI awareness : very big problem

Post by C87 »

I can confirm Olli's problems on searching. As a relatively new user I have also experienced huge problems searching for help in the forums. There can also be spelling mistakes and inconsistency in terminology which add to the difficulties. One recurring problem is that it is the headings that should contain the pointer, but often it is in the text. Which results in hundreds of hits and is basically unhelpful.

The only way around it I have found was to buy a copy of MemPad (written in PureB) and regularly view the Forums. As what looks like something that could be of interest in the future or at the time. I'll save it under headings that I find useful. Then as I need stuff I'll usually find it now. As an example the following is information on DPI related posts is from my "library". They are in the format :
Start of ->{{ TITLES
Path to posting }} <- end of

{{ Calculating size and position of a window (DPI issue)
https://www.purebasic.fr/english/viewto ... f+a+window }}
{{ Procedure HDPI fix
https://www.purebasic.fr/english/viewto ... e+HDPI+fix }}
{{ How I make DPI-aware apps
https://www.purebasic.fr/english/viewto ... aware+apps }}
{{ PB5.71 IDE No longer DPI Aware [ ongoing Dec10}}{{ said to be fixed April? ]
{{ [Module] DPI Awareness
https://www.purebasic.fr/english/viewto ... +Awareness }}
{{ Problem With ResizeWindow and DPI Aware
https://www.purebasic.fr/english/viewto ... +DPI+Aware }}
Constant for DPI compatible mode? [ /english/viewtopic.php?f=13&t=76293 ]
https://www.purebasic.fr/english/viewto ... le+mode%3F }}
^^{see https://www.purebasic.fr/english/viewto ... 08#p561808 }
{{ DPI aware scaling bug, important 5.73
https://www.purebasic.fr/english/viewto ... =4&t=76405 }}
{{ Too Small Icons IDE with High DPI Screen [PB5.73]
https://www.purebasic.fr/english/viewto ... =4&t=76404 }}
{{ [Solved] DPI aware scaling bug 5.73
https://www.purebasic.fr/english/viewto ... =4&t=76405 }}
{{ Automatic dpi aware
https://www.purebasic.fr/english/viewtopic.php?t=79271 }}

I've often wondered about posting it to help any other new users, as it must be a nightmare for anyone looking at PureBasic coming from a RAD environment. Myself I'm only really interested in database applications and after many incursions and abandonments with PureB am starting to think (again) that maybe it isn't really suitable for that type of work due to the time consuming nature of the beast.

Maybe the above posts will help you Olli?
If it's falling over......just remember the computer is never wrong!
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: DPI awareness : very big problem

Post by Olli »

C87 wrote:Maybe the above posts will help you Olli?
Sure !

And I thank you for all this help, I will study. I thank you Thorsten1867 too, for the several examples.

I will update the head of subject, by inserting your help. I am a little bit tired these days, that creates a "freeze" of the update !
Post Reply