diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index 1df6b67ae..0e6c926dc 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -30,6 +30,8 @@ title: $:/core/macros/sidebar-resizer \function convert.to.pixels(value) [is.pixel.value] [is.percentage.valuemultiplydivide[100]] [is.cm.valuemultiply[37.8]] [is.mm.valuemultiply[37.8]divide[10]] [is.Q.valuemultiply[37.8]divide[40]] [is.in.valuemultiply[96]] [is.pc.valuemultiply[96]divide[6]] [is.pt.valuemultiply[96]divide[72]] [is.em.valuemultiply{$:/themes/tiddlywiki/vanilla/metrics/fontsize}] +\function convert.to.pixels.relative.to(value,parent) [is.pixel.value] [is.percentage.valuemultiplydivide[100]] [is.cm.valuemultiply[37.8]] [is.mm.valuemultiply[37.8]divide[10]] [is.Q.valuemultiply[37.8]divide[40]] [is.in.valuemultiply[96]] [is.pc.valuemultiply[96]divide[6]] [is.pt.valuemultiply[96]divide[72]] [is.em.valuemultiply{$:/themes/tiddlywiki/vanilla/metrics/fontsize}] + \function convert.to.result(value,suffix) [match[px]then] [match[%]then] [match[cm]then] [match[mm]then] [match[Q]then] [match[in]then] [match[pc]then] [match[pt]then] [match[em]then] \function get.value.metric(value) [suffix[px]then[px]] ~[suffix[%]then[%]] ~[suffix[cm]then[cm]] ~[suffix[mm]then[mm]] ~[suffix[Q]then[Q]] ~[suffix[in]then[in]] ~[suffix[pc]then[pc]] ~[suffix[pt]then[pt]] ~[suffix[em]then[em]] @@ -43,10 +45,13 @@ title: $:/core/macros/sidebar-resizer start-story-left={{$:/themes/tiddlywiki/vanilla/metrics/storyleft}} story-left-metric={{{ [get.value.metric{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] }}} start-story-right={{$:/themes/tiddlywiki/vanilla/metrics/storyright}} - saved-story-right={{$:/themes/tiddlywiki/vanilla/metrics/storyright}} story-right-metric={{{ [get.value.metric{$:/themes/tiddlywiki/vanilla/metrics/storyright}] }}} start-sidebar-width={{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}} sidebar-width-metric={{{ [get.value.metric{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] }}} + start-tiddler-width={{$:/themes/tiddlywiki/vanilla/metrics/tiddlerwidth}} + tiddler-width-metric={{{ [get.value.metric{$:/themes/tiddlywiki/vanilla/metrics/tiddlerwidth}] }}} + start-story-width={{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} + story-width-metric={{{ [get.value.metric{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} /> <% endif %> \end @@ -55,43 +60,58 @@ title: $:/core/macros/sidebar-resizer <$action-deletetiddler $tiddler="$:/state/sidebar/resizing"/> \end -\function convert.storydiffintermediate.to.result() [function[convert.to.result],,] -\function convert.storydiff.to.result() [function[convert.to.result],,] -\function convert.leftdiff.to.result() [function[convert.to.result],,] - \procedure set-storyleft-storyright-actions() <$let - storyLeftStart={{{ [convert.to.pixels{$:/state/sidebar/resizing!!start-story-left}] }}} storyRightStart={{{ [convert.to.pixels{$:/state/sidebar/resizing!!start-story-right}] }}} - storyWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] }}} - storyLeft={{{ [convert.to.pixels{$:/state/sidebar/resizing!!start-story-left}add] }}} + storyWidthStart={{{ [convert.to.pixels{$:/state/sidebar/resizing!!start-story-width}] }}} + storyMinWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] }}} + storyWidth={{{ [add] }}} + innerStoryWidth={{{ [subtract[84]] }}} + innerStoryWidthStart={{{ [subtract[84]] }}} + storyLeft={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] }}} + storyWidthAddLeft={{{ [add] }}} + storyMinWidthAddLeft={{{ [add] }}} sidebarMinWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}} storyRiverLimit={{{ [subtract] }}} - storyDiff={{{ [addsubtractmultiply[-1]] }}} - storyLeftMax={{{ [subtractsubtractsubtract] }}}> + storyMaxWidth={{{ [subtract] }}} + tiddlerWidthMetric={{$:/state/sidebar/resizing!!tiddler-width-metric}} + tiddlerWidthStart={{$:/state/sidebar/resizing!!start-tiddler-width}} + tiddlerWidthStartPixels={{{ [match[%]thenmultiplydivide[100]] ~[convert.to.pixels] }}} + tiddlerWidth={{{ [add] }}} + tiddlerWidthDiff={{{ [subtract] }}} + tiddlerMinWidth={{{ [match[%]then] ~[subtract] }}} + tiddlerMaxWidth={{{ [match[%]then] ~[subtract] }}}> + + <$let + storyWidthMetric={{$:/state/sidebar/resizing!!story-width-metric}} + storyWidthConverted={{{ [function[convert.to.result],,] }}} + storyMinWidthConverted={{{ [function[convert.to.result],,] }}} + storyMaxWidthConverted={{{ [function[convert.to.result],,] }}} + tiddlerWidthConverted={{{ [match[%]thenmultiply[100]divide] ~[function[convert.to.result],,] }}} + tiddlerMinWidthConverted={{{ [match[%]thenmultiply[100]divide] ~[function[convert.to.result],,] }}} + tiddlerMaxWidthConverted={{{ [match[%]thenmultiply[100]divide] ~[function[convert.to.result],,] }}} + + storyWidthResult={{{ [compare:number:ltthenaddsuffix] ~[compare:number:gteqthenaddsuffix] ~[addsuffix] }}} + + tiddlerWidthResult={{{ [compare:number:ltthenaddsuffix] ~[compare:number:gteqthenaddsuffix] ~[addsuffix] }}}> + + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/tiddlerwidth" text=<>/> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storywidth" text=<>/> + + <$let storyRightMetric={{$:/state/sidebar/resizing!!story-right-metric}} storyRiverWidthConverted={{{ [function[convert.to.result],,] }}} storyRiverLimitConverted={{{ [function[convert.to.result],,] }}} - storyDiffConverted={{{ [!match[ctrl]then] ~0 }}} - storyWidthConverted={{{ [function[convert.to.result],,] }}} - result={{{ [subtractcompare:number:ltthenaddaddsuffix] ~[compare:number:gteqthenaddsuffix] ~[addsuffix] }}}> + storyMinWidthAddLeftConverted={{{ [function[convert.to.result],,] }}} + + result={{{ [compare:number:ltthenaddsuffix] ~[compare:number:gteqthenaddsuffix] ~[addsuffix] }}}> <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text=<>/> - <$let - storyLeftMetric={{$:/state/sidebar/resizing!!story-left-metric}} - storyLeftConverted={{{ [function[convert.to.result],,] }}} - storyLeftMaxConverted={{{ [function[convert.to.result],,] }}} - result={{{ [compare:number:lt[0]then[0]addsuffix] ~[compare:number:gteqthenaddsuffix] ~[addsuffix] }}}> - - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text=<>/> - - - \end @@ -102,12 +122,12 @@ title: $:/core/macros/sidebar-resizer storyLeft={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] }}} storyMinWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] }}} sidebarMaxWidth={{{ [subtractsubtract] }}}> - + <$vars sidebarWidthConverted={{{ [function[convert.to.result],,] }}} sidebarMaxWidthConverted={{{ [function[convert.to.result],,] }}} sidebarMinWidthConverted={{{ [function[convert.to.result],,] }}}> - + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [compare:number:gteqthenaddsuffix] ~[compare:number:ltthenaddsuffix] ~[addsuffix] }}}/>