1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-25 08:26:52 +00:00

more calculations

This commit is contained in:
BurningTreeC 2024-10-05 08:04:03 +02:00
parent dd5af9f092
commit ea7da2b8c1

View File

@ -88,11 +88,11 @@ title: $:/core/macros/sidebar-resizer
\end
\procedure set-storyright-action(suffix)
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [<storyRiverWidth>addsuffix<suffix>compare:number:lteq<storyWidthConverted>then<storyWidthConverted>] [<storyRiverWidth>addsuffix<suffix>compare:number:gteq<storyRiverLimit>then<storyRiverLimit>addsuffix<suffix>] ~[<storyRiverWidth>addsuffix<suffix>] }}}/>
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [<storyRiverWidth>addsuffix<suffix>compare:number:lteq<storyWidthConverted>then<storyWidthConverted>] [<storyRiverWidth>addsuffix<suffix>compare:number:gteq<storyRiverLimit>then<storyRiverLimit>addsuffix<suffix>] ~[<storyRiverWidthConverted>addsuffix<suffix>] }}}/>
\end
\procedure set-storyright-actions-percentage()
<$set name="storyRiverWidth" value={{{ [<storyRiverWidth>multiply[100]divide<widgetNodeWidth>] }}}>
<$set name="storyRiverWidthConverted" value={{{ [<storyRiverWidth>multiply[100]divide<widgetNodeWidth>] }}}>
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$vars storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divide<widgetNodeWidth>] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action %>>
@ -102,11 +102,11 @@ title: $:/core/macros/sidebar-resizer
<<set-storyright-action %>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<$let storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action %>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<$let storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} sidebarMinWidth={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<<set-storyright-action %>>
</$let>
<% endif %>
@ -114,23 +114,73 @@ title: $:/core/macros/sidebar-resizer
\end
\procedure set-storyright-actions-pixel()
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$vars storyWidthConverted=<<storyRiverWidth>> storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action px>>
</$set>
<%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted=<<storyRiverWidth>> sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide<widgetNodeWidth>] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<<set-storyright-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<<set-storyright-action px>>
</$let>
<% endif %>
<$set name="storyRiverWidthConverted" value=<<storyRiverWidth>>>
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$vars storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action px>>
</$vars>
<%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide<widgetNodeWidth>] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<<set-storyright-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<<set-storyright-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %>
<$let storyWidthConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} sidebarMinWidth={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [<widgetNodeWidth>subtract<sidebarMinWidth>] }}}>
<<set-storyright-action px>>
</$let>
<% endif %>
</$set>
\end
\procedure set-sidebarwidth-action(suffix)
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidthConverted>addsuffix<suffix>compare:number:gteq<sidebarMaxWidth>then<sidebarMaxWidth>] [<sidebarWidthConverted>addsuffix<suffix>compare:number:lteq<sidebarMinWidth>then<sidebarMinWidth>] ~[<sidebarWidthConverted>addsuffix<suffix>] }}}/>
\end
\procedure set-sidebarwidth-actions-percentage()
<$vars sidebarWidthConverted={{{ [<sidebarWidth>multiply[100]divide<widgetNodeWidth>] }}} sidebarMinWidth={{{ [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide<widgetNodeWidth>addsuffix[%]] [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}>
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyLeftConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyleft}multiply[100]divide<widgetNodeWidth>] }}} storyMinWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}multiply[100]divide<widgetNodeWidth>] }}} sidebarMaxWidth={{{ [[100]subtract<storyLeftConverted>subtract<storyMinWidthConverted>addsuffix[%]] }}}>
<<set-sidebarwidth-action %>>
</$let>
<%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyLeftConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyleft}multiply[100]divide<widgetNodeWidth>] }}} sidebarMaxWidth={{{ [[100]subtract<storyLeftConverted>subtract{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}addsuffix[%]] }}}>
<<set-sidebarwidth-action %>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyMinWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}multiply[100]divide<widgetNodeWidth>] }}} sidebarMaxWidth={{{ [[100]subtract{$:/themes/tiddlywiki/vanilla/metrics/storyleft}subtract<storyMinWidthConverted>addsuffix[%]] }}}>
<<set-sidebarwidth-action %>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$set name="sidebarMaxWidth" value={{{ [[100]subtract{$:/themes/tiddlywiki/vanilla/metrics/storyleft}subtract{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}addsuffix[%]] }}}>
<<set-sidebarwidth-action %>>
</$set>
<% endif %>
</$vars>
\end
\procedure set-sidebarwidth-actions-pixel()
<$vars sidebarWidthConverted=<<sidebarWidth>> sidebarMinWidth={{{ [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}addsuffix[px]] [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply<widgetNodeWidth>divide[100]addsuffix[px]] }}}>
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$vars sidebarMaxWidth={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/storyleft}subtract{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}addsuffix[px]] }}}>
<<set-sidebarwidth-action px>>
</$vars>
<%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyMinWidthConverted={{{ [<widgetNodeWidth>multipy{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}divide[100]] }}} sidebarMaxWidth={{{ [<widgetNodeWidth>subtract{$:/themes/tiddlywiki/vanilla/metrics/storyleft}subtract<storyMinWidthConverted>addsuffix[px]] }}}>
<<set-sidebarwidth-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyLeftConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storyleft}divide[100]] }}} sidebarMaxWidth={{{ [<widgetNodeWidth>subtract<storyLeftConverted>subtract{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}addsuffix[px]] }}}>
<<set-sidebarwidth-action px>>
</$let>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] %>
<$let storyLeftConverted={{{ [<widgetNodeWidth>multiply{$:/themes/tiddlywiki/vanilla/metrics/storyleft}divide[100]] }}} storyMinWidthConverted={{{ [<widgetNodeWidth>multipy{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}divide[100]] }}} sidebarMaxWidth={{{ [<widgetNodeWidth>subtract<storyLeftConverted>subtract<storyMinWidthConverted>addsuffix[px]] }}}>
<<set-sidebarwidth-action px>>
</$let>
<% endif %>
</$vars>
\end
\procedure sidebar-resizer-pointermove-actions()
@ -153,11 +203,11 @@ title: $:/core/macros/sidebar-resizer
<% endif %>
<% else %>
<%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %>
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidth>addsuffix[px]] }}}/>
<<set-sidebarwidth-actions-pixel>>
<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %>
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidth>divide<widgetNodeWidth>multiply[100]addsuffix[%]] }}}/>
<<set-sidebarwidth-actions-percentage>>
<% else %>
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidth>addsuffix[px]] }}}/>
<<set-sidebarwidth-actions-pixel>>
<% endif %>
<% endif %>
</$let>