From 40a89fc3375e71ec2b6fe90fc68086c153ead720 Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Sat, 5 Oct 2024 15:52:15 +0200 Subject: [PATCH] add ctrl modifier drag for fixed-fluid mode that changes behavior --- core/wiki/macros/sidebar-resizer.tid | 86 +++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 13 deletions(-) diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index 9e024c10b..c031a0f67 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -4,7 +4,7 @@ title: $:/core/macros/sidebar-resizer \function is.percentage.value(value) [removesuffix[%]] \procedure sidebar-resizer-pointerdown-actions() -<%if [[$:/state/sidebar/resizing]is[missing]thenmatch[left]thenmatch[normal]] %> +<%if [[$:/state/sidebar/resizing]is[missing]thenmatch[left]] %> <$let startPosX=<> dragGripDiff=<> storyRiverWidth={{{ [subtractsubtract[14]add[42]] }}} sidebarWidth={{{ [subtractaddadd[14]] }}}> <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> @@ -87,26 +87,74 @@ title: $:/core/macros/sidebar-resizer \end -\procedure set-storyright-action(suffix) +\procedure set-storyright-action-alternative(suffix) <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [subtractaddsuffixcompare:number:ltthenaddaddsuffix] [addsuffixcompare:number:gteqthenaddsuffix] ~[addsuffix] }}}/> \end +\procedure set-storyright-actions-percentage-alternative() +<$let storyLeftStart={{{ [is.pixel.value{$:/state/sidebar/resizing!!start-story-left}multiply[100]divide] ~[is.percentage.value{$:/state/sidebar/resizing!!start-story-left}] }}} storyRightStart={{$:/state/sidebar/resizing!!start-story-right}} storyRiverWidthConverted={{{ [multiply[100]divide] }}}> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> + <> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiplydivide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> + <> + + <% endif %> + +\end + +\procedure set-storyright-actions-pixel-alternative() +<$let storyLeftStart={{{ [is.percentage.value{$:/state/sidebar/resizing!!start-story-left}multiplydivide[100]] ~[is.pixel.value{$:/state/sidebar/resizing!!start-story-left}] }}} storyRightStart={{$:/state/sidebar/resizing!!start-story-right}} storyRiverWidthConverted=<>> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiplydivide[100]addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiplydivide[100]addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> + <> + + <% endif %> + +\end + +\procedure set-storyright-action(suffix) +<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffixcompare:number:ltthen] [addsuffixcompare:number:gteqthenaddsuffix] ~[addsuffix] }}}/> +\end + \procedure set-storyright-actions-percentage() <$let storyLeftStart={{{ [is.pixel.value{$:/state/sidebar/resizing!!start-story-left}multiply[100]divide] ~[is.percentage.value{$:/state/sidebar/resizing!!start-story-left}] }}} storyRightStart={{$:/state/sidebar/resizing!!start-story-right}} storyRiverWidthConverted={{{ [multiply[100]divide] }}}> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> <> <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiplydivide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiply[100]divideaddsuffix[%]] }}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiplydivide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}}> <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> + <$let storyWidthConverted={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtractmultiply[100]divide] }}}> <> <% endif %> @@ -116,19 +164,19 @@ title: $:/core/macros/sidebar-resizer \procedure set-storyright-actions-pixel() <$let storyLeftStart={{{ [is.percentage.value{$:/state/sidebar/resizing!!start-story-left}multiplydivide[100]] ~[is.pixel.value{$:/state/sidebar/resizing!!start-story-left}] }}} storyRightStart={{$:/state/sidebar/resizing!!start-story-right}} storyRiverWidthConverted=<>> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <$let storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> <> <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsubtractmultiply[-1]] }}} storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> + <$let storyWidthConverted={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiplydivide[100]addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> <> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] :then[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> - <$let storyDiff={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storywidth}multiplydivide[100]addsubtractmultiply[-1]] }}} storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]addsuffix[px]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> <> <% endif %> @@ -195,11 +243,23 @@ title: $:/core/macros/sidebar-resizer <> <% endif %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> - <> + <%if [match[ctrl]] %> + <> + <% else %> + <> + <% endif %> <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> - <> + <%if [match[ctrl]] %> + <> + <% else %> + <> + <% endif %> <% else %> - <> + <%if [match[ctrl]] %> + <> + <% else %> + <> + <% endif %> <% endif %> <% else %> <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %>