www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Blog Post #0099: A Special Request

reply Ron Tarrant <rontarrant gmail.com> writes:
Today's post was requested by Joel Christensen, how to have one 
button affect another. You can find it here: 
https://gtkdcoding.com/2020/01/21/0099-sfx-button-interactions-i-text-labels.html
Jan 21 2020
next sibling parent reply Jan =?UTF-8?B?SMO2bmln?= <hrominium gmail.com> writes:
On Tuesday, 21 January 2020 at 14:02:59 UTC, Ron Tarrant wrote:
 Today's post was requested by Joel Christensen, how to have one 
 button affect another. You can find it here: 
 https://gtkdcoding.com/2020/01/21/0099-sfx-button-interactions-i-text-labels.html
Hi Ron. Your blog is great. I have saved it for the future. (I know it from reddit). I would also like to request a future blog post about animation. I know you have done that in the past, but i am thinking of some animation triggered by user input (say a button, or some text field, which provides parameters for a circle).
Jan 21 2020
next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:
 Hi Ron. Your blog is great. I have saved it for the future. (I 
 know it from reddit).
Glad you like it.
 I would also like to request a future blog post about animation.
 I know you have done that in the past, but i am thinking of 
 some animation triggered by user input (say a button, or some 
 text field, which provides parameters for a circle).
Okay. I'll see what I can come up with. Lead time is 2-3 months, just so you're aware.
Jan 21 2020
prev sibling parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:

 I would also like to request a future blog post about animation.
 I know you have done that in the past, but i am thinking of 
 some animation triggered by user input (say a button, or some 
 text field, which provides parameters for a circle).
Just to make sure I know exactly what you want... - the user inputs parameters for a circle - I'm assuming size, position, perhaps the fraction of the circle (half, quarter, two-thirds, whatever) - the user then clicks a button and that draws the circle. Is that more or less what you're after?
Jan 21 2020
next sibling parent reply Antonio Corbi <acrb ggmail.com> writes:
On Tuesday, 21 January 2020 at 22:06:30 UTC, Ron Tarrant wrote:
 On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:

 I would also like to request a future blog post about 
 animation.
 I know you have done that in the past, but i am thinking of 
 some animation triggered by user input (say a button, or some 
 text field, which provides parameters for a circle).
Just to make sure I know exactly what you want... - the user inputs parameters for a circle - I'm assuming size, position, perhaps the fraction of the circle (half, quarter, two-thirds, whatever) - the user then clicks a button and that draws the circle. Is that more or less what you're after?
Hi Ron! Do you still have the Maurer Rose example? Do you think it could fit this kind of example? Antonio
Jan 21 2020
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Tuesday, 21 January 2020 at 22:12:10 UTC, Antonio Corbi wrote:
 On Tuesday, 21 January 2020 at 22:06:30 UTC, Ron Tarrant wrote:
 Do you still have the Maurer Rose example?
I had to look this up. I'd never heard of it before. That being said...
 Do you think it could fit this kind of example?
When I say "demo" I'm talking about examples of how to do various GTK GUI stuff rather than mathematical exercises. Trying to do this mathematical/drawing exercise, I'd be waaaaaaay out of my element. The few simple math/draw examples I did in Cairo (posts However, I can point you at this repository of Java examples: https://github.com/iabin/Maurer-Rose/tree/master/src Using the methods outlined in the posts I've listed, you should be able to port it over from Java to D. I'm not a mathematician, so I wouldn't be of much help. I wish you the best of luck on this endeavour.
Jan 22 2020
parent reply Antonio Corbi <antonio ggmail.ca> writes:
On Wednesday, 22 January 2020 at 21:22:57 UTC, Ron Tarrant wrote:
 On Tuesday, 21 January 2020 at 22:12:10 UTC, Antonio Corbi 
 wrote:
 On Tuesday, 21 January 2020 at 22:06:30 UTC, Ron Tarrant wrote:
 Do you still have the Maurer Rose example?
I had to look this up. I'd never heard of it before. That being said...
 Do you think it could fit this kind of example?
When I say "demo" I'm talking about examples of how to do various GTK GUI stuff rather than mathematical exercises. Trying to do this mathematical/drawing exercise, I'd be waaaaaaay out of my element. The few simple math/draw examples as math goes. However, I can point you at this repository of Java examples: https://github.com/iabin/Maurer-Rose/tree/master/src Using the methods outlined in the posts I've listed, you should be able to port it over from Java to D. I'm not a mathematician, so I wouldn't be of much help. I wish you the best of luck on this endeavour.
I was referring to this example I made some time ago: https://gitlab.com/amcorbi/dmaurerrose I think this is somewhat related to what te OP was asking for. Assuming you are on GNU/Linux, a simple 'dub run' is all you have to do to make it compile and run. Antonio
Jan 23 2020
next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 23 January 2020 at 08:33:39 UTC, Antonio Corbi wrote:

 https://gitlab.com/amcorbi/dmaurerrose

 I think this is somewhat related to what te OP was asking for.
I'm confused. I was the OP, so I'm not sure who you're referring to.
 Assuming you are on GNU/Linux, a simple 'dub run' is all you 
 have to do to make it compile and run.
On Windows, `dub run` yielded the following output: Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64. gtk-d:gtkd 3.9.0: target for configuration "library" is up to date. gtk-d:gstreamer 3.9.0: target for configuration "library" is up to date. gtk-d:peas 3.9.0: target for configuration "library" is up to date. gtk-d:sv 3.9.0: target for configuration "library" is up to date. gtk-d:vte 3.9.0: target for configuration "library" is up to date. maurerrose-d ~master: building configuration "application"... Running pre-build commands... source/constants.d.in was unexpected at this time. Command failed with exit code 1: if [ source/constants.d.in -nt source/constants.d ]; then sed -e 's#topdir#D source/constants.d; fi
Jan 23 2020
prev sibling parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 23 January 2020 at 08:33:39 UTC, Antonio Corbi wrote:

 https://gitlab.com/amcorbi/dmaurerrose

 I think this is somewhat related to what te OP was asking for.
I'm confused. I was the OP, so I'm not sure who you're referring to.
 Assuming you are on GNU/Linux, a simple 'dub run' is all you 
 have to do to make it compile and run.
On Windows, `dub run` yielded the following output: Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64. gtk-d:gtkd 3.9.0: target for configuration "library" is up to date. gtk-d:gstreamer 3.9.0: target for configuration "library" is up to date. gtk-d:peas 3.9.0: target for configuration "library" is up to date. gtk-d:sv 3.9.0: target for configuration "library" is up to date. gtk-d:vte 3.9.0: target for configuration "library" is up to date. maurerrose-d ~master: building configuration "application"... Running pre-build commands... source/constants.d.in was unexpected at this time. Command failed with exit code 1: if [ source/constants.d.in -nt source/constants.d ]; then sed -e 's#topdir#D source/constants.d; fi
Jan 23 2020
parent reply Antonio Corbi <antonio ggmail.ca> writes:
On Thursday, 23 January 2020 at 12:29:11 UTC, Ron Tarrant wrote:
 On Thursday, 23 January 2020 at 08:33:39 UTC, Antonio Corbi 
 wrote:

 https://gitlab.com/amcorbi/dmaurerrose

 I think this is somewhat related to what te OP was asking for.
I'm confused. I was the OP, so I'm not sure who you're referring to.
Ooops, sorry, my bad!
 Assuming you are on GNU/Linux, a simple 'dub run' is all you 
 have to do to make it compile and run.
On Windows, `dub run` yielded the following output: Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64. gtk-d:gtkd 3.9.0: target for configuration "library" is up to date. gtk-d:gstreamer 3.9.0: target for configuration "library" is up to date. gtk-d:peas 3.9.0: target for configuration "library" is up to date. gtk-d:sv 3.9.0: target for configuration "library" is up to date. gtk-d:vte 3.9.0: target for configuration "library" is up to date. maurerrose-d ~master: building configuration "application"... Running pre-build commands... source/constants.d.in was unexpected at this time. Command failed with exit code 1: if [ source/constants.d.in -nt source/constants.d ]; then sed -e 's#topdir#D source/constants.d; fi
Yes, it uses 'sed' to get 'constants.d' from 'constants.d.in' at configuration time. So you can write your own 'constants.d' with the appropiate values for UIDIR and DATADIR and delete/comment the the preBuildCommands in dub.sdl. Hope this helps. Antonio
Jan 23 2020
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 23 January 2020 at 12:43:24 UTC, Antonio Corbi wrote:

 Yes, it uses 'sed' to get 'constants.d' from 'constants.d.in' 
 at configuration time.
 So you can write your own 'constants.d' with the appropiate 
 values for UIDIR and DATADIR and delete/comment the the 
 preBuildCommands in dub.sdl.
This is beginning to sound like it's beyond the scope of the blog.
Jan 23 2020
parent Russel Winder <russel winder.org.uk> writes:
On Thu, 2020-01-23 at 15:12 +0000, Ron Tarrant via Digitalmars-d-learn
wrote:
 On Thursday, 23 January 2020 at 12:43:24 UTC, Antonio Corbi wrote:
=20
 Yes, it uses 'sed' to get 'constants.d' from 'constants.d.in'=20
 at configuration time.
 So you can write your own 'constants.d' with the appropiate=20
 values for UIDIR and DATADIR and delete/comment the the=20
 preBuildCommands in dub.sdl.
=20 This is beginning to sound like it's beyond the scope of the blog.
Someone does a side tutorial referenced from your blog? With reverse links obviously. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
Jan 23 2020
prev sibling parent reply Jan =?UTF-8?B?SMO2bmln?= <hrominium gmail.com> writes:
On Tuesday, 21 January 2020 at 22:06:30 UTC, Ron Tarrant wrote:
 On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:

 I would also like to request a future blog post about 
 animation.
 I know you have done that in the past, but i am thinking of 
 some animation triggered by user input (say a button, or some 
 text field, which provides parameters for a circle).
Just to make sure I know exactly what you want... - the user inputs parameters for a circle - I'm assuming size, position, perhaps the fraction of the circle (half, quarter, two-thirds, whatever) - the user then clicks a button and that draws the circle. Is that more or less what you're after?
Yes something in that manner. I am not familiar with GTK, i have done a few things in QT. I am mainly interested in the information passing. When i make some change to the input || hit enter || hit the button, the scene will change accordingly. For a more satisfying example, you could have a ball on one line. Below that you have a horizontal slider. Whenever you move the slider, the ball on the line will move accordingly.
Jan 22 2020
parent Ron Tarrant <rontarrant gmail.com> writes:
On Wednesday, 22 January 2020 at 15:29:44 UTC, Jan Hönig wrote:

 Yes something in that manner.
 I am not familiar with GTK, i have done a few things in QT.
 I am mainly interested in the information passing.
 When i make some change to the input || hit enter || hit the 
 button, the scene will change accordingly.

 For a more satisfying example, you could have a ball on one 
 line. Below that you have a horizontal slider. Whenever you 
 move the slider, the ball on the line will move accordingly.
Would you be able to do a quick sketch/rough drawing of this? Perhaps before and after drawings? I wanna make sure I understand exactly what you're looking for. I don't know if this forum will allow images, so perhaps we could switch over to email (gtkdcoding gmail.com) so you can attach them.
Jan 22 2020
prev sibling parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Tuesday, 21 January 2020 at 14:02:59 UTC, Ron Tarrant wrote:
 Today's post was requested by Joel Christensen, how to have one 
 button affect another. You can find it here: 
 https://gtkdcoding.com/2020/01/21/0099-sfx-button-interactions-i-text-labels.html
Another useful tutorial would be something using bindProperty and/or bindPropertyWithClosures. Once I used bindProperty with vala, but I think there is no any example to do it with gtkd.
Jan 22 2020
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Wednesday, 22 January 2020 at 09:18:51 UTC, Ferhat Kurtulmuş 
wrote:

 Another useful tutorial would be something using bindProperty 
 and/or bindPropertyWithClosures. Once I used bindProperty with 
 vala, but I think there is no any example to do it with gtkd.
I found a bindProperty() function in gobject/ObjectG.d. Is this what you're referring to?
Jan 22 2020
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Wednesday, 22 January 2020 at 21:26:40 UTC, Ron Tarrant wrote:
 On Wednesday, 22 January 2020 at 09:18:51 UTC, Ferhat Kurtulmuş 
 wrote:

 Another useful tutorial would be something using bindProperty 
 and/or bindPropertyWithClosures. Once I used bindProperty with 
 vala, but I think there is no any example to do it with gtkd.
I found a bindProperty() function in gobject/ObjectG.d. Is this what you're referring to?
Yes that one. Let me define a use case. We have a button spawning a thread doing some time consuming job (we can use Thread.sleep(5.seconds)). I want this button disabled so that user cannot spawn another thread while the first one is on duty. In the same time, we show a spinner while job is running. After completion, we want to set button enabled and to make the spinner invisible. Instead of setting properties of button and spinner separately, we can bind disabled property of the button and visible property of the spinner each other. In vala, we can use something like (pseudo code): "this" may refer to a self pointer to an instance of derived spinner class: this.bind_property("customWorkingProperty", somebutton, "sensitive", BindingFlags.INVERT_BOOLEAN); bool customWorkingProperty() will be responsible for showing and hiding the spinner.
Jan 23 2020
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 23 January 2020 at 09:27:45 UTC, Ferhat Kurtulmuş 
wrote:

 I want this button disabled so that user cannot spawn another 
 thread while the first one is on duty.
This is actually the subject of an up-coming post which is scheduled to go live on Feb. 25, 2020. It uses setSensitive() rather than bindProperty(), but it has the same effect.
Jan 23 2020
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Thursday, 23 January 2020 at 12:32:57 UTC, Ron Tarrant wrote:
 On Thursday, 23 January 2020 at 09:27:45 UTC, Ferhat Kurtulmuş 
 wrote:

 I want this button disabled so that user cannot spawn another 
 thread while the first one is on duty.
This is actually the subject of an up-coming post which is scheduled to go live on Feb. 25, 2020. It uses setSensitive() rather than bindProperty(), but it has the same effect.
Yes, but what if you set sensitive properties of a bunch of the widgets in the same time. Each time you have to write and call setSensitive() for each widgets. If you bind their sensitivity property to one single widget, you can only switch one widget's property, and others will set automatically. void doWhenDownloadIsComplete1(){// a lot of code pollution but1.setSensitive(false); but2.setSensitive(false); . . entry2.setSensitive(false); } ... void doWhenDownloadIsComplete2(){ // nicer but1.setSensitive(false); // other widgets' sensitive properties are binded to of but1. No extra code needed. }
Jan 23 2020
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Thursday, 23 January 2020 at 13:41:34 UTC, Ferhat Kurtulmuş 
wrote:
 On Thursday, 23 January 2020 at 12:32:57 UTC, Ron Tarrant wrote:
 [...]
Yes, but what if you set sensitive properties of a bunch of the widgets in the same time. Each time you have to write and call setSensitive() for each widgets. If you bind their sensitivity property to one single widget, you can only switch one widget's property, and others will set automatically. void doWhenDownloadIsComplete1(){// a lot of code pollution but1.setSensitive(false); but2.setSensitive(false); . . entry2.setSensitive(false); } ... void doWhenDownloadIsComplete2(){ // nicer but1.setSensitive(false); // other widgets' sensitive properties are binded to of but1. No extra code needed. }
Actually I have just tried this with gtkd and working: button1.bindProperty("sensitive", entry1, "sensitive", GBindingFlags.DEFAULT);
Jan 23 2020
parent Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 23 January 2020 at 14:10:37 UTC, Ferhat Kurtulmuş 
wrote:

 Actually I have just tried this with gtkd and working:

 button1.bindProperty("sensitive", entry1, "sensitive", 
 GBindingFlags.DEFAULT);
That's pretty cool, Ferhat. I'll add this to the todo list.
Jan 23 2020