GridGUI v1.1.11 - Simplify Control Placement and Resizing

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
metacognition
Posts: 117
Joined: 22 Oct 2014, 05:57
Location: Alaska
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

02 Sep 2021, 00:31

What does a value other than 1 accomplish for expandwidth and fillwidth?

on line 18 in screenshot below, where you have “2.3” for both params, from the UCR example (from evilc).

072A45D2-6318-4B29-97EC-65776342BE07.jpeg
072A45D2-6318-4B29-97EC-65776342BE07.jpeg (133.71 KiB) Viewed 3284 times
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

02 Sep 2021, 02:11

metacognition wrote:
02 Sep 2021, 00:31
What does a value other than 1 accomplish for expandwidth and fillwidth?

on line 18 in screenshot below, where you have “2.3” for both params, from the UCR example (from evilc).


072A45D2-6318-4B29-97EC-65776342BE07.jpeg
The size of exW and exH change the relative width and height a control gets of the available size in a GUI after all the controls with fixed width and height have taken the parts they need.
fillW and fillH are Boolean values that determines if the control should fill the size of the cells the control occupies, the size of the cells are determined by other controls. I should probably not have used something other than 1 for fillW like I did.
Please excuse my spelling I am dyslexic.
User avatar
metacognition
Posts: 117
Joined: 22 Oct 2014, 05:57
Location: Alaska
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

02 Sep 2021, 21:07

Cool. Well I gotta say this is a blast converting my GUI to GridGUI and refactoring events to functions and methods. It makes everything uniform and look and behave great. But, another question!

I've noticed when I give a button a width somthing is adding padding or margin, and it doesn't seem to be affected by adjust margin parameters. When I remove the width option and use exW and fillW the padding goes away.

Code: Select all


btn_add_reminder			:= gui_email_view_%email_id%.Add(6, 6, "Button", {text: "Add", options: "w" global_button_width})

sc1 2021-09-02_18-08-41.png
sc1 2021-09-02_18-08-41.png (12.12 KiB) Viewed 3251 times
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

03 Sep 2021, 00:02

metacognition wrote:
02 Sep 2021, 21:07
Cool. Well I gotta say this is a blast converting my GUI to GridGUI and refactoring events to functions and methods. It makes everything uniform and look and behave great. But, another question!

I've noticed when I give a button a width somthing is adding padding or margin, and it doesn't seem to be affected by adjust margin parameters. When I remove the width option and use exW and fillW the padding goes away.

Code: Select all


btn_add_reminder			:= gui_email_view_%email_id%.Add(6, 6, "Button", {text: "Add", options: "w" global_button_width})

sc1 2021-09-02_18-08-41.png
I will have a look at it in the evening this sounds like it might be a bug. But one thing that I have noticed some problems with is DPI can you try adding the -DPIScale option to the GUI, and see if it changes anything?

Edit: can you share the source of the specific GUI with me so that I can get a better idea of what is happening?
Please excuse my spelling I am dyslexic.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

03 Sep 2021, 10:12

Long time no see @Capn Odin, nice to see you back :heart:.

Script looks nice, well done :bravo: .

Cheers.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

03 Sep 2021, 10:19

Thank you, I have been hiding in the Discord server.
Please excuse my spelling I am dyslexic.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

03 Sep 2021, 15:32

metacognition wrote:
02 Sep 2021, 21:07
Cool. Well I gotta say this is a blast converting my GUI to GridGUI and refactoring events to functions and methods. It makes everything uniform and look and behave great. But, another question!

I've noticed when I give a button a width somthing is adding padding or margin, and it doesn't seem to be affected by adjust margin parameters. When I remove the width option and use exW and fillW the padding goes away.

Code: Select all


btn_add_reminder			:= gui_email_view_%email_id%.Add(6, 6, "Button", {text: "Add", options: "w" global_button_width})

sc1 2021-09-02_18-08-41.png
Alternatively you can share an image of the original GUI and I can see how well I can recreate it, I will probably run into the same problem you did this way.
Please excuse my spelling I am dyslexic.
User avatar
metacognition
Posts: 117
Joined: 22 Oct 2014, 05:57
Location: Alaska
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

03 Sep 2021, 15:40

Here you go, should be easy to play with commented lines and reproduce, -dpiscale did fix it so you were correct in your suspicion. I still can't figure out where it is happening.

Code: Select all

#Include %A_ScriptDir%\..\GridGui.ahk

global_button_width := "100"

; Capn Odin: adding -dpiscale DOES fix the issue, removing it creates the margin. Try with and without.
gui_email_view_%item_id% 	:= new GridGUI("Title", "+dpiscale", true)

lv_list1_%item_id%  		:= new GridGUI.ListviewControl(gui_email_view_%item_id%.hwnd, "AltSubmit", "list1")
lv_list2_%item_id%  		:= new GridGUI.ListviewControl(gui_email_view_%item_id%.hwnd, "AltSubmit", "list2")
lv_list3_%item_id%  		:= new GridGUI.ListviewControl(gui_email_view_%item_id%.hwnd, "AltSubmit", "list3")

text_subject_%item_id%  	:= gui_email_view_%item_id%.Add(1, 1, "Text", , "subject", 1, , 1, false )
text_sender_%item_id%  		:= gui_email_view_%item_id%.Add(1, 2, "Text", , "sender", 	1, , 1, false )
text_sent_%item_id%  		:= gui_email_view_%item_id%.Add(1, 3, "Text", , "sent",	1, , 1, false )
edit_msgbody_%item_id% 		:= gui_email_view_%item_id%.Add("1-3", 4, "Edit", , "Edit1", 		1, 1, 1, 1)

text_list3_%item_id%  		:= gui_email_view_%item_id%.Add(1, 6, "Text", , "list2", 		1, , 1, false)

; Capn Odin: below, using exW and fillH or not using those and leaving width out corrects the margin issue when dpiscale is active.

btn_add_2				:= gui_email_view_%item_id%.Add(3, 6, "Button", {text: "Add", options: "w" global_button_width})
;btn_add_2				:= gui_email_view_%item_id%.Add(3, 6, "Button", {text: "Add", exW: 1, fillW: 1})

gui_email_view_%item_id%.AddControl("1-3", 7, lv_list3_%item_id% , 1, 1, 1, 1)
text_list1_%item_id%  	:= gui_email_view_%item_id%.Add(4, 1, "Text", , "list1", 	1, , 1, false)

btn_add_1				:= gui_email_view_%item_id%.Add(6, 1, "Button", {text: "Add", options: "w" global_button_width})
;btn_add_1				:= gui_email_view_%item_id%.Add(6, 1, "Button", {text: "Add", exW: 1, fillW: 1})

gui_email_view_%item_id%.AddControl("4-6", "2-4", lv_list1_%item_id% , 1, 1, 1, 1)
text_list2_%item_id%  	:= gui_email_view_%item_id%.Add(4, 6, "Text", , "list2", 	1, , 1, false)

btn_add_3				:= gui_email_view_%item_id%.Add(6, 6, "Button", {text: "Add", options: "w" global_button_width})
;btn_add_3				:= gui_email_view_%item_id%.Add(6, 6, "Button", {text: "Add", exW: 1, fillW: 1})

gui_email_view_%item_id%.AddControl("4-6", 7, lv_list2_%item_id% , 1, 1, 1, 1)

btn_add_1.callback := Func("test_func").Bind(A_Gui, "action")

gui_email_view_%item_id%.Show("w1200 h700 xCenter yCenter")
EDIT:
I think I found the problem, on line 787 of Grid.ahk, inside GetNeededWidth() in the final expression of the ternary sequence, this.cPos.w uses ControlGetPos() for the .w, which returns a DPI adjusted width, which creates the margin, and I think everything else here is dealing in pre-adjusted widths. Not sure how to fix yet... but maybe using this.ctrl.initialwidth, but that screws up other controls without a width that have no fillW.... I'll keep thinking.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

04 Sep 2021, 00:18

@metacognition
I could dpi deajust it, this should not be too hard to fix.

Edit: I have made a fix but I do not have any way to try it out using a non-standard DPI until Monday.

Edit 2: I was informed how to change the DPI scale in the windows settings by @MiM so it has been tested now.
Please excuse my spelling I am dyslexic.
User avatar
metacognition
Posts: 117
Joined: 22 Oct 2014, 05:57
Location: Alaska
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

04 Sep 2021, 11:41

That dpiscale is a real bugger isn't it. So with your fix it now works correctly with dpi scale on, but with dpi scale off "-dpiscale" in the gui... controls creep out of their grid.
2021-09-04_08-39-25.png
2021-09-04_08-39-25.png (16.17 KiB) Viewed 3077 times
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

04 Sep 2021, 11:48

I see. Makes sense, I will have to get the setting from the GUI then.

Edit: @metacognition you can try it again now

Edit 2: you should also know that currently, it will not handle changes to the DPI after the GUI has been created properly.
Please excuse my spelling I am dyslexic.
User avatar
metacognition
Posts: 117
Joined: 22 Oct 2014, 05:57
Location: Alaska
Contact:

Re: GridGUI v1.1.4 - Simplify Control Placement and Resizing

04 Sep 2021, 15:12

@Capn Odin That's it. Beautiful. :bravo:
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.5 - Simplify Control Placement and Resizing

08 Sep 2021, 11:51

Here is a sneak peek at what I am adding next.
Image

Edit: I have added Tabs as well here is a gif showing the example I made.
Image
Please excuse my spelling I am dyslexic.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.8 - Simplify Control Placement and Resizing

17 Sep 2021, 12:37

I guess I forgot to add support for GuiEscape, I never really used it so I am not sure if it is really a useful event to support. If anyone has used it, can you tell me why you used it instead of a conditional hotkey?
Please excuse my spelling I am dyslexic.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: GridGUI v1.1.8 - Simplify Control Placement and Resizing

17 Sep 2021, 14:26

Capn Odin wrote:
17 Sep 2021, 12:37
I guess I forgot to add support for GuiEscape, I never really used it so I am not sure if it is really a useful event to support. If anyone has used it, can you tell me why you used it instead of a conditional hotkey?
GuiEscape seems more native to me than a shortcut. I don't know the background.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

23 Sep 2021, 10:55

pgeugene wrote:
23 Sep 2021, 05:14
Hi,
Thank you for your script.
How can I apply below user input codes
viewtopic.php?f=6&t=93513#:~:text=true)-,user%20input,-When

to this https://github.com/CapnOdin/GridGUI/blob/master/Examples/Example%20Tabs.ahk

Thank you.
You can retrieve the control added to the tab the same way as in the user input example that you linked.

Code: Select all

bt := tab.tabs[1].Add(1, 1, "Button", args)
bt.callback := Func("ToolTip").Bind("You Pressed the Button")
Here is a full example using the tab script:

Code: Select all

#Include <GridGUI>

args := {Options: "w0 h0", exW: 1, exH: 1, fillW: true, fillH: true}

count := 1

myGui := new GridGUI("Tab Example", "resize")
myGui.GuiClose := GridGUI.ExitApp

tab := new GridGUI.TabControl(myGui.hwnd, , "Name 1|Name 2|Name 3|Name 4")
myGui.AddControl(1, 1, tab, args)

bt := tab.tabs[1].Add(1, 1, "Button", args)
bt.callback := Func("ToolTip").Bind("You Pressed the Button " count++)

tab.tabs[2].Add(1, 1, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
tab.tabs[2].Add(2, 2, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)

tab.tabs[3].Add(1, 1, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
tab.tabs[3].Add(2, 2, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
tab.tabs[3].Add(3, 3, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)

subgrid := new GridGUI.SubGrid(myGui.hwnd, GridGUI.Area(0, 0))
subgrid.Margin(0, 0)

tab.tabs[4].Add(1, 1, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
tab.tabs[4].AddControl(2, 2, subgrid, args)
tab.tabs[4].Add(3, 3, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)

loop 10 {
	newsubgrid := new GridGUI.SubGrid(myGui.hwnd, GridGUI.Area(0, 0))
	newsubgrid.Margin(0, 0)
	subgrid.Add(1, 1, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
	subgrid.AddControl(2, 2, newsubgrid, args)
	subgrid.Add(3, 3, "Button", args).callback := Func("ToolTip").Bind("You Pressed the Button " count++)
	subgrid.AutoSize()
	subgrid := newsubgrid
}

subgrid.AutoSize()
myGui.AutoSize()
myGui.Show("w300 h300")
myGui.MinSize()
return

ToolTip(text) {
	ToolTip, % text
}
This adds the click callback to all the buttons and shows the order that they were added to the GUI by updating the counter that was appended to the string that will be shown in the tooltip.
Please excuse my spelling I am dyslexic.
william_ahk
Posts: 481
Joined: 03 Dec 2018, 20:02

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

25 Sep 2021, 06:19

Hi, it would be cool if you could release a bundled single file library for easier distribution.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

26 Sep 2021, 02:22

william_ahk wrote:
25 Sep 2021, 06:19
Hi, it would be cool if you could release a bundled single file library for easier distribution.
I do not want to maintain multiple release versions of the lib, so I opted to make a small script that you can find in /Examples/Utils/ called To Single File.ahk it generates a file that has all the lib files included.
Please excuse my spelling I am dyslexic.
william_ahk
Posts: 481
Joined: 03 Dec 2018, 20:02

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

26 Sep 2021, 05:10

@Capn Odin Thanks! Great idea.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 117 guests