Page 1 of 1
Numeric Displays
Posted: Wed Feb 02, 2022 4:02 pm
by UrbanCyborg
I was wondering how the numeric displays in things like Andrew Macaulay's Dual Frequency Meter are done. Are they extensions of the Counter type, or done from scratch, maybe with the Canvas Type? Anyone know, or any guesses. I don't see any way to get more than integer digits in the Counter type.
Re: Numeric Displays
Posted: Wed Feb 02, 2022 5:40 pm
by seal58
For example, in my p.moon CV-Meter I used regular text labels as digital display.
But it's a little bit tricky to get the characters onto right place.
Re: Numeric Displays
Posted: Thu Feb 03, 2022 3:17 am
by UrbanCyborg
I thought of that, but figured I'd have the very problem you mentioned.
Re: Numeric Displays
Posted: Thu Feb 03, 2022 7:38 am
by seal58
Andrew Macauley seems to use the regular CA Digital Counter. At the moment there are 7 styles for the counter available.
Count of digits is always setable.
Additional characters like "Hz" then can be added by means of a text label with similiar style.
Re: Numeric Displays
Posted: Thu Feb 03, 2022 12:20 pm
by UrbanCyborg
Monki-bobo's Volt Meter seems to be doing a custom draw.
Re: Numeric Displays
Posted: Thu Feb 03, 2022 1:07 pm
by UrbanCyborg
I was looking through the sample code, and found that the timer sample does it with a text label.
Re: Numeric Displays
Posted: Thu Feb 03, 2022 4:23 pm
by honki-bobo
UrbanCyborg wrote: ↑Thu Feb 03, 2022 12:20 pm
Monki-bobo's
Volt Meter seems to be doing a custom draw.
I'm using a text label that I update on every GUI repaint.
And it's honki-bobo
Re: Numeric Displays
Posted: Fri Feb 04, 2022 7:11 am
by UrbanCyborg
Sorry about that, honki-bobo-san. My memory failed me. So, that's just a text label update, eh? I'm guessing you have a nice custom background for it to draw over. I'd started a new module yesterday that does that. Nice work, btw.
Re: Numeric Displays
Posted: Fri Feb 04, 2022 7:45 am
by honki-bobo
UrbanCyborg wrote: ↑Fri Feb 04, 2022 7:11 am
Sorry about that, honki-bobo-san. My memory failed me.
No worries, my friend
UrbanCyborg wrote: ↑Fri Feb 04, 2022 7:11 am
So, that's just a text label update, eh? I'm guessing you have a nice custom background for it to draw over.
Actually I just use the textlabels background color, border color and border width features and write the numbers in bold Courier New 16px in the upper right corner of the label. The generated code looks like this:
Code: Select all
textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "-0.12345678" );
AddComponent( textLabel1 );
textLabel1.SetWantsMouseNotifications( false );
textLabel1.SetPosition( 17, 24 );
textLabel1.SetSize( 120, 25 );
textLabel1.SetEditable( false, false );
textLabel1.SetJustificationFlags( VoltageLabel.Justification.Right );
textLabel1.SetJustificationFlags( VoltageLabel.Justification.Top );
textLabel1.SetColor( new Color( 0, 0, 0, 255 ) );
textLabel1.SetBkColor( new Color( 65, 65, 65, 65 ) );
textLabel1.SetBorderColor( new Color( 0, 0, 0, 255 ) );
textLabel1.SetBorderSize( 1 );
textLabel1.SetMultiLineEdit( false );
textLabel1.SetIsNumberEditor( false );
textLabel1.SetNumberEditorRange( 0, 100 );
textLabel1.SetNumberEditorInterval( 1 );
textLabel1.SetNumberEditorUsesMouseWheel( false );
textLabel1.SetHasCustomTextHoverColor( false );
textLabel1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
textLabel1.SetFont( "Courier New", 16, true, false );
UrbanCyborg wrote: ↑Fri Feb 04, 2022 7:11 am
Nice work, btw.
Thanks!
Re: Numeric Displays
Posted: Fri Feb 04, 2022 8:46 am
by UrbanCyborg
Kewl. I just went and looked at my debug window, where I'm using your Volt Meter as part of my setup. I had to look closely to tell that it wasn't a custom background. Fools the eye. Nicely done.