Finished function-style macros functionality in Stylesheet
This commit is contained in:
parent
13fe2bb05b
commit
9cfa49d691
3 changed files with 50 additions and 40 deletions
|
|
@ -10,15 +10,22 @@ const $accentColorLight = #87FF5CFF
|
||||||
const $accentColorDark = #3B7500FF
|
const $accentColorDark = #3B7500FF
|
||||||
const $backgroundColor = rgba(30, 30, 30, 255)
|
const $backgroundColor = rgba(30, 30, 30, 255)
|
||||||
const $crimsonAccent = rgba(220, 20, 60, 150)
|
const $crimsonAccent = rgba(220, 20, 60, 150)
|
||||||
|
const $blueAccent = #0075C7
|
||||||
% ===================
|
% ===================
|
||||||
|
|
||||||
|
|
||||||
macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
macro set_focus_border(color, width = 1, show = true) {
|
||||||
focusBorderColor = $color;
|
focusBorderColor = $color;
|
||||||
showFocusBorder = $width2;
|
showFocusBorder = $show;
|
||||||
focusBorderWidth = $width;
|
focusBorderWidth = $width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro set_common_values(_borderColor = $borderColor, _fontSize = 18, _showBorder = true) {
|
||||||
|
borderColor = $_borderColor;
|
||||||
|
fontSize = $_fontSize;
|
||||||
|
showBorder = $_showBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
% ====== Root Widget ======
|
% ====== Root Widget ======
|
||||||
(window) {
|
(window) {
|
||||||
|
|
@ -36,15 +43,14 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== Panel ======
|
% ====== Panel ======
|
||||||
(panel) {
|
(panel) {
|
||||||
|
set_common_values()
|
||||||
backgroundColor = $backgroundColor
|
backgroundColor = $backgroundColor
|
||||||
titleColor = $accentColorDark
|
titleColor = $accentColorDark
|
||||||
titlebarColor = $borderColor
|
titlebarColor = $borderColor
|
||||||
titlebarBorderColor = $borderColor
|
titlebarBorderColor = $borderColor
|
||||||
borderColor = $borderColor
|
|
||||||
borderRadius = 0
|
borderRadius = 0
|
||||||
borderWidth = 2
|
borderWidth = 2
|
||||||
titlebarBorderWidth = 2
|
titlebarBorderWidth = 2
|
||||||
showBorder = true
|
|
||||||
showBackground = true
|
showBackground = true
|
||||||
titlebarType = full
|
titlebarType = full
|
||||||
titlebarHeight = 35
|
titlebarHeight = 35
|
||||||
|
|
@ -61,15 +67,13 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== TabPanel ======
|
% ====== TabPanel ======
|
||||||
(tabPanel) {
|
(tabPanel) {
|
||||||
|
set_common_values()
|
||||||
backgroundColor = $backgroundColor
|
backgroundColor = $backgroundColor
|
||||||
borderColor = $borderColor
|
|
||||||
borderRadius = 0
|
borderRadius = 0
|
||||||
borderWidth = 2
|
borderWidth = 2
|
||||||
showBorder = true
|
|
||||||
showBackground = true
|
showBackground = true
|
||||||
margin = rect(0, 0, 0, 0)
|
margin = rect(0, 0, 0, 0)
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
fontSize = 18
|
|
||||||
|
|
||||||
(tabBar) {
|
(tabBar) {
|
||||||
height = 35.0
|
height = 35.0
|
||||||
|
|
@ -117,18 +121,18 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== CheckBox ======
|
% ====== CheckBox ======
|
||||||
(checkbox) {
|
(checkbox) {
|
||||||
|
set_common_values($borderColor, 18, false)
|
||||||
checkBorderColor = $accentColorDark
|
checkBorderColor = $accentColorDark
|
||||||
checkBoxColor = $accentColor
|
checkBoxColor = $accentColor
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
fontSize = 20
|
|
||||||
borderRadius = 0
|
borderRadius = 0
|
||||||
borderWidth = 0
|
borderWidth = 0
|
||||||
checkBorderRadius = 6
|
checkBorderRadius = 6
|
||||||
checkBorderWidth = 2
|
checkBorderWidth = 2
|
||||||
showBackground = false
|
showBackground = false
|
||||||
showBorder = false
|
padding = rect(4, 4, 4, 4)
|
||||||
padding = rect(15, 15, 15, 15)
|
|
||||||
margin = rect(0, 0, 0, 0)
|
margin = rect(0, 0, 0, 0)
|
||||||
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
(checkbox:hover) {
|
(checkbox:hover) {
|
||||||
checkBorderColor = $accentColorLight
|
checkBorderColor = $accentColorLight
|
||||||
|
|
@ -149,15 +153,15 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== RadioButton ======
|
% ====== RadioButton ======
|
||||||
(radioButton) {
|
(radioButton) {
|
||||||
|
set_common_values($borderColor, 18, false)
|
||||||
innerCircleColor = $accentColorDark
|
innerCircleColor = $accentColorDark
|
||||||
outerCircleColor = $accentColor
|
outerCircleColor = $accentColor
|
||||||
outerCircleBorderWidth = 2
|
outerCircleBorderWidth = 2
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
fontSize = 20
|
|
||||||
showBackground = false
|
showBackground = false
|
||||||
showBorder = false
|
|
||||||
padding = rect(4, 4, 4, 4)
|
padding = rect(4, 4, 4, 4)
|
||||||
margin = rect(0, 0, 0, 0)
|
margin = rect(0, 0, 0, 0)
|
||||||
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
(radioButton:hover) {
|
(radioButton:hover) {
|
||||||
outerCircleColor = $accentColorLight
|
outerCircleColor = $accentColorLight
|
||||||
|
|
@ -178,12 +182,11 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== Label ======
|
% ====== Label ======
|
||||||
(label) {
|
(label) {
|
||||||
|
set_common_values($borderColor, 18, false)
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
fontSize = 20
|
|
||||||
borderRadius = 0
|
borderRadius = 0
|
||||||
borderWidth = 0
|
borderWidth = 0
|
||||||
showBackground = false
|
showBackground = false
|
||||||
showBorder = false
|
|
||||||
padding = rect(15, 15, 15, 15)
|
padding = rect(15, 15, 15, 15)
|
||||||
margin = rect(0, 0, 0, 0)
|
margin = rect(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
@ -193,20 +196,19 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== Button ======
|
% ====== Button ======
|
||||||
(button) {
|
(button) {
|
||||||
|
set_common_values($accentColorDark)
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
backgroundGradient = gradientV($accentColor - $accentColorDark)
|
backgroundGradient = gradientV($accentColor - $accentColorDark)
|
||||||
borderColor = $accentColorDark
|
|
||||||
fontSize = 20
|
|
||||||
borderRadius = 0
|
borderRadius = 0
|
||||||
borderWidth = 1
|
borderWidth = 1
|
||||||
showBackground = false
|
showBackground = false
|
||||||
showBorder = true
|
|
||||||
useBackgroundGradient = true
|
useBackgroundGradient = true
|
||||||
padding = rect(5, 5, 5, 5)
|
padding = rect(5, 5, 5, 5)
|
||||||
margin = rect(0, 0, 0, 0)
|
margin = rect(0, 0, 0, 0)
|
||||||
showIcon = false
|
showIcon = false
|
||||||
(icon) {
|
(icon) {
|
||||||
}
|
}
|
||||||
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
(button:hover) {
|
(button:hover) {
|
||||||
borderColor = $accentColorLight
|
borderColor = $accentColorLight
|
||||||
|
|
@ -229,7 +231,7 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== ProgressBar ======
|
% ====== ProgressBar ======
|
||||||
(progressbar) {
|
(progressbar) {
|
||||||
borderColor = $accentColor
|
set_common_values($accentColor)
|
||||||
borderWidth = 1
|
borderWidth = 1
|
||||||
showDecimal = false
|
showDecimal = false
|
||||||
showText = true
|
showText = true
|
||||||
|
|
@ -257,6 +259,7 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
stepTickHeight = 6.0
|
stepTickHeight = 6.0
|
||||||
stepTickColor = $accentColor
|
stepTickColor = $accentColor
|
||||||
padding = rect(5, 5, 5, 5)
|
padding = rect(5, 5, 5, 5)
|
||||||
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
% ===================
|
% ===================
|
||||||
|
|
||||||
|
|
@ -264,16 +267,15 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== Context Menu ======
|
% ====== Context Menu ======
|
||||||
(context) {
|
(context) {
|
||||||
|
set_common_values()
|
||||||
padding = rect(16, 0, 16, 0)
|
padding = rect(16, 0, 16, 0)
|
||||||
itemSpacing = 6.0
|
itemSpacing = 6.0
|
||||||
fontSize = 18
|
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
selectionColor = $accentColor
|
selectionColor = $accentColor
|
||||||
selectionTextColor = $accentColorLight
|
selectionTextColor = $accentColorLight
|
||||||
separatorLineColor = $borderColor
|
separatorLineColor = $borderColor
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
submenuIndicatorColor = $accentColorDark
|
submenuIndicatorColor = $accentColorDark
|
||||||
borderColor = $borderColor
|
|
||||||
useSelectionGradient = true
|
useSelectionGradient = true
|
||||||
selectionGradient = gradientV($accentColor - $accentColorDark)
|
selectionGradient = gradientV($accentColor - $accentColorDark)
|
||||||
animateOpen = true
|
animateOpen = true
|
||||||
|
|
@ -285,15 +287,13 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== MenuBar ======
|
% ====== MenuBar ======
|
||||||
(menubar) {
|
(menubar) {
|
||||||
|
set_common_values($borderColor, 16, false)
|
||||||
height = 24.0
|
height = 24.0
|
||||||
itemPadding = rect(0, 0, 15, 0)
|
itemPadding = rect(0, 0, 15, 0)
|
||||||
fontSize = 16
|
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
selectionColor = $accentColor
|
selectionColor = $accentColor
|
||||||
selectionTextColor = $accentColorLight
|
selectionTextColor = $accentColorLight
|
||||||
showBorder = false
|
|
||||||
borderColor = $borderColor
|
|
||||||
}
|
}
|
||||||
% =====================
|
% =====================
|
||||||
|
|
||||||
|
|
@ -301,29 +301,26 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== ToolBar ======
|
% ====== ToolBar ======
|
||||||
(toolbar) {
|
(toolbar) {
|
||||||
|
set_common_values()
|
||||||
height = 30.0
|
height = 30.0
|
||||||
fontSize = 16
|
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
selectionColor = $accentColor
|
selectionColor = $accentColor
|
||||||
selectionTextColor = $accentColorLight
|
selectionTextColor = $accentColorLight
|
||||||
borderColor = $borderColor
|
|
||||||
showBorder = true
|
|
||||||
showBackground = true
|
showBackground = true
|
||||||
}
|
}
|
||||||
(@tool_button button) {
|
(@tool_button button) {
|
||||||
fontSize = 18
|
set_common_values(color_black, 18, false)
|
||||||
padding = rect(5, 0, 5, 0)
|
padding = rect(5, 0, 5, 0)
|
||||||
margin = rect(5, 0, 0, 0)
|
margin = rect(5, 0, 0, 0)
|
||||||
showBackground = true
|
showBackground = true
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
useBackgroundGradient = false
|
useBackgroundGradient = false
|
||||||
showBorder = false
|
|
||||||
borderColor = color_black
|
|
||||||
showIcon = true
|
showIcon = true
|
||||||
(icon) {
|
(icon) {
|
||||||
tint = $accentColorLight
|
tint = $accentColorLight
|
||||||
}
|
}
|
||||||
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
(@tool_button button:hover) {
|
(@tool_button button:hover) {
|
||||||
borderColor = $textColor
|
borderColor = $textColor
|
||||||
|
|
@ -346,15 +343,13 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== ComboBox ======
|
% ====== ComboBox ======
|
||||||
(combo) {
|
(combo) {
|
||||||
borderColor = $accentColor
|
set_common_values($accentColor)
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
borderWidth = 1
|
borderWidth = 1
|
||||||
showBackground = true
|
showBackground = true
|
||||||
showBorder = true
|
|
||||||
triangleIndicatorColor = $accentColor
|
triangleIndicatorColor = $accentColor
|
||||||
triangleIndicatorPadding = 8.0
|
triangleIndicatorPadding = 8.0
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
fontSize = 18
|
|
||||||
}
|
}
|
||||||
(combo:hover) {
|
(combo:hover) {
|
||||||
triangleIndicatorColor = $accentColorLight
|
triangleIndicatorColor = $accentColorLight
|
||||||
|
|
@ -370,18 +365,17 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
|
|
||||||
% ====== TreeView ======
|
% ====== TreeView ======
|
||||||
(tree) {
|
(tree) {
|
||||||
|
set_common_values($borderColor, 16, true)
|
||||||
linePadding = rect(5, 5, 0, 0)
|
linePadding = rect(5, 5, 0, 0)
|
||||||
selectionColor = $accentColor
|
selectionColor = $accentColor
|
||||||
selectionTextColor = color_white
|
selectionTextColor = color_white
|
||||||
iconSpacing = 0.0
|
iconSpacing = 0.0
|
||||||
iconInset = 4
|
iconInset = 4
|
||||||
showIcons = true
|
showIcons = true
|
||||||
fontSize = 16
|
|
||||||
textColor = $textColor
|
textColor = $textColor
|
||||||
backgroundColor = $darkColor
|
backgroundColor = $darkColor
|
||||||
backgroundColor2 = $darkColor.lighten(0.06)
|
backgroundColor2 = $darkColor.lighten(0.06)
|
||||||
showAlternatingBackground = true
|
showAlternatingBackground = true
|
||||||
borderColor = $borderColor
|
|
||||||
separatorLineColor = $borderColor
|
separatorLineColor = $borderColor
|
||||||
showSeparatorLine = false
|
showSeparatorLine = false
|
||||||
iconTintColor = $accentColorLight
|
iconTintColor = $accentColorLight
|
||||||
|
|
@ -391,6 +385,6 @@ macro set_focus_border(color, test = "str", width = 1, width2 = false) {
|
||||||
branchLineColor = $textColor
|
branchLineColor = $textColor
|
||||||
showBranchLines = true
|
showBranchLines = true
|
||||||
branchLineThickness = 1.0
|
branchLineThickness = 1.0
|
||||||
set_focus_border(#FF0000.lighten(0.5), "bella balla", 5)
|
set_focus_border($blueAccent)
|
||||||
}
|
}
|
||||||
% ======================
|
% ======================
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ namespace ogfx
|
||||||
setPadding({ 5, 5, 5, 5 });
|
setPadding({ 5, 5, 5, 5 });
|
||||||
setTypeName("ogfx::gui::ComboBox");
|
setTypeName("ogfx::gui::ComboBox");
|
||||||
disableChildren();
|
disableChildren();
|
||||||
|
disableFocus();
|
||||||
setStylesheetCategoryName("combo");
|
setStylesheetCategoryName("combo");
|
||||||
connectSignal(ostd::BuiltinSignals::MouseReleased);
|
connectSignal(ostd::BuiltinSignals::MouseReleased);
|
||||||
connectSignal(ostd::BuiltinSignals::MouseMoved);
|
connectSignal(ostd::BuiltinSignals::MouseMoved);
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ namespace ostd
|
||||||
macroCode.trim();
|
macroCode.trim();
|
||||||
if (!parseMacro(macroCode))
|
if (!parseMacro(macroCode))
|
||||||
l_warn("Invalid macro");
|
l_warn("Invalid macro");
|
||||||
|
std::cout << macroCode << "\n";
|
||||||
macroCode = "";
|
macroCode = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +348,7 @@ namespace ostd
|
||||||
for (const auto& m : m_macros)
|
for (const auto& m : m_macros)
|
||||||
{
|
{
|
||||||
stdvec<String> matches;
|
stdvec<String> matches;
|
||||||
stdvec<u32> indices = value.regexFind("^(.+\\.)?" + m.first + "[ \\t]*\\(", false, &matches);
|
stdvec<u32> indices = value.regexFind("^(.+\\.)?" + m.first + "\\b[ \\t]*\\(", false, &matches);
|
||||||
|
|
||||||
if (!indices.empty())
|
if (!indices.empty())
|
||||||
{
|
{
|
||||||
|
|
@ -942,10 +943,24 @@ namespace ostd
|
||||||
auto l_splitByTopLevelComma = [](const String& call) -> stdvec<String> {
|
auto l_splitByTopLevelComma = [](const String& call) -> stdvec<String> {
|
||||||
stdvec<String> callArgs;
|
stdvec<String> callArgs;
|
||||||
i32 openP = 0;
|
i32 openP = 0;
|
||||||
|
bool inStr = false;
|
||||||
String arg = "";
|
String arg = "";
|
||||||
for (i32 i = 0; i < call.len(); i++)
|
for (i32 i = 0; i < call.len(); i++)
|
||||||
{
|
{
|
||||||
char c = call[i];
|
char c = call[i];
|
||||||
|
if (inStr)
|
||||||
|
{
|
||||||
|
arg += c;
|
||||||
|
if (c == '"')
|
||||||
|
inStr = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == '"')
|
||||||
|
{
|
||||||
|
arg += c;
|
||||||
|
inStr = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
openP++;
|
openP++;
|
||||||
if (c == ')')
|
if (c == ')')
|
||||||
|
|
@ -962,6 +977,8 @@ namespace ostd
|
||||||
}
|
}
|
||||||
arg += c;
|
arg += c;
|
||||||
}
|
}
|
||||||
|
if (inStr) // unterminated string
|
||||||
|
return {};
|
||||||
if (arg.trim() == "")
|
if (arg.trim() == "")
|
||||||
return {};
|
return {};
|
||||||
callArgs.push_back(arg);
|
callArgs.push_back(arg);
|
||||||
|
|
@ -994,21 +1011,19 @@ namespace ostd
|
||||||
i32 argIndex = 0;
|
i32 argIndex = 0;
|
||||||
for (const auto&[_pname, _pval] : macro.params)
|
for (const auto&[_pname, _pval] : macro.params)
|
||||||
{
|
{
|
||||||
String pname = l_escapeRegex(_pname);
|
String pname = l_escapeRegex(_pname) + "\\b";
|
||||||
String pval = "";
|
String pval = "";
|
||||||
if (argIndex < callArgs.size())
|
if (argIndex < callArgs.size())
|
||||||
{
|
{
|
||||||
pval = callArgs[argIndex++].new_replaceAll("$", "$$");
|
pval = callArgs[argIndex++].new_replaceAll("$", "$$");
|
||||||
line.regexReplace(pname, pval);
|
line.regexReplace(pname, pval);
|
||||||
std::cout << pname << " " << callArgs[argIndex - 1] << "\n " << line << "\n";
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pval == MacroParamDefault)
|
if (_pval == MacroParamDefault)
|
||||||
return {};
|
return {};
|
||||||
pval = _pval.new_replaceAll("$", "$$");
|
pval = _pval.new_replaceAll("$", "$$");
|
||||||
line.regexReplace(pname, pval);
|
line.regexReplace(pname, pval);
|
||||||
}
|
}
|
||||||
std::cout << "\n";
|
|
||||||
lines.push_back(line);
|
lines.push_back(line);
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue