Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fold bad tool calls into a "discarded material" opener #654

Merged
merged 11 commits into from
Apr 18, 2024
Binary file modified Assets/DisplayFunctions.wxf
Binary file not shown.
Binary file modified Assets/Icons.wxf
Binary file not shown.
134 changes: 134 additions & 0 deletions Developer/Resources/Icons/DiscardedMaterial.wl
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
Graphics[
{
Thickness[ 0.066667 ],
FaceForm @ { RGBColor[ 0.53725, 0.53725, 0.53725 ], Opacity[ 1.0 ] },
FilledCurve[
{
{
{ 1, 4, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 }
},
{
{ 0, 2, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 1, 3, 3 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 },
{ 0, 1, 0 },
{ 1, 3, 3 }
},
{
{ 0, 2, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 }
}
},
{
{
{ 13.0, 12.75 },
{ 13.0, 12.888 },
{ 12.888, 13.0 },
{ 12.75, 13.0 },
{ 2.25, 13.0 },
{ 2.112, 13.0 },
{ 2.0, 12.888 },
{ 2.0, 12.75 },
{ 2.0, 5.25 },
{ 2.0, 5.112 },
{ 2.112, 5.0 },
{ 2.25, 5.0 },
{ 4.468, 5.0 },
{ 4.744, 5.0 },
{ 4.968, 4.776 },
{ 4.968, 4.5 },
{ 4.968, 2.698 },
{ 7.148, 4.855 },
{ 7.242, 4.948 },
{ 7.368, 5.0 },
{ 7.5, 5.0 },
{ 12.75, 5.0 },
{ 12.888, 5.0 },
{ 13.0, 5.112 },
{ 13.0, 5.25 },
{ 13.0, 12.75 }
},
{
{ 14.0, 12.75 },
{ 14.0, 5.25 },
{ 14.0, 4.561 },
{ 13.439, 4.0 },
{ 12.75, 4.0 },
{ 7.706, 4.0 },
{ 4.819, 1.145 },
{ 4.724, 1.05 },
{ 4.597, 1.0 },
{ 4.468, 1.0 },
{ 4.403, 1.0 },
{ 4.337, 1.013 },
{ 4.275, 1.038 },
{ 4.089, 1.116 },
{ 3.968, 1.298 },
{ 3.968, 1.5 },
{ 3.968, 4.0 },
{ 2.25, 4.0 },
{ 1.561, 4.0 },
{ 1.0, 4.561 },
{ 1.0, 5.25 },
{ 1.0, 12.75 },
{ 1.0, 13.439 },
{ 1.561, 14.0 },
{ 2.25, 14.0 },
{ 12.75, 14.0 },
{ 13.439, 14.0 },
{ 14.0, 13.439 },
{ 14.0, 12.75 }
},
{
{ 10.316, 11.109 },
{ 8.207, 9.0 },
{ 10.316, 6.891 },
{ 9.609, 6.184 },
{ 7.5, 8.293 },
{ 5.391, 6.184 },
{ 4.684, 6.891 },
{ 6.793, 9.0 },
{ 4.684, 11.109 },
{ 5.391, 11.816 },
{ 7.5, 9.707 },
{ 9.609, 11.816 },
{ 10.316, 11.109 }
}
}
]
},
AspectRatio -> Automatic,
ImageSize -> { 16.0, 16.0 },
PlotRange -> { { -0.5, 15.5 }, { -0.5, 15.5 } }
]
132 changes: 132 additions & 0 deletions Developer/Resources/Styles.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,138 @@ Cell[



(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*DiscardedMaterialOpener*)


Cell[
StyleData[ "DiscardedMaterialOpener" ],
TemplateBoxOptions -> {
DisplayFunction -> Function @ DynamicModuleBox[
{ Typeset`hover$$ = False, Typeset`open$$ = False },
PaneSelectorBox[
{
False -> TagBox[
GridBox[
{ { $discardedMaterialLabel } },
DefaultBaseStyle -> "Column",
GridBoxAlignment -> { "Columns" -> { { Left } } },
GridBoxItemSize -> { "Columns" -> { { Automatic } }, "Rows" -> { { Automatic } } },
GridBoxSpacings -> { "Columns" -> { { Automatic } }, "Rows" -> { { 0.25 } } }
],
"Column"
],
True -> TagBox[
GridBox[
{
{ $discardedMaterialLabel },
{
FrameBox[
#1,
Background -> RGBColor[ 0.94902, 0.96863, 0.98824 ],
FrameMargins -> 10,
FrameStyle -> RGBColor[ 0.9098, 0.93333, 0.95294 ],
ImageSize -> { Full, Automatic },
RoundingRadius -> 5,
StripOnInput -> False
]
}
},
DefaultBaseStyle -> "Column",
GridBoxAlignment -> { "Columns" -> { { Left } } },
GridBoxItemSize -> { "Columns" -> { { Automatic } }, "Rows" -> { { Automatic } } },
GridBoxSpacings -> { "Columns" -> { { Automatic } }, "Rows" -> { { 0.25 } } }
],
"Column"
]
},
Dynamic @ Typeset`open$$,
ImageMargins -> 10,
ImageSize -> Automatic,
Alignment -> Left,
ContentPadding -> False
],
DynamicModuleValues :> { },
UnsavedVariables :> { Typeset`hover$$ }
]
}
]


Cell[
StyleData[ "DiscardedMaterialOpenerIcon" ],
TemplateBoxOptions -> {
DisplayFunction -> Function @ GraphicsBox[
{
#1,
Thickness[ 0.090909 ],
Opacity[ 1.0 ],
FilledCurveBox[
{
{
{ 0, 2, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 }
}
},
{
{
{ 8.5, 4.5 },
{ 6.5, 4.5 },
{ 6.5, 2.5 },
{ 4.5, 2.5 },
{ 4.5, 4.5 },
{ 2.5, 4.5 },
{ 2.5, 6.5 },
{ 4.5, 6.5 },
{ 4.5, 8.5 },
{ 6.5, 8.5 },
{ 6.5, 6.5 },
{ 8.5, 6.5 }
}
}
]
},
AspectRatio -> Automatic,
BaselinePosition -> Center -> Center,
ImageSize -> { 11.0, 11.0 },
PlotRange -> { { 0.0, 11.0 }, { 0.0, 11.0 } }
]
}
]


Cell[
StyleData[ "DiscardedMaterialCloserIcon" ],
TemplateBoxOptions -> {
DisplayFunction -> Function @ GraphicsBox[
{
#1,
Thickness[ 0.090909 ],
Opacity[ 1.0 ],
FilledCurveBox[
{ { { 0, 2, 0 }, { 0, 1, 0 }, { 0, 1, 0 } } },
{ { { 8.5, 4.5 }, { 2.5, 4.5 }, { 2.5, 6.5 }, { 8.5, 6.5 } } }
]
},
AspectRatio -> Automatic,
BaselinePosition -> Center -> Center,
ImageSize -> { 11.0, 11.0 },
PlotRange -> { { 0.0, 11.0 }, { 0.0, 11.0 } }
]
}
]


(* ::Section::Closed:: *)
(*Package Footer*)

Expand Down
59 changes: 58 additions & 1 deletion Developer/StylesheetBuilder.wl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,62 @@ insertionPointMenuItem[ icon_, label_, shortcut_, style_ ] :=
] :> FrontEndTokenExecute[ EvaluationNotebook[ ], "Style", style ];


(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*DiscardedMaterialOpener*)

discardedMaterialLabelBox[ Dynamic[ hover_ ], Dynamic[ open_ ] ] := TagBox[
TagBox[
FrameBox[
TagBox[
GridBox[
{
{
TemplateBox[ { }, "DiscardedMaterial" ],
"\"Discarded material\"",
discardedMaterialLabelIcon[ Dynamic @ hover, Dynamic @ open ]
}
},
GridBoxAlignment -> { "Columns" -> { { Automatic } }, "Rows" -> { { Baseline } } },
AutoDelete -> False,
GridBoxItemSize -> { "Columns" -> { { Automatic } }, "Rows" -> { { Automatic } } }
],
"Grid"
],
Background -> Dynamic @ FEPrivate`If[ hover, GrayLevel[ 1 ], RGBColor[ 0.94902, 0.96863, 0.98824 ] ],
BaseStyle -> { "Text", "IconizedDefaultName", ShowStringCharacters -> False },
FrameMargins -> 2,
FrameStyle -> RGBColor[ 0.9098, 0.93333, 0.95294 ],
RoundingRadius -> 5,
StripOnInput -> False
],
EventHandlerTag @ {
"MouseEntered" :> FEPrivate`Set[ hover, True ],
"MouseExited" :> FEPrivate`Set[ hover, False ],
"MouseClicked" :> FEPrivate`Set[ open, FEPrivate`If[ open, False, True ] ],
PassEventsDown -> True,
Method -> "Preemptive",
PassEventsUp -> True
}
],
MouseAppearanceTag[ "LinkHand" ]
];

discardedMaterialLabelIcon[ Dynamic[ hover_ ], Dynamic[ open_ ] ] :=
With[ { hoverColor = RGBColor[ 0.3451, 0.72157, 0.98039 ], defaultColor = GrayLevel[ 0.7451 ] },
PaneSelectorBox[
{
{ True , False } -> TemplateBox[ { hoverColor }, "DiscardedMaterialOpenerIcon" ],
{ False, False } -> TemplateBox[ { defaultColor }, "DiscardedMaterialOpenerIcon" ],
{ True , True } -> TemplateBox[ { hoverColor }, "DiscardedMaterialCloserIcon" ],
{ False, True } -> TemplateBox[ { defaultColor }, "DiscardedMaterialCloserIcon" ]
},
Dynamic[ { hover, open } ]
]
];


$discardedMaterialLabel = discardedMaterialLabelBox[ Dynamic @ Typeset`hover$$, Dynamic @ Typeset`open$$ ];

(* ::Subsection::Closed:: *)
(*Stylesheet Version*)
Expand All @@ -516,7 +572,8 @@ $stylesheetVersion = StringJoin[
inlineResources[ expr_ ] := expr /. {
HoldPattern @ $askMenuItem :> RuleCondition @ $askMenuItem,
HoldPattern @ $defaultChatbookSettings :> RuleCondition @ $defaultChatbookSettings,
HoldPattern @ $suppressButtonAppearance :> RuleCondition @ $suppressButtonAppearance
HoldPattern @ $suppressButtonAppearance :> RuleCondition @ $suppressButtonAppearance,
HoldPattern @ $discardedMaterialLabel :> RuleCondition @ $discardedMaterialLabel
};


Expand Down
Loading