From 5de13418814c810344f44f3800b180d84f6f5bb2 Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Wed, 27 Nov 2024 09:26:01 -0800 Subject: [PATCH 1/3] Improve the Preferences dialog appearance for Cloud --- Source/Chatbook/PreferencesContent.wl | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Source/Chatbook/PreferencesContent.wl b/Source/Chatbook/PreferencesContent.wl index d2793a33..3bf7f197 100644 --- a/Source/Chatbook/PreferencesContent.wl +++ b/Source/Chatbook/PreferencesContent.wl @@ -112,6 +112,25 @@ currentTabPage[ scope_ ] := Replace[ currentTabPage // endDefinition; +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*mousedown*) +(* Cloud doesn't utilize the Dialog.nb stylesheet as expected, so workaround that. *) +mousedown[ args__ ] := NotebookTools`Mousedown[ args ] + +commonOpts = { Alignment -> Center, FrameMargins -> { { 17, 17 }, { 7, 7 } }, FrameStyle -> None, ImageSize -> { { 38, Full }, { 19.5, Full } }, RoundingRadius -> 3 }; + +mousedown[ args__ ] /; $CloudEvaluation := +ReplaceAll[ + NotebookTools`Mousedown[args], + { + HoldPattern[ BaseStyle -> "ButtonRed1Normal" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 13/15, 1/15, 0 ] }, commonOpts ], + HoldPattern[ BaseStyle -> "ButtonRed1Hover" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 254/255, 0, 0 ] }, commonOpts ], + HoldPattern[ BaseStyle -> "ButtonRed1Pressed" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 176/255, 1/17, 0 ] }, commonOpts ] + } +] + + (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Main*) @@ -1168,7 +1187,7 @@ servicesSettingsPanel0[ ] := Enclose[ llmHelp = (* If this tooltip isn't meant to be a button, then use infoTooltip[llmLabel, text] *) Button[ Tooltip[ - NotebookTools`Mousedown[ + mousedown[ Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.537 ], 14 ] ] ], Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.692 ], 14 ] ] ], Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.358 ], 14 ] ] ] ], @@ -1218,10 +1237,10 @@ makeLLMPanel[ ] := Module[ { subscribeButton, username, signInButton, manageButton }, subscribeButton = Button[ - NotebookTools`Mousedown[ - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Normal", FrameMargins -> { { 17, 17 }, { 7, 7 } } ], - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Hover", FrameMargins -> { { 17, 17 }, { 7, 7 } } ], - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Pressed", FrameMargins -> { { 17, 17 }, { 7, 7 } } ] ], + mousedown[ + Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Normal" ], + Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Hover" ], + Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Pressed" ] ], Wolfram`LLMFunctions`Common`OpenLLMKitURL @ "Buy", Appearance -> "Suppressed", BaseStyle -> "DialogTextCommon", @@ -1237,7 +1256,7 @@ makeLLMPanel[ ] := Grid[ { { RawBoxes @ DynamicBox[ FEPrivate`FrontEndResource[ "FEBitmaps", "GenericUserIcon" ][ GrayLevel[ 0.2 ] ] ], - Dynamic[ FrontEnd`CurrentValue["WolframCloudFullUserName"] ] } }, + If[ $CloudEvaluation, Dynamic[ $CloudAccountName ], Dynamic[ FrontEnd`CurrentValue["WolframCloudFullUserName"] ] ] } }, Alignment -> { Left, Baseline }, BaseStyle -> { FontColor -> GrayLevel[ 0.2 ], FontSize -> 14 }, BaselinePosition -> { 1, 2 } ] }, @@ -1976,6 +1995,8 @@ highlightControl // endDefinition; (*highlightColor*) highlightColor // beginDefinition; +highlightColor[ tab_, id_ ] /; $CloudEvaluation := None + highlightColor[ tab_, id_ ] := With[ { From 99c85502d62cd8091e9017ce2d5ec9b5b930f52b Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Wed, 27 Nov 2024 10:40:00 -0800 Subject: [PATCH 2/3] Use existing dialog elements to support the preferences content --- Source/Chatbook/Dialogs.wl | 56 +++++++++++++++++---------- Source/Chatbook/PreferencesContent.wl | 26 +------------ 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/Source/Chatbook/Dialogs.wl b/Source/Chatbook/Dialogs.wl index feea7bfe..4643331e 100644 --- a/Source/Chatbook/Dialogs.wl +++ b/Source/Chatbook/Dialogs.wl @@ -30,6 +30,22 @@ $headerMargins := If[ TrueQ @ $inDialog, $dialogHeaderMargins , $paneHeader $subHeaderMargins := If[ TrueQ @ $inDialog, $dialogSubHeaderMargins, $paneSubHeaderMargins ]; $bodyMargins := If[ TrueQ @ $inDialog, $dialogBodyMargins , $paneBodyMargins ]; +(* Copied from Dialog.nb stylesheet in order for buttons to render correctly on Cloud *) +$buttonCommonOptions = { + Alignment -> Center, + BaselinePosition -> Baseline, (* added since it's repeatedly used everywhere *) + FrameMargins -> 4, + FrameStyle -> None, + ImageSize -> { { 38, Full }, { 19.5, Full } }, + RoundingRadius -> 3 +}; + +$dialogTextBasic = { + FontFamily -> "Source Sans Pro", + FontSize -> 13, + PrivateFontOptions -> { "OperatorSubstitution" -> False } +} + (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Create Dialogs*) @@ -193,26 +209,26 @@ autoMargins0 // endDefinition; (*grayDialogButtonLabel*) grayDialogButtonLabel // beginDefinition; -grayDialogButtonLabel[ { normal_, hover_, pressed_ } ] /; $cloudNotebooks := +grayDialogButtonLabel[ { normal_, hover_, pressed_ }, optsOverrides: OptionsPattern[ ] ] /; $cloudNotebooks := Mouseover[ - Framed[ normal , BaseStyle -> "ButtonGray1Normal" , BaselinePosition -> Baseline ], - Framed[ hover , BaseStyle -> "ButtonGray1Hover" , BaselinePosition -> Baseline ], - BaseStyle -> "DialogTextBasic", + Framed[ normal , Sequence @@ Join[ Flatten @ { optsOverrides }, { BaseStyle -> { FontColor -> GrayLevel[ 20/51 ] }, Background -> GrayLevel[ 229/255 ] }, $buttonCommonOptions ] ], + Framed[ hover , Sequence @@ Join[ Flatten @ { optsOverrides }, { BaseStyle -> { FontColor -> GrayLevel[ 20/51 ] }, Background -> GrayLevel[ 49/51 ], FrameStyle -> GrayLevel[ 229/255 ] }, $buttonCommonOptions ] ], + BaseStyle -> $dialogTextBasic, ContentPadding -> False, ImageSize -> All ]; -grayDialogButtonLabel[ { normal_, hover_, pressed_ } ] := +grayDialogButtonLabel[ { normal_, hover_, pressed_ }, optsOverrides: OptionsPattern[ ] ] := NotebookTools`Mousedown[ - Framed[ normal , BaseStyle -> "ButtonGray1Normal" , BaselinePosition -> Baseline ], - Framed[ hover , BaseStyle -> "ButtonGray1Hover" , BaselinePosition -> Baseline ], - Framed[ pressed, BaseStyle -> "ButtonGray1Pressed", BaselinePosition -> Baseline ], + Framed[ normal , optsOverrides, BaseStyle -> "ButtonGray1Normal" , BaselinePosition -> Baseline ], + Framed[ hover , optsOverrides, BaseStyle -> "ButtonGray1Hover" , BaselinePosition -> Baseline ], + Framed[ pressed, optsOverrides, BaseStyle -> "ButtonGray1Pressed", BaselinePosition -> Baseline ], BaseStyle -> "DialogTextBasic" ]; -grayDialogButtonLabel[ { normal_, hover_ } ] := grayDialogButtonLabel[ { normal, hover, hover } ]; +grayDialogButtonLabel[ { normal_, hover_ }, opts: OptionsPattern[ ] ] := grayDialogButtonLabel[ { normal, hover, hover }, opts ]; -grayDialogButtonLabel[ label_ ] := grayDialogButtonLabel[ { label, label, label } ]; +grayDialogButtonLabel[ label_, opts: OptionsPattern[ ] ] := grayDialogButtonLabel[ { label, label, label }, opts ]; grayDialogButtonLabel // endDefinition; @@ -221,26 +237,26 @@ grayDialogButtonLabel // endDefinition; (*redDialogButtonLabel*) redDialogButtonLabel // beginDefinition; -redDialogButtonLabel[ { normal_, hover_, pressed_ } ] /; $cloudNotebooks := +redDialogButtonLabel[ { normal_, hover_, pressed_ }, optsOverrides: OptionsPattern[ ] ] /; $cloudNotebooks := Mouseover[ - Framed[ normal , BaseStyle -> "ButtonRed1Normal" , BaselinePosition -> Baseline ], - Framed[ hover , BaseStyle -> "ButtonRed1Hover" , BaselinePosition -> Baseline ], - BaseStyle -> "DialogTextBasic", + Framed[ normal , Sequence @@ Join[ Flatten @ { optsOverrides }, { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 13/15, 1/15, 0 ] }, $buttonCommonOptions ] ], + Framed[ hover , Sequence @@ Join[ Flatten @ { optsOverrides }, { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 254/255, 0, 0 ] }, $buttonCommonOptions ] ], + BaseStyle -> $dialogTextBasic, ContentPadding -> False, ImageSize -> All ]; -redDialogButtonLabel[ { normal_, hover_, pressed_ } ] := +redDialogButtonLabel[ { normal_, hover_, pressed_ }, optsOverrides: OptionsPattern[ ] ] := NotebookTools`Mousedown[ - Framed[ normal , BaseStyle -> "ButtonRed1Normal" , BaselinePosition -> Baseline ], - Framed[ hover , BaseStyle -> "ButtonRed1Hover" , BaselinePosition -> Baseline ], - Framed[ pressed, BaseStyle -> "ButtonRed1Pressed", BaselinePosition -> Baseline ], + Framed[ normal , optsOverrides, BaseStyle -> "ButtonRed1Normal" , BaselinePosition -> Baseline ], + Framed[ hover , optsOverrides, BaseStyle -> "ButtonRed1Hover" , BaselinePosition -> Baseline ], + Framed[ pressed, optsOverrides, BaseStyle -> "ButtonRed1Pressed", BaselinePosition -> Baseline ], BaseStyle -> "DialogTextBasic" ]; -redDialogButtonLabel[ { normal_, hover_ } ] := redDialogButtonLabel[ { normal, hover, hover } ]; +redDialogButtonLabel[ { normal_, hover_ }, opts: OptionsPattern[ ] ] := redDialogButtonLabel[ { normal, hover, hover }, opts ]; -redDialogButtonLabel[ label_ ] := redDialogButtonLabel[ { label, label, label } ]; +redDialogButtonLabel[ label_, opts: OptionsPattern[ ] ] := redDialogButtonLabel[ { label, label, label }, opts ]; redDialogButtonLabel // endDefinition; diff --git a/Source/Chatbook/PreferencesContent.wl b/Source/Chatbook/PreferencesContent.wl index 3bf7f197..cb5ae100 100644 --- a/Source/Chatbook/PreferencesContent.wl +++ b/Source/Chatbook/PreferencesContent.wl @@ -112,25 +112,6 @@ currentTabPage[ scope_ ] := Replace[ currentTabPage // endDefinition; -(* ::**************************************************************************************************************:: *) -(* ::Subsection::Closed:: *) -(*mousedown*) -(* Cloud doesn't utilize the Dialog.nb stylesheet as expected, so workaround that. *) -mousedown[ args__ ] := NotebookTools`Mousedown[ args ] - -commonOpts = { Alignment -> Center, FrameMargins -> { { 17, 17 }, { 7, 7 } }, FrameStyle -> None, ImageSize -> { { 38, Full }, { 19.5, Full } }, RoundingRadius -> 3 }; - -mousedown[ args__ ] /; $CloudEvaluation := -ReplaceAll[ - NotebookTools`Mousedown[args], - { - HoldPattern[ BaseStyle -> "ButtonRed1Normal" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 13/15, 1/15, 0 ] }, commonOpts ], - HoldPattern[ BaseStyle -> "ButtonRed1Hover" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 254/255, 0, 0 ] }, commonOpts ], - HoldPattern[ BaseStyle -> "ButtonRed1Pressed" ] :> Sequence @@ Join[ { BaseStyle -> { FontColor -> GrayLevel[ 1 ] }, Background -> RGBColor[ 176/255, 1/17, 0 ] }, commonOpts ] - } -] - - (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Main*) @@ -1187,7 +1168,7 @@ servicesSettingsPanel0[ ] := Enclose[ llmHelp = (* If this tooltip isn't meant to be a button, then use infoTooltip[llmLabel, text] *) Button[ Tooltip[ - mousedown[ + NotebookTools`Mousedown[ Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.537 ], 14 ] ] ], Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.692 ], 14 ] ] ], Dynamic[ RawBoxes[ FEPrivate`FrontEndResource[ "FEBitmaps", "ProductSelectorInfo" ][ GrayLevel[ 0.358 ], 14 ] ] ] ], @@ -1237,10 +1218,7 @@ makeLLMPanel[ ] := Module[ { subscribeButton, username, signInButton, manageButton }, subscribeButton = Button[ - mousedown[ - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Normal" ], - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Hover" ], - Framed[ tr[ "PreferencesContentLLMKitSubscribeButton" ], BaseStyle -> "ButtonRed1Pressed" ] ], + redDialogButtonLabel[ tr[ "PreferencesContentLLMKitSubscribeButton" ], FrameMargins -> { { 17, 17 }, { 7, 7 } } ], Wolfram`LLMFunctions`Common`OpenLLMKitURL @ "Buy", Appearance -> "Suppressed", BaseStyle -> "DialogTextCommon", From cfbe0e991b3ab911503053451ef6d4b1b68f5703 Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Wed, 27 Nov 2024 10:41:07 -0800 Subject: [PATCH 3/3] Update string resource "ChatToolbarChatEnabledLabel" --- FrontEnd/TextResources/ChatbookStrings.tr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontEnd/TextResources/ChatbookStrings.tr b/FrontEnd/TextResources/ChatbookStrings.tr index 44ae93e7..23338c1c 100644 --- a/FrontEnd/TextResources/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChatbookStrings.tr @@ -37,7 +37,7 @@ "ChatToolbarInsertChatCell" -> "Insert Chat Cell", "ChatToolbarChatSettings" -> "Chat Settings", "ChatToolbarChatDrivenLabel" -> "Chat-Driven Notebook", -"ChatToolbarChatEnabledLabel" -> "Chat-Enabled Notebook", +"ChatToolbarChatEnabledLabel" -> "Chat Notebook", "DefaultToolsLinks" -> "Links",