From 682cf3795c336837d805ed4c488a909c08601e55 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Wed, 14 Apr 2010 11:33:13 +0200 Subject: [PATCH] Adapted buttons and scaled fonts and buttons --- Data/Buttons_NL.Table | 2 +- sgc2.praat | 109 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/Data/Buttons_NL.Table b/Data/Buttons_NL.Table index dd9728b..d632a70 100644 --- a/Data/Buttons_NL.Table +++ b/Data/Buttons_NL.Table @@ -6,5 +6,5 @@ Previous Terug T Next Vooruit u Quit Stop S Config Instellingen I -Wordlist Woorden W +Wordlist Lijst W Refresh Ververs r diff --git a/sgc2.praat b/sgc2.praat index 437c951..ec2b118 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -62,7 +62,7 @@ call read_preferences "" # Set inital language call set_language 'language$' # Get the word-list -call load_word_list "'wordlistDir$'" "'preferencesDirectory$'/sgc2/wordlists" 0 +call load_word_list "'preferencesDirectory$'/sgc2/wordlists" "'wordlistDir$'" 0 # Draw inital window call init_window @@ -127,7 +127,7 @@ procedure process_label .label$ # Draw the contour call draw_tone_contour elsif .label$ = "Wordlist" - call load_word_list "'wordlistDir$'" "'preferencesDirectory$'/sgc2/wordlists" 1 + call load_word_list "'preferencesDirectory$'/sgc2/wordlists" "'wordlistDir$'" 1 call write_word_list endif endproc @@ -173,41 +173,100 @@ procedure Draw_button .table$ .label$ .push if .row < 1 exit Button Table '.table$' does not have a row with label '.label$' endif - .buttonBackGround$ = "{0.97,0.97,0.97}" - .buttonShift$ = "Black" - + + # Set drawing parameters + .topBackGroundColorUp$ = "{0.97,0.97,0.97}" + .topLineColorUp$ = "Black" + .topLineWidthUp = 1.5 + .topBackGroundColorDown$ = "{0.92,0.92,0.92}" + .topLineColorDown$ = "Grey" + .topLineWidthDown = 1.5 + .flankBackGroundColorUp$ = "Silver" + .flankLineColorUp$ = "Black" + .flankLineWidthUp = 1.5 + .flankBackGroundColorDown$ = "White" + .flankLineColorDown$ = "Black" + .flankLineWidthDown = 1.5 + .buttonFontSize = defaultFontSize + + # Get button values .leftX = Get value... '.row' LeftX .rightX = Get value... '.row' RightX .lowY = Get value... '.row' LowY .highY = Get value... '.row' HighY + .buttonText$ = Get value... '.row' Text + .buttonColor$ = Get value... '.row' Color + .buttonDraw$ = Get value... '.row' Draw + .buttonKey$ = Get value... '.row' Key + + # Adapt size of button to length of text + demo Font size... '.buttonFontSize' + .buttonTextWidth = demo Text width (wc)... '.buttonText$' + .count = 0 + while (.rightX - .leftX) < .buttonTextWidth + 2 + if .buttonFontSize > 6 + .buttonFontSize -= 1 + demo Font size... '.buttonFontSize' + else + .diff = (.buttonTextWidth + 2 - (.rightX - .leftX))/2 + .rightX += .diff + .leftX -= .diff + goto BUTTONADAPTED + endif + .buttonTextWidth = demo Text width (wc)... '.buttonText$' + .count += 1 + if .count > 30 + goto BUTTONADAPTED + endif + endwhile + label BUTTONADAPTED + .rightX = round(.rightX) + .leftX = round(.leftX) + # Reset and erase button area demo Select outer viewport... 0 100 0 100 demo Axes... 0 100 0 100 demo Line width... 'defaultLineWidth' demo Paint rectangle... White .leftX .rightX .lowY .highY - # Give some depth to button: Draw outline + # Give some depth to button: Draw flank outline .shiftX = -0.10 - .shiftY = -0.20 + .shiftY = -0.30 .shiftLeftX = .leftX + .shiftX .shiftRightX = .rightX + .shiftX .shiftLowY = .lowY + .shiftY .shiftHighY = .highY + .shiftY - demo Black + if .push <= 0 + demo Paint rounded rectangle... '.flankBackGroundColorUp$' .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3 + demo Colour... '.flankLineColorUp$' + demo Line width... '.flankLineWidthUp' + else + demo Paint rounded rectangle... '.flankBackGroundColorDown$' .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3 + demo Colour... '.flankLineColorDown$' + demo Line width... '.flankLineWidthDown' + endif demo Draw rounded rectangle... .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3 - .buttonText$ = Get value... '.row' Text - .buttonColor$ = Get value... '.row' Color - .buttonDraw$ = Get value... '.row' Draw - .buttonKey$ = Get value... '.row' Key + # Draw the button top + if .push <= 0 + demo Paint rounded rectangle... '.topBackGroundColorUp$' .leftX .rightX .lowY .highY 3 + demo Colour... '.topLineColorUp$' + demo Line width... '.topLineWidthUp' + else + demo Paint rounded rectangle... '.topBackGroundColorDown$' .leftX .rightX .lowY .highY 3 + demo Colour... '.topLineColorDown$' + demo Line width... '.topLineWidthDown' + endif + demo Draw rounded rectangle... .leftX .rightX .lowY .highY 3 + + # The button text and symbol + .centerX = (.leftX + .rightX)/2 + .centerY = (.lowY + .highY)/2 + .radius = (.highY - .lowY )/4 .newText$ = replace_regex$(.buttonText$, "['.buttonKey$']", "#%&", 1) if .newText$ = "" .newText$ = .buttonText$ endif - if .push > 0 - .buttonBackGround$ = "{0.92,0.92,0.92}" - .buttonShift$ = "{0.98,0.98,0.98}" - endif if .push = 1 demo Grey if .buttonColor$ = "Red" @@ -218,23 +277,19 @@ procedure Draw_button .table$ .label$ .push elsif .push = 2 .buttonColor$ = "Maroon" else - demo Black + demo Colour... Black endif - # Give some depth to button - demo Paint rounded rectangle... '.buttonShift$' .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3 - demo Paint rounded rectangle... '.buttonBackGround$' .leftX .rightX .lowY .highY 3 - - # The real button - demo Draw rounded rectangle... .leftX .rightX .lowY .highY 3 - .centerX = (.leftX + .rightX)/2 - .centerY = (.lowY + .highY)/2 - .radius = (.highY - .lowY )/4 - demo '.buttonColor$' + demo Colour... '.buttonColor$' + demo Font size... '.buttonFontSize' demo Text... '.centerX' Centre '.lowY' Bottom '.newText$' + demo Font size... 'defaultFontSize' .centerY += 1 call '.buttonDraw$' '.buttonColor$' '.centerX' '.centerY' '.radius' + + # Reset demo Black + demo Line width... 'defaultLineWidth' demoShow() endproc -- 2.11.4.GIT