summaryrefslogtreecommitdiff
path: root/macros/unicodetex/latex/lilyglyphs/tex/core/keyval.inp
blob: 840bbacc366e83f2cf29e52555331dd2db29b84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                        %
%      This file is part of the 'lilyglyphs' LaTeX package.              %
%                                ==========                              %
%                                                                        %
%              https://github.com/openlilylib/lilyglyphs                 %
%               http://www.openlilylib.org/lilyglyphs                    %
%                                                                        %
%  Copyright 2012-2013 Urs Liska and others, ul@openlilylib.org          %
%                                                                        %
%  'lilyglyphs' is free software: you can redistribute it and/or modify  %
%  it under the terms of the LaTeX Project Public License, either        %
%  version 1.3 of this license or (at your option) any later version.    %
%  You may find the latest version of this license at                    %
%               http://www.latex-project.org/lppl.txt                    %
%  more information on                                                   %
%               http://latex-project.org/lppl/                           %
%  and version 1.3 or later is part of all distributions of LaTeX        %
%  version 2005/12/01 or later.                                          %
%                                                                        %
%  This work has the LPPL maintenance status 'maintained'.               %
%  The Current Maintainer of this work is Urs Liska (see above).         %
%                                                                        %
%  This work consists of the files listed in the file 'manifest.txt'     %
%  which can be found in the 'license' directory.                        %
%                                                                        %
%  This program is distributed in the hope that it will be useful,       %
%  but WITHOUT ANY WARRANTY; without even the implied warranty of        %
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  %
%                                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of the lilyglyphs package %
% and defines the key-value functionality     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define keys for keyval options
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%
% Family lilyDesignOptions
%
% This family is used for defining default values for the options at design time
% i.e. when developping predefined commands.
\define@key{lilyDesignOptions}{scale}{\def\lilyDesignOptions@scale{#1}}
\define@key{lilyDesignOptions}{raise}{\def\lilyDesignOptions@raise{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% Family lilyGlobalOptions
%
% This family is used for globally adjusting the option values.
% The user can globally override options at any time
% using the command \lilyOptions.
% This is originally intended for cases where the package defaults
% are not very suitable for the font of the continuous text
\define@key{lilyGlobalOptions}{scale}{\def\lilyGlobalOptions@scale{#1}}
\define@key{lilyGlobalOptions}{raise}{\def\lilyGlobalOptions@raise{#1}}
% Initialize these \defs to 'no adjustment' because the user doesn't have to do that
\def\lilyGlobalOptions@scale{1}
\def\lilyGlobalOptions@raise{0}

% Change any of the global options at any place in the document
% (only options that are present are affected)
\newcommand*{\lilyGlobalOptions}[1]{\setkeys{lilyGlobalOptions}{#1}}

%%%%%%%%%%%%%%%%%%%%%%%
% Family lilyCmdOptions
%
% This family is used for options the end user can use to fine tune the output
% (i.e. within the actual document)
\define@key{lilyCmdOptions}{scale}{\def\lilyCmdOptions@scale{#1}}
\define@key{lilyCmdOptions}{raise}{\def\lilyCmdOptions@raise{#1}}

% Calculate the effective option values from 
% - global defaults,
% - design time defaults and
% - actual user options
%
% Scaling factors are multiplied.
% Raise levels are summed.
\newcommand*{\interpretLilyOptions}[1]{%
	% initialize user arguments (no argument = no change)
	% in order to avoid uninitialized arguments
	\setkeys{lilyCmdOptions}{scale=1,raise=0}%
	% Options that are present override the defaults
	\setkeys{lilyCmdOptions}{#1}%
	% calculate the scaling factor 
	\pgfmathsetmacro{\lilyEffectiveScale}{%
		\lilyGlobalOptions@scale * \lilyCmdOptions@scale * \lilyDesignOptions@scale}%
	% calculate the raise level from the design value and the optional user value
	\pgfmathsetmacro{\lilyEffectiveRaise}{%
		\lilyGlobalOptions@raise + \lilyCmdOptions@raise + \lilyDesignOptions@raise}%
}

\makeatother