Skip to content

Commit

Permalink
Merge pull request #484 from WolframResearch/bugfix/avoid-bouncing-co…
Browse files Browse the repository at this point in the history
…py-buttons-in-cloud

Make `inlineInteractiveCodeCell` portable between cloud and desktop and avoid bouncing on mouseover in cloud
  • Loading branch information
rhennigan authored Dec 1, 2023
2 parents e2df35d + 64926ba commit f3ca2d4
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions Source/Chatbook/Formatting.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,16 @@ inlineInteractiveCodeCell // beginDefinition;
inlineInteractiveCodeCell[ display_, string_ ] /; $dynamicText := display;

inlineInteractiveCodeCell[ display_, string_ ] :=
inlineInteractiveCodeCell[ display, string, contentLanguage @ string ];
With[ { lang = contentLanguage @ string },
Dynamic[
inlineInteractiveCodeCell[ display, string, lang ],
Initialization :> Quiet @ Needs[ "Wolfram`Chatbook`" -> None ],
SingleEvaluation -> True
]
];

inlineInteractiveCodeCell[ display_, string_, lang_ ] /; $cloudNotebooks :=
Mouseover[ display, Column @ { display, floatingButtonGrid[ string, lang ] } ];
cloudInlineInteractiveCodeCell[ display, string, lang ];

inlineInteractiveCodeCell[ display_, string_, lang_ ] :=
DynamicModule[ { $CellContext`attached, $CellContext`cell },
Expand All @@ -1167,6 +1173,54 @@ inlineInteractiveCodeCell[ display_, string_, lang_ ] :=

inlineInteractiveCodeCell // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*cloudInlineInteractiveCodeCell*)
cloudInlineInteractiveCodeCell // beginDefinition;

cloudInlineInteractiveCodeCell[ display_, string_, lang_ ] :=
Module[ { padded, buttons },

padded = Pane[ display, ImageSize -> { { 100, Automatic }, { 30, Automatic } } ];

buttons = Framed[
floatingButtonGrid[ string, lang ],
Background -> White,
FrameMargins -> { { 1, 0 }, { 0, 1 } },
FrameStyle -> White,
ImageMargins -> 1,
RoundingRadius -> 3
];

Mouseover[
buttonOverlay[ padded, Invisible @ buttons ],
buttonOverlay[ padded, buttons ],
ContentPadding -> False,
FrameMargins -> 0,
ImageMargins -> 0,
ImageSize -> All
]
];

cloudInlineInteractiveCodeCell // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*buttonOverlay*)
buttonOverlay // beginDefinition;

buttonOverlay[ a_, b_ ] := Overlay[
{ a, b },
All,
2,
Alignment -> { Left, Bottom },
ContentPadding -> False,
FrameMargins -> 0,
ImageMargins -> 0
];

buttonOverlay // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*makeInlineCodeCell*)
Expand Down

0 comments on commit f3ca2d4

Please sign in to comment.