feat: cleaned up and created 'ceramic/'
This commit is contained in:
parent
2d669e6411
commit
f32494a29f
204
.clang-format
Normal file
204
.clang-format
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
---
|
||||||
|
BasedOnStyle: Microsoft
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignConsecutiveBitFields: None
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: None
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BreakAfterAttributes: Never
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakArrays: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: false
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
CommentPragmas: "^ IWYU pragma:"
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: ^"(llvm|llvm-c|clang|clang-c)/
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: ^(<|"(gtest|gmock|isl|json)/)
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: .*
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: (Test)?$
|
||||||
|
IncludeIsMainSourceRegex: ""
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: true
|
||||||
|
InsertNewlineAtEOF: true
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
Language: Cpp
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ""
|
||||||
|
MacroBlockEnd: ""
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PPIndentWidth: -1
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||||
|
PointerAlignment: Right
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterIfMacros: false
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Always
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
UseCRLF: false
|
||||||
|
|
@ -1,24 +1,13 @@
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "style.h"
|
#include "ceramic/style.h"
|
||||||
#include "elements.h"
|
#include "ceramic/elements.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
|
|
||||||
namespace application {
|
namespace application {
|
||||||
static void SampleHeader() {
|
|
||||||
elements::Header(CLAY_STRING("Left Panel"), 2, {
|
|
||||||
.textColor = style::color::white
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Clay_RenderCommandArray RenderApplication() {
|
Clay_RenderCommandArray RenderApplication() {
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY(CLAY_ID("OuterContainer"), style::Window()) {
|
CLAY(CLAY_ID("OuterContainer"), style::Window()) {
|
||||||
CLAY_AUTO_ID(style::PanelContainer(0, {
|
|
||||||
.layout = { .sizing = { CLAY_SIZING_PERCENT(0.15), CLAY_SIZING_GROW() } }
|
|
||||||
})) {
|
|
||||||
SampleHeader();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Clay_EndLayout();
|
return Clay_EndLayout();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intpt
|
||||||
}) {
|
}) {
|
||||||
Clay_OnHover(onHovered, onHoveredData);
|
Clay_OnHover(onHovered, onHoveredData);
|
||||||
elements::Body(text, {
|
elements::Body(text, {
|
||||||
.textColor = style::TextColor(0),
|
.textColor = style::textColor,
|
||||||
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ void Toggle(Clay_String label, Clay_Color selected, bool &state) {
|
||||||
},
|
},
|
||||||
}) { }
|
}) { }
|
||||||
Body(label, {
|
Body(label, {
|
||||||
.textColor = style::TextColor(0)
|
.textColor = style::textColor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,13 +2,14 @@
|
||||||
#define ELEMENTS_H
|
#define ELEMENTS_H
|
||||||
|
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
|
#include "style.h"
|
||||||
|
|
||||||
namespace elements {
|
namespace elements {
|
||||||
typedef void(*OnHoveredFn)(Clay_ElementId element, Clay_PointerData pointer, intptr_t data);
|
typedef void(*OnHoveredFn)(Clay_ElementId element, Clay_PointerData pointer, intptr_t data);
|
||||||
void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData = 0);
|
void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData = 0);
|
||||||
void Toggle(Clay_String label, Clay_Color selected, bool &state);
|
void Toggle(Clay_String label, Clay_Color selected, bool &state);
|
||||||
void Body(Clay_String string, Clay_TextElementConfig baseCfg = {});
|
void Body(Clay_String string, Clay_TextElementConfig baseCfg = {.textColor = style::textColor});
|
||||||
void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg = {});
|
void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg = {.textColor = style::textColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !ELEMENTS_H
|
#endif // !ELEMENTS_H
|
||||||
28
src/ceramic/resources.cpp
Normal file
28
src/ceramic/resources.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "resources.h"
|
||||||
|
#include "style.h"
|
||||||
|
#include <clay/clay.h>
|
||||||
|
#include <SDL3/SDL_log.h>
|
||||||
|
#include <SDL3/SDL_render.h>
|
||||||
|
#include <SDL3_image/SDL_image.h>
|
||||||
|
|
||||||
|
namespace resources {
|
||||||
|
TTF_Font *defaultFont[FONT_MAX];
|
||||||
|
TTF_TextEngine *textEngine = nullptr;
|
||||||
|
|
||||||
|
void SetDefaultFont(char const *path) {
|
||||||
|
defaultFont[FONT_DEFAULT] = TTF_OpenFont(path, style::baseFontSize * 5);
|
||||||
|
if (defaultFont[FONT_DEFAULT] == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default font '%s': %s", path, SDL_GetError());
|
||||||
|
exit(6);
|
||||||
|
}
|
||||||
|
TTF_SetFontHinting(defaultFont[FONT_DEFAULT], TTF_HINTING_LIGHT_SUBPIXEL);
|
||||||
|
defaultFont[FONT_BOLD] = TTF_OpenFont(path, style::baseFontSize * 5);
|
||||||
|
if (defaultFont[FONT_BOLD] == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default bold font '%s': %s", path, SDL_GetError());
|
||||||
|
exit(6);
|
||||||
|
}
|
||||||
|
TTF_SetFontHinting(defaultFont[FONT_BOLD], TTF_HINTING_LIGHT_SUBPIXEL);
|
||||||
|
TTF_SetFontStyle(defaultFont[FONT_BOLD], TTF_STYLE_BOLD);
|
||||||
|
SDL_Log("SetDefaultFont: Success");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,9 +11,9 @@ enum Font {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TTF_TextEngine *textEngine;
|
extern TTF_TextEngine *textEngine;
|
||||||
extern TTF_Font *fonts[FONT_MAX];
|
extern TTF_Font *defaultFont[FONT_MAX];
|
||||||
|
|
||||||
void LoadResources();
|
void SetDefaultFont(char const *path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !RESOURCES_H
|
#endif // !RESOURCES_H
|
||||||
|
|
@ -1,22 +1,23 @@
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
|
#include "SDL3/SDL_stdinc.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
|
Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
|
||||||
baseCfg.border = {
|
baseCfg.border = {
|
||||||
PanelBorder(depth),
|
.color = panelBorder,
|
||||||
CLAY_BORDER_ALL(2)
|
.width = CLAY_BORDER_ALL(2)
|
||||||
};
|
};
|
||||||
baseCfg.cornerRadius = defaultRadiusAll;
|
baseCfg.cornerRadius = defaultRadiusAll;
|
||||||
return baseCfg;
|
return baseCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
|
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
|
||||||
baseCfg.backgroundColor = PanelBackground(depth);
|
baseCfg.backgroundColor = panelBackground;
|
||||||
baseCfg.border = {
|
baseCfg.border = {
|
||||||
PanelBorder(depth),
|
.color = panelBorder,
|
||||||
CLAY_BORDER_OUTSIDE(2)
|
.width = CLAY_BORDER_OUTSIDE(2)
|
||||||
};
|
};
|
||||||
baseCfg.cornerRadius = defaultRadiusAll;
|
baseCfg.cornerRadius = defaultRadiusAll;
|
||||||
baseCfg.layout.padding = CLAY_PADDING_ALL(8);
|
baseCfg.layout.padding = CLAY_PADDING_ALL(8);
|
||||||
|
|
@ -39,49 +40,23 @@ Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaratio
|
||||||
return baseCfg;
|
return baseCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_Color PanelBackground(size_t idx) {
|
|
||||||
return {
|
|
||||||
255*panelBackground[idx],
|
|
||||||
255*panelBackground[idx],
|
|
||||||
255*panelBackground[idx],
|
|
||||||
255
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Clay_Color PanelBorder(size_t idx) {
|
|
||||||
return {
|
|
||||||
255*panelBorder[idx],
|
|
||||||
255*panelBorder[idx],
|
|
||||||
255*panelBorder[idx],
|
|
||||||
255
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Clay_Color TextColor(size_t idx) {
|
|
||||||
return {
|
|
||||||
255*textColorsP[idx],
|
|
||||||
255*textColorsP[idx],
|
|
||||||
255*textColorsP[idx],
|
|
||||||
255
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Clay_ElementDeclaration Window() {
|
Clay_ElementDeclaration Window() {
|
||||||
return {
|
return {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
||||||
.padding = CLAY_PADDING_ALL(0),
|
.padding = CLAY_PADDING_ALL(windowPadding),
|
||||||
.childGap = 0,
|
.childGap = 0,
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||||
},
|
},
|
||||||
|
.backgroundColor = windowColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_Color ToHoveredColor(Clay_Color color) {
|
Clay_Color ToHoveredColor(Clay_Color color) {
|
||||||
float avg = (color.r + color.g + color.b) / 3.f;
|
float avg = (color.r + color.g + color.b) / 3.f;
|
||||||
color.r = (color.r - avg) * 0.8f + avg - 30;
|
color.r = SDL_clamp((color.r - avg) * 0.8f + avg - 30, 0., 1.);
|
||||||
color.g = (color.g - avg) * 0.8f + avg - 30;
|
color.g = SDL_clamp((color.g - avg) * 0.8f + avg - 30, 0., 1.);
|
||||||
color.b = (color.b - avg) * 0.8f + avg - 30;
|
color.b = SDL_clamp((color.b - avg) * 0.8f + avg - 30, 0., 1.);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,8 @@ namespace style {
|
||||||
// WINDOW STYLE
|
// WINDOW STYLE
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
||||||
constexpr uint16_t windowPadding{ 10 };
|
constexpr uint16_t windowPadding{1};
|
||||||
|
constexpr Clay_Color windowColor{20, 20, 20, 255};
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// CONTAINER STYLE
|
// CONTAINER STYLE
|
||||||
|
|
@ -18,12 +19,8 @@ constexpr uint16_t windowPadding{ 10 };
|
||||||
constexpr uint16_t containerGap{10};
|
constexpr uint16_t containerGap{10};
|
||||||
constexpr double defaultRadius{5.0};
|
constexpr double defaultRadius{5.0};
|
||||||
|
|
||||||
constexpr float panelBackground[] = {
|
constexpr Clay_Color panelBackground{ 0,0,0,0 };
|
||||||
.4f, .3f, .2f
|
constexpr Clay_Color panelBorder { 150, 150, 150, 150 };
|
||||||
};
|
|
||||||
constexpr float panelBorder[] = {
|
|
||||||
.5f, .4f, .3f
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr Clay_Padding panelPadding = {
|
constexpr Clay_Padding panelPadding = {
|
||||||
24, 24,
|
24, 24,
|
||||||
|
|
@ -34,8 +31,6 @@ Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration base
|
||||||
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
||||||
Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
||||||
Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg);
|
||||||
Clay_Color PanelBackground(size_t idx);
|
|
||||||
Clay_Color PanelBorder(size_t idx);
|
|
||||||
Clay_ElementDeclaration Window();
|
Clay_ElementDeclaration Window();
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
@ -44,16 +39,10 @@ Clay_ElementDeclaration Window();
|
||||||
|
|
||||||
constexpr float paragraphGap = 10;
|
constexpr float paragraphGap = 10;
|
||||||
constexpr uint16_t baseFontSize = 16;
|
constexpr uint16_t baseFontSize = 16;
|
||||||
constexpr float textColorsP[] = {
|
|
||||||
0.9f, 0.9f, 0.9f
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint16_t headerSizes[] = {
|
constexpr uint16_t headerSizes[] = {64, 32, 28, 16};
|
||||||
64, 32,
|
|
||||||
28, 16
|
|
||||||
};
|
|
||||||
|
|
||||||
Clay_Color TextColor(size_t idx);
|
constexpr Clay_Color textColor{170, 170, 170, 255};
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// BUTTONS
|
// BUTTONS
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "resources.h"
|
#include "ceramic/resources.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_error.h>
|
#include <SDL3/SDL_error.h>
|
||||||
#include <SDL3/SDL_events.h>
|
#include <SDL3/SDL_events.h>
|
||||||
|
|
@ -90,7 +90,7 @@ void InitClay() {
|
||||||
clayMemorySize = Clay_MinMemorySize();
|
clayMemorySize = Clay_MinMemorySize();
|
||||||
clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize));
|
clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize));
|
||||||
Clay_Initialize(clayPrimaryArena, { (float)screenWidth, (float)screenHeight }, { HandleClayErrors });
|
Clay_Initialize(clayPrimaryArena, { (float)screenWidth, (float)screenHeight }, { HandleClayErrors });
|
||||||
Clay_SetMeasureTextFunction(MeasureText, resources::fonts);
|
Clay_SetMeasureTextFunction(MeasureText, resources::defaultFont);
|
||||||
Clay_SetLayoutDimensions({ (float)screenWidth, (float)screenHeight });
|
Clay_SetLayoutDimensions({ (float)screenWidth, (float)screenHeight });
|
||||||
float x{ 0 }, y{ 0 };
|
float x{ 0 }, y{ 0 };
|
||||||
SDL_GetMouseState(&x, &y);
|
SDL_GetMouseState(&x, &y);
|
||||||
|
|
@ -99,10 +99,10 @@ void InitClay() {
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
InitSDL();
|
InitSDL();
|
||||||
resources::LoadResources();
|
resources::SetDefaultFont("assets/AdwaitaSans-Regular.ttf");
|
||||||
LogOutputResolution();
|
LogOutputResolution();
|
||||||
InitClay();
|
InitClay();
|
||||||
backendData = { renderer, resources::textEngine, resources::fonts };
|
backendData = { renderer, resources::textEngine, resources::defaultFont };
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
uint64_t startFrameTime = SDL_GetTicksNS();
|
uint64_t startFrameTime = SDL_GetTicksNS();
|
||||||
double deltaTime = 0.0;
|
double deltaTime = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
#include "resources.h"
|
|
||||||
#include "style.h"
|
|
||||||
#include <clay/clay.h>
|
|
||||||
#include <SDL3/SDL_log.h>
|
|
||||||
#include <SDL3/SDL_render.h>
|
|
||||||
#include <SDL3_image/SDL_image.h>
|
|
||||||
|
|
||||||
namespace resources {
|
|
||||||
TTF_Font *fonts[FONT_MAX];
|
|
||||||
TTF_TextEngine *textEngine = nullptr;
|
|
||||||
|
|
||||||
static inline void LoadFonts() {
|
|
||||||
fonts[FONT_DEFAULT] = TTF_OpenFont("assets/AdwaitaSans-Regular.ttf", style::baseFontSize * 5);
|
|
||||||
if (fonts[FONT_DEFAULT] == nullptr) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load adwaita sans: %s", SDL_GetError());
|
|
||||||
exit(6);
|
|
||||||
}
|
|
||||||
TTF_SetFontHinting(fonts[FONT_DEFAULT], TTF_HINTING_LIGHT_SUBPIXEL);
|
|
||||||
fonts[FONT_BOLD] = TTF_OpenFont("assets/AdwaitaSans-Regular.ttf", style::baseFontSize * 5);
|
|
||||||
if (fonts[FONT_BOLD] == nullptr) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load adwaita sans bold: %s", SDL_GetError());
|
|
||||||
exit(6);
|
|
||||||
}
|
|
||||||
TTF_SetFontHinting(fonts[FONT_BOLD], TTF_HINTING_LIGHT_SUBPIXEL);
|
|
||||||
TTF_SetFontStyle(fonts[FONT_BOLD], TTF_STYLE_BOLD);
|
|
||||||
SDL_Log("LoadFonts: Success");
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadResources() {
|
|
||||||
LoadFonts();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#include "thread_pool.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <thread>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace threading {
|
|
||||||
ThreadPool::ThreadPool() {
|
|
||||||
size_t const thread_count{ std::max(std::thread::hardware_concurrency() - 1, 1u) };
|
|
||||||
this->threads.reserve(thread_count);
|
|
||||||
for (size_t i{ 0 }; i < thread_count; ++i) {
|
|
||||||
this->threads.emplace_back(std::bind(&ThreadPool::ThreadFn, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadPool::~ThreadPool() {
|
|
||||||
{ std::scoped_lock lock{ this->lock };
|
|
||||||
this->shutdown = true;
|
|
||||||
this->threadNotifier.notify_all();
|
|
||||||
}
|
|
||||||
for (std::thread &thread : this->threads) {
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ThreadPool::GetThreadCount() {
|
|
||||||
return this->threads.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadPool::ScheduleTask(TaskFunc fn) {
|
|
||||||
std::scoped_lock lock{ this->lock };
|
|
||||||
this->taskQueue.emplace(std::move(fn));
|
|
||||||
this->threadNotifier.notify_one();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadPool::ThreadFn() {
|
|
||||||
TaskFunc function;
|
|
||||||
for(;;) {
|
|
||||||
{ std::unique_lock<std::mutex> lock{ this->lock };
|
|
||||||
while (!this->shutdown && this->taskQueue.empty()) {
|
|
||||||
this->threadNotifier.wait(lock);
|
|
||||||
}
|
|
||||||
if (this->taskQueue.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
function = std::move(this->taskQueue.front());
|
|
||||||
this->taskQueue.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
function.operator()();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadPool tasks{};
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
#ifndef THREAD_POOL_H
|
|
||||||
#define THREAD_POOL_H
|
|
||||||
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <functional>
|
|
||||||
#include <mutex>
|
|
||||||
#include <queue>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace threading {
|
|
||||||
typedef std::function<void()> TaskFunc;
|
|
||||||
|
|
||||||
class ThreadPool {
|
|
||||||
public: ThreadPool();
|
|
||||||
~ThreadPool();
|
|
||||||
void ScheduleTask(TaskFunc jobs);
|
|
||||||
size_t GetThreadCount();
|
|
||||||
private:
|
|
||||||
void ThreadFn();
|
|
||||||
std::queue<TaskFunc> taskQueue{};
|
|
||||||
std::vector<std::thread> threads{};
|
|
||||||
std::mutex lock{};
|
|
||||||
std::condition_variable threadNotifier{};
|
|
||||||
bool shutdown{ false };
|
|
||||||
};
|
|
||||||
|
|
||||||
extern ThreadPool tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !THREAD_POOL_H
|
|
||||||
Loading…
Reference in a new issue