1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-10 09:20:26 +00:00

make it work with em too

This commit is contained in:
BurningTreeC 2024-10-06 13:57:19 +02:00
parent 5d22139187
commit c1499896f7

View File

@ -8,6 +8,7 @@ title: $:/core/macros/sidebar-resizer
\function is.in.value(value) [<value>removesuffix[in]] \function is.in.value(value) [<value>removesuffix[in]]
\function is.pc.value(value) [<value>removesuffix[pc]] \function is.pc.value(value) [<value>removesuffix[pc]]
\function is.pt.value(value) [<value>removesuffix[pt]] \function is.pt.value(value) [<value>removesuffix[pt]]
\function is.em.value(value) [<value>removesuffix[em]]
\function convert.to.percentage(value) [<value>divide<widgetNodeWidth>multiply[100]] \function convert.to.percentage(value) [<value>divide<widgetNodeWidth>multiply[100]]
\function convert.to.cm(value) [<value>divide[37.8]] \function convert.to.cm(value) [<value>divide[37.8]]
@ -16,6 +17,7 @@ title: $:/core/macros/sidebar-resizer
\function convert.to.in(value) [<value>divide[96]] \function convert.to.in(value) [<value>divide[96]]
\function convert.to.pc(value) [convert.to.in<value>multiply[6]] \function convert.to.pc(value) [convert.to.in<value>multiply[6]]
\function convert.to.pt(value) [convert.to.in<value>multiply[72]] \function convert.to.pt(value) [convert.to.in<value>multiply[72]]
\function convert.to.em(value) [<value>divide{$:/themes/tiddlywiki/vanilla/metrics/fontsize}]
\function convert.to.percentage.value() [convert.to.percentage<value>] \function convert.to.percentage.value() [convert.to.percentage<value>]
\function convert.to.cm.value() [convert.to.cm<value>] \function convert.to.cm.value() [convert.to.cm<value>]
@ -24,12 +26,13 @@ title: $:/core/macros/sidebar-resizer
\function convert.to.in.value() [convert.to.in<value>] \function convert.to.in.value() [convert.to.in<value>]
\function convert.to.pc.value() [convert.to.pc<value>] \function convert.to.pc.value() [convert.to.pc<value>]
\function convert.to.pt.value() [convert.to.pt<value>] \function convert.to.pt.value() [convert.to.pt<value>]
\function convert.to.em.value() [convert.to.em<value>]
\function convert.to.pixels(value) [is.pixel.value<value>] [is.percentage.value<value>multiply<widgetNodeWidth>divide[100]] [is.cm.value<value>multiply[37.8]] [is.mm.value<value>multiply[37.8]divide[10]] [is.Q.value<value>multiply[37.8]divide[40]] [is.in.value<value>multiply[96]] [is.pc.value<value>multiply[96]divide[6]] [is.pt.value<value>multiply[96]divide[72]] \function convert.to.pixels(value) [is.pixel.value<value>] [is.percentage.value<value>multiply<widgetNodeWidth>divide[100]] [is.cm.value<value>multiply[37.8]] [is.mm.value<value>multiply[37.8]divide[10]] [is.Q.value<value>multiply[37.8]divide[40]] [is.in.value<value>multiply[96]] [is.pc.value<value>multiply[96]divide[6]] [is.pt.value<value>multiply[96]divide[72]] [is.em.value<value>multiply{$:/themes/tiddlywiki/vanilla/metrics/fontsize}]
\function convert.to.result(value,suffix) [<suffix>match[px]then<value>] [<suffix>match[%]then<convert.to.percentage.value>] [<suffix>match[cm]then<convert.to.cm.value>] [<suffix>match[mm]then<convert.to.mm.value>] [<suffix>match[Q]then<convert.to.Q.value>] [<suffix>match[in]then<convert.to.in.value>] [<suffix>match[pc]then<convert.to.pc.value>] [<suffix>match[pt]then<convert.to.pt.value>] \function convert.to.result(value,suffix) [<suffix>match[px]then<value>] [<suffix>match[%]then<convert.to.percentage.value>] [<suffix>match[cm]then<convert.to.cm.value>] [<suffix>match[mm]then<convert.to.mm.value>] [<suffix>match[Q]then<convert.to.Q.value>] [<suffix>match[in]then<convert.to.in.value>] [<suffix>match[pc]then<convert.to.pc.value>] [<suffix>match[pt]then<convert.to.pt.value>] [<suffix>match[em]then<convert.to.em.value>]
\function get.value.metric(value) [<value>suffix[px]then[px]] ~[<value>suffix[%]then[%]] ~[<value>suffix[cm]then[cm]] ~[<value>suffix[mm]then[mm]] ~[<value>suffix[Q]then[Q]] ~[<value>suffix[in]then[in]] ~[<value>suffix[pc]then[pc]] ~[<value>suffix[pt]then[pt]] \function get.value.metric(value) [<value>suffix[px]then[px]] ~[<value>suffix[%]then[%]] ~[<value>suffix[cm]then[cm]] ~[<value>suffix[mm]then[mm]] ~[<value>suffix[Q]then[Q]] ~[<value>suffix[in]then[in]] ~[<value>suffix[pc]then[pc]] ~[<value>suffix[pt]then[pt]] ~[<value>suffix[em]then[em]]
\procedure sidebar-resizer-pointerdown-actions() \procedure sidebar-resizer-pointerdown-actions()
<%if [[$:/state/sidebar/resizing]is[missing]then<event-mousebutton>match[left]] %> <%if [[$:/state/sidebar/resizing]is[missing]then<event-mousebutton>match[left]] %>
@ -72,7 +75,7 @@ title: $:/core/macros/sidebar-resizer
\procedure set-sidebarwidth-actions() \procedure set-sidebarwidth-actions()
<$let sidebarWidthMetric={{$:/state/sidebar/resizing!!sidebar-width-metric}} sidebarMinWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}} storyLeftConverted={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] }}} storyMinWidthConverted={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] }}} sidebarMaxWidth={{{ [<widgetNodeWidth>subtract<storyLeftConverted>subtract<storyMinWidthConverted>] }}}> <$let sidebarWidthMetric={{$:/state/sidebar/resizing!!sidebar-width-metric}} sidebarMinWidth={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}} storyLeftConverted={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] }}} storyMinWidthConverted={{{ [convert.to.pixels{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}] }}} sidebarMaxWidth={{{ [<widgetNodeWidth>subtract<storyLeftConverted>subtract<storyMinWidthConverted>] }}}>
<$vars sidebarWidthConverted={{{ [function[convert.to.result],<sidebarWidth>,<sidebarWidthMetric>] }}} sidebarMaxWidthConverted={{{ [function[convert.to.result],<sidebarMaxWidth>,<sidebarWidthMetric>] }}} sidebarMinWidthConverted={{{ [function[convert.to.result],<sidebarMinWidth>,<sidebarWidthMetric>] }}}> <$vars sidebarWidthConverted={{{ [function[convert.to.result],<sidebarWidth>,<sidebarWidthMetric>] }}} sidebarMaxWidthConverted={{{ [function[convert.to.result],<sidebarMaxWidth>,<sidebarWidthMetric>] }}} sidebarMinWidthConverted={{{ [function[convert.to.result],<sidebarMinWidth>,<sidebarWidthMetric>] }}}>
<$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidthConverted>compare:number:gteq<sidebarMaxWidthConverted>then<sidebarMaxWidthConverted>addsuffix<sidebarWidthMetric>] [<sidebarWidthConverted>compare:number:lt<sidebarMinWidthConverted>then<sidebarMinWidthConverted>addsuffix<sidebarWidthMetric>] ~[<sidebarWidthConverted>addsuffix<sidebarWidthMetric>] }}}/> <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [<sidebarWidthConverted>compare:number:gteq<sidebarMaxWidthConverted>then<sidebarMaxWidthConverted>addsuffix<sidebarWidthMetric>] ~[<sidebarWidthConverted>compare:number:lt<sidebarMinWidthConverted>then<sidebarMinWidthConverted>addsuffix<sidebarWidthMetric>] ~[<sidebarWidthConverted>addsuffix<sidebarWidthMetric>] }}}/>
</$vars> </$vars>
</$let> </$let>
\end \end