Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a Customizable Dialog
#1
I decided I needed a little more feedback in my setup. Here is a dialog box I created for my system. It can be used for confirmations or just user notifications and is fully customizable by setting global variables before showing it. So with this I basically have one template that I can reuse throughout my whole setup for notifications, confirmations, and feedback and they will all have a consistent look and feel. Some examples of where I am using it are for playlist add/delete/clear confirmation, movie selection confirmation, etc.

Modes of Operation
  • Timer - By setting a timer value, the dialog will dismiss itself automatically. The new version uses the SetTimeout command. So you can now have a dialog that timesout as well as responds to command buttons. A timeout will return Timeout in the global variable GVarBig Grinlg_Result. Also, when the timer is set an animated throbber cursor will appear in the upper right corner.
  • Button - In this mode you can display 1 or 2 buttons with customizable text/values. When one is clicked the value will be returned in a Global Variable.
  • Template Click - You can also allow the dialog to be dismissed by clicking on the template itself. This can be enabled along with the 2 buttons above and a value will be returned.
  • Default Behavior - If you do not set a display time or any buttons, the dialog will automatically display a default Ok button.
Global Variables Used
The following global variables are used to control the dialog's behavior. These are automatically deleted by the dialog after they are used, so you will need to set these everytime you invoke the dialog. The only one that isn't deleted is Dlg_Result.
  • GVarBig Grinlg_Message - This will be the text message displayed in the dialog.
  • GVarBig Grinlg_Title - This will set the dialog's title
  • GVarBig Grinlg_Image - This is a path to an icon to be displayed by the dialog (32x32).
  • GVarBig Grinlg_Button1Val - This the the text for button 1, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 1 is clicked to close the dialog.
  • GVarBig Grinlg_Button2Val - This the the text for button 2, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 2 is clicked to close the dialog.
  • GVarBig Grinlg_ButtonMainVal - If set the overlay button will be displayed (unless DisplayTime is set). This will also be the result returned if the user clicks anywhere in the dialog to close it.
  • GVarBig Grinlg_DisplayTime - This is the time to display the dialog in milliseconds before it auto-dismisses. If set, an animation will be displayed.
  • GVarBig Grinlg_Result - This is the result returned by the dialog. If a button is clicked it will be the button's value, otherwise it will be blank (for Timed Mode).
Example Images

Ok/Cancel Dialog
[Image: Dialog_Box.png]

Yes/No Dialog
[Image: Dialog_YesNo.png]

Timed/Notification Dialog
[Image: Timed_Dialog.png]

Code:
[B]With Buttons[/B]
[B]--------------------------------------------------------------------------------[/B]
  This code will display a dialog with the message "Are you sure you want to clear the
  playlist?" and an OK and Cancel button.  If the user clicks OK the playlist is cleared if
  the user clicks Cancel, the dialog is dismissed and no action is taken.
[B]--------------------------------------------------------------------------------[/B]
GlobalVars::SetVariable(GVar:Dlg_Title, Confirm Clear)
GlobalVars::SetVariable(GVar:Dlg_Button1Val, OK)
GlobalVars::SetVariable(GVar:Dlg_Button2Val, Cancel)
GlobalVars::SetVariable(GVar:Dlg_Message, Are you sure you want to clear the playlist?)
GlobalVars::SetVariable(GVar:Dlg_Image, /User/Hardware/Small Icons/Speaker Music)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)
If GlobalVars::Exists(GVar:Dlg_Result)
  If System::Equals(%(GVar:Dlg_Result), OK)
     Devices::FieldWrite(AudioPlayer.ClearPlaylist, True)
  End
End


[B]Timed / Auto Close[/B]
[B]--------------------------------------------------------------------------------[/B]
  This code will display a notification dialog with the message "You have a new email
  message!" for 2.5 seconds and then the dialog will dismiss itself.
[B]--------------------------------------------------------------------------------[/B]
GlobalVars::SetVariable(GVar:Dlg_Title, Email Notification)
GlobalVars::SetVariable(GVar:Dlg_Message, You have a new email message!)
GlobalVars::SetVariable(GVar:Dlg_Image, \User\Hardware\Small Icons\Document)
GlobalVars::SetVariable(GVar:Dlg_DisplayTime, 2500)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)

Templates
Here are the templates for the dialog and a template to test the features. These require 2.4.32+.


Attached Files
.zip   BlueGlass-Pop_Dialog.zip (Size: 48.67 KB / Downloads: 16)
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#2
thinking... would this work as a set of instructions... ie message says "what zone" and you push Family... then message says "what source" ..etc or am I losing the concept?
tia, Ron

My Go Big or Go Home Retirement HT...
Yamaha CX-A5100, (3) JBL 2360As/EV DHA-1s, (3) 1/4 Pie bass bins, (2) MiniDSP DDRC-88M, (4) JBL 8340As, (4) JBL 8320s), PS3, (2) Intel NUCs, Monoprice Redmere HDMI cables, Monster HTPS7000, )2) Furman rack conditioners, (2) Danley DTS-10 subs, Panasonic AE8000, Panamorph UH-480 anamorphic lens, SeymourAV 180 (195" diagonal) scope screen, Yamaha P7000s (for the subs), 2 Crest Audio CM2008 8 channel amps, and (3) Parasound Zamps.
Reply
#3
Sure, but you'll probably need to expand it with more buttons. Right now it only supports 2.
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#4
Thanks, I'll have to play some to see what else I don't get.
Les
Reply
#5
This was a big help even though it was far more complex than I needed. I got what I needed done.

Instead of an animation has anyone done a straight 5 or 10 second countdown timer? I'd like to do it with the same font as the rest of the pop up. I suppose I could just make the requisite images and do it like you did this animation.
Thanks,
Les
Reply
#6
I tried to come up with a way to do a countdown timer so the user would have good feedback on how long the dialog is going to hang around, but I haven't found a way yet. At first I thought I could just call SetTimeout and then change the count in the OnTimeout, but the minimum SetTimeout value is 5 seconds so the counter would count down in 5's.

Today I tried to use the Timer Driver, but there is no formatted output for the countdown timers. So you can't get seconds out, you get ticks instead. There is a format for count up, so you could do a count up timer. We need a formatted field for the countdowns as well.

Short of writing my own timer driver I don't think there is a way to do it.
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#7
A countdown timer and a time field widget will do it for you. The countdown isn't real smooth, but it works.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#8
The Field Time Text widget shows the year (1970). There's no way to format it down to just show seconds....
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#9
For the Field Time Text widget select the Time Fmt tab. For the Format String type in %(s,2,0) for straight seconds or %(u,2,0):%(s,2,0) for an mmConfuseds format. Works like a charm.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#10
How do you set the time? Say to countdown from 10s?
Les
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  create a grid of temp values from DataLogDB IVB 6 2,199 12-13-2015, 09:37 PM
Last Post: IVB
  How to create simple one way drivers Dean Roddey 2 3,043 05-03-2015, 12:14 PM
Last Post: Dean Roddey
  Create Custom DropDown Widget jrlewis 2 10,127 08-05-2011, 08:26 AM
Last Post: jrlewis
  How to create a "Run Time" counter and display beelzerob 13 9,150 01-12-2009, 08:06 AM
Last Post: beelzerob

Forum Jump:


Users browsing this thread: 1 Guest(s)