From dd5af9f092aeaaadacfcc03d66b7b2191fa0c2a1 Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Sat, 5 Oct 2024 06:11:13 +0200 Subject: [PATCH] cleanup pointermove actions --- core/wiki/macros/sidebar-resizer.tid | 141 ++++++++++++++++++++------- 1 file changed, 105 insertions(+), 36 deletions(-) diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index 1df2a11fe..e15239254 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -1,7 +1,8 @@ title: $:/core/macros/sidebar-resizer -\function is.pixel.value(value) [removesuffix[px]compare:number:eq] -\function is.percentage.value(value) [removesuffix[%]compare:number:eq] +\function is.pixel.value(value) [removesuffix[px]] +\function is.percentage.value(value) [removesuffix[%]] + \procedure sidebar-resizer-pointerdown-actions() <%if [[$:/state/sidebar/resizing]is[missing]thenmatch[left]thenmatch[normal]] %> <$let startPosX=<> dragGripDiff=<> storyRiverWidth={{{ [subtractsubtract[14]add[42]] }}} sidebarWidth={{{ [subtractaddadd[14]] }}}> @@ -33,54 +34,122 @@ title: $:/core/macros/sidebar-resizer <% endif %> \end + \procedure sidebar-resizer-pointercancel-actions() <$action-deletetiddler $tiddler="$:/state/sidebar/resizing"/> \end + +\procedure set-storyleft-action(suffix) +<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [compare:number:lteq[0]then[0]addsuffix] ~[compare:number:gteqthen] ~[] }}}/> +\end + +\procedure set-storyleft-actions-percentage() +<$let dragDiffPercentage={{{ [dividemultiply[100]] }}} storyLeft={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[%]] }}}> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$vars storyLeftMax={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}}> + <> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} storyLeftMax={{{ [[100]subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtractaddsuffix[%]] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyLeftMax={{{ [[100]subtractsubtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[%]] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$set name="storyLeftMax" value={{{ [[100]subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[%]] }}}> + <> + + <% endif %> + +\end + +\procedure set-storyleft-actions-pixel() +<$set name="storyLeft" value={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[px]] }}}> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$set name="storyLeftMax" value={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[px]] }}}> + <> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyLeftMax={{{ [subtractsubtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[px]] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyLeftMax={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtractaddsuffix[px]] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyLeftMax={{{ [subtractsubtractaddsuffix[px]] }}}> + <> + + <% endif %> + +\end + +\procedure set-storyright-action(suffix) +<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffixcompare:number:lteqthen] [addsuffixcompare:number:gteqthenaddsuffix] ~[addsuffix] }}}/> +\end + +\procedure set-storyright-actions-percentage() +<$set name="storyRiverWidth" value={{{ [multiply[100]divide] }}}> + <%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] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divide] }}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> + <> + + <% endif %> + +\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=<> storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + +<%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted=<> sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> + <> + +<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + +<%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> + <> + +<% endif %> +\end + \procedure sidebar-resizer-pointermove-actions() <%if [[$:/state/sidebar/resizing]!is[missing]] %> <$let dragDiff={{{ [subtract{$:/state/sidebar/resizing!!start-posx}] }}} storyRiverWidth={{{ [subtract{$:/state/sidebar/resizing!!drag-grip-diff}subtract[14]add[42]] }}} sidebarWidth={{{ [subtractadd{$:/state/sidebar/resizing!!drag-grip-diff}add[14]] }}} widgetNodeWidth={{$:/state/sidebar/resizing!!widget-node-width}}> <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> - <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$vars storyLeft={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[px]] }}} storyLeftMax={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[px]] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [compare:number:lteq[0]then[0px]] ~[compare:number:gteqthen] ~[] }}}/> - - <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - - <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - - <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - - <% endif %> + <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> - <$set name="dragDiffPercentage" value={{{ [dividemultiply[100]] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[%]compare:number:gteq[0]] ~0% }}}/> - + <> <% else %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[px]compare:number:gteq[0]] ~0px }}}/> + <> <% endif %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> - <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$set name="storyRiverLimit" value={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteq{$:/themes/tiddlywiki/vanilla/metrics/storywidth}then{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> - - <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteq{$:/themes/tiddlywiki/vanilla/metrics/storywidth}then{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> - - <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteqthen] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> - - <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteqthen] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> - - <% endif %> + <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [dividemultiply[100]addsuffix[%]] }}}/> + <> <% else %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <> <% endif %> <% else %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %>