Compare commits
No commits in common. "b0d5226915d18fdccda10ac17e0f6ad96bea48ca" and "2810e06b3ede86cbb4b9666492d3b0c3c3688ae3" have entirely different histories.
b0d5226915
...
2810e06b3e
17 changed files with 29 additions and 31454 deletions
206
.clang-format
206
.clang-format
|
|
@ -1,55 +1,21 @@
|
||||||
---
|
# Generated from CLion C/C++ Code Style settings
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
AccessModifierOffset: -2
|
AccessModifierOffset: -2
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignArrayOfStructures: Left
|
AlignConsecutiveAssignments: None
|
||||||
AlignConsecutiveAssignments:
|
|
||||||
Enabled: false
|
|
||||||
AcrossEmptyLines: false
|
|
||||||
AcrossComments: false
|
|
||||||
AlignCompound: false
|
|
||||||
PadOperators: true
|
|
||||||
AlignConsecutiveBitFields:
|
|
||||||
Enabled: false
|
|
||||||
AcrossEmptyLines: false
|
|
||||||
AcrossComments: false
|
|
||||||
AlignCompound: false
|
|
||||||
PadOperators: false
|
|
||||||
AlignConsecutiveDeclarations:
|
|
||||||
Enabled: false
|
|
||||||
AcrossEmptyLines: false
|
|
||||||
AcrossComments: false
|
|
||||||
AlignCompound: false
|
|
||||||
PadOperators: false
|
|
||||||
AlignConsecutiveMacros:
|
|
||||||
Enabled: true
|
|
||||||
AcrossEmptyLines: false
|
|
||||||
AcrossComments: false
|
|
||||||
AlignCompound: false
|
|
||||||
PadOperators: false
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AlignOperands: Align
|
AlignOperands: Align
|
||||||
AlignTrailingComments:
|
AllowAllArgumentsOnNextLine: false
|
||||||
Kind: Always
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
OverEmptyLines: 0
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowAllArgumentsOnNextLine: true
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
|
||||||
AllowShortBlocksOnASingleLine: Always
|
AllowShortBlocksOnASingleLine: Always
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortEnumsOnASingleLine: true
|
|
||||||
AllowShortFunctionsOnASingleLine: All
|
AllowShortFunctionsOnASingleLine: All
|
||||||
AllowShortIfStatementsOnASingleLine: Never
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
AllowShortLambdasOnASingleLine: All
|
AllowShortLambdasOnASingleLine: All
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: true
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
AttributeMacros:
|
BreakBeforeBraces: Custom
|
||||||
- __capability
|
|
||||||
BinPackArguments: true
|
|
||||||
BinPackParameters: true
|
|
||||||
BitFieldColonSpacing: Both
|
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterCaseLabel: false
|
AfterCaseLabel: false
|
||||||
AfterClass: false
|
AfterClass: false
|
||||||
|
|
@ -57,172 +23,44 @@ BraceWrapping:
|
||||||
AfterEnum: false
|
AfterEnum: false
|
||||||
AfterFunction: false
|
AfterFunction: false
|
||||||
AfterNamespace: false
|
AfterNamespace: false
|
||||||
AfterObjCDeclaration: false
|
|
||||||
AfterStruct: false
|
|
||||||
AfterUnion: false
|
AfterUnion: false
|
||||||
AfterExternBlock: false
|
|
||||||
BeforeCatch: false
|
BeforeCatch: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
BeforeLambdaBody: false
|
|
||||||
BeforeWhile: false
|
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
SplitEmptyFunction: true
|
SplitEmptyFunction: false
|
||||||
SplitEmptyRecord: true
|
SplitEmptyRecord: true
|
||||||
SplitEmptyNamespace: true
|
|
||||||
BreakAfterAttributes: Never
|
|
||||||
BreakAfterJavaFieldAnnotations: false
|
|
||||||
BreakArrays: true
|
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Attach
|
|
||||||
BreakBeforeConceptDeclarations: Always
|
|
||||||
BreakBeforeInlineASMColon: OnlyMultiline
|
|
||||||
BreakBeforeTernaryOperators: true
|
BreakBeforeTernaryOperators: true
|
||||||
BreakConstructorInitializers: BeforeColon
|
BreakConstructorInitializers: BeforeColon
|
||||||
BreakInheritanceList: BeforeColon
|
BreakInheritanceList: BeforeColon
|
||||||
BreakStringLiterals: true
|
ColumnLimit: 0
|
||||||
ColumnLimit: 180
|
|
||||||
CommentPragmas: "^ IWYU pragma:"
|
|
||||||
CompactNamespaces: false
|
CompactNamespaces: false
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 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: true
|
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentExternBlock: Indent
|
IndentPPDirectives: None
|
||||||
IndentGotoLabels: true
|
|
||||||
IndentPPDirectives: BeforeHash
|
|
||||||
IndentRequiresClause: true
|
|
||||||
IndentWidth: 2
|
IndentWidth: 2
|
||||||
IndentWrappedFunctionNames: false
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
InsertBraces: true
|
MaxEmptyLinesToKeep: 2
|
||||||
InsertNewlineAtEOF: true
|
|
||||||
InsertTrailingCommas: None
|
|
||||||
IntegerLiteralSeparator:
|
|
||||||
Binary: 0
|
|
||||||
BinaryMinDigits: 0
|
|
||||||
Decimal: 0
|
|
||||||
DecimalMinDigits: 0
|
|
||||||
Hex: 0
|
|
||||||
HexMinDigits: 0
|
|
||||||
JavaScriptQuotes: Leave
|
|
||||||
JavaScriptWrapImports: true
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
||||||
LambdaBodyIndentation: Signature
|
|
||||||
Language: Cpp
|
|
||||||
LineEnding: DeriveLF
|
|
||||||
MacroBlockBegin: ""
|
|
||||||
MacroBlockEnd: ""
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
ObjCBinPackProtocolList: Auto
|
|
||||||
ObjCBlockIndentWidth: 2
|
|
||||||
ObjCBreakBeforeNestedBlockParam: true
|
|
||||||
ObjCSpaceAfterProperty: false
|
ObjCSpaceAfterProperty: false
|
||||||
ObjCSpaceBeforeProtocolList: true
|
ObjCSpaceBeforeProtocolList: true
|
||||||
PPIndentWidth: -1
|
|
||||||
PackConstructorInitializers: CurrentLine
|
|
||||||
PenaltyBreakAssignment: 2
|
|
||||||
PenaltyBreakBeforeFirstCallParameter: 19
|
|
||||||
PenaltyBreakComment: 300
|
|
||||||
PenaltyBreakFirstLessLess: 120
|
|
||||||
PenaltyBreakOpenParenthesis: 0
|
|
||||||
PenaltyBreakString: 1000
|
|
||||||
PenaltyBreakTemplateDeclaration: 10
|
|
||||||
PenaltyExcessCharacter: 1000000
|
|
||||||
PenaltyIndentedWhitespace: 0
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
QualifierAlignment: Custom
|
ReflowComments: false
|
||||||
ReferenceAlignment: Pointer
|
|
||||||
ReflowComments: true
|
|
||||||
RemoveBracesLLVM: false
|
|
||||||
RemoveSemicolon: true
|
|
||||||
RequiresClausePosition: OwnLine
|
|
||||||
RequiresExpressionIndentation: OuterScope
|
|
||||||
SeparateDefinitionBlocks: Always
|
|
||||||
ShortNamespaceLines: 1000
|
|
||||||
SortIncludes: CaseSensitive
|
|
||||||
SortJavaStaticImport: Before
|
|
||||||
SortUsingDeclarations: LexicographicNumeric
|
|
||||||
SpaceAfterCStyleCast: true
|
SpaceAfterCStyleCast: true
|
||||||
SpaceAfterLogicalNot: false
|
SpaceAfterLogicalNot: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: false
|
||||||
SpaceAroundPointerQualifiers: Default
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
SpaceBeforeCaseColon: false
|
SpaceBeforeCpp11BracedList: false
|
||||||
SpaceBeforeCpp11BracedList: true
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
SpaceBeforeCtorInitializerColon: true
|
||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
SpaceBeforeParensOptions:
|
SpaceBeforeRangeBasedForLoopColon: false
|
||||||
AfterControlStatements: true
|
|
||||||
AfterForeachMacros: true
|
|
||||||
AfterFunctionDeclarationName: false
|
|
||||||
AfterFunctionDefinitionName: false
|
|
||||||
AfterIfMacros: true
|
|
||||||
AfterOverloadedOperator: false
|
|
||||||
AfterRequiresInClause: false
|
|
||||||
AfterRequiresInExpression: false
|
|
||||||
BeforeNonEmptyParentheses: false
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
|
||||||
SpaceBeforeSquareBrackets: false
|
|
||||||
SpaceInEmptyBlock: false
|
|
||||||
SpaceInEmptyParentheses: false
|
SpaceInEmptyParentheses: false
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 0
|
||||||
SpacesInAngles: Never
|
SpacesInAngles: false
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInCStyleCastParentheses: false
|
||||||
SpacesInConditionalStatement: false
|
SpacesInContainerLiterals: false
|
||||||
SpacesInContainerLiterals: true
|
|
||||||
SpacesInLineCommentPrefix:
|
|
||||||
Minimum: 1
|
|
||||||
Maximum: -1
|
|
||||||
SpacesInParentheses: false
|
SpacesInParentheses: false
|
||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
Standard: Latest
|
|
||||||
StatementAttributeLikeMacros:
|
|
||||||
- Q_EMIT
|
|
||||||
StatementMacros:
|
|
||||||
- Q_UNUSED
|
|
||||||
- QT_REQUIRE_VERSION
|
|
||||||
TabWidth: 2
|
TabWidth: 2
|
||||||
UseTab: Never
|
UseTab: Always
|
||||||
WhitespaceSensitiveMacros:
|
|
||||||
- BOOST_PP_STRINGIZE
|
|
||||||
- CF_SWIFT_NAME
|
|
||||||
- NS_SWIFT_NAME
|
|
||||||
- PP_STRINGIZE
|
|
||||||
- STRINGIZE
|
|
||||||
QualifierOrder:
|
|
||||||
- inline
|
|
||||||
- static
|
|
||||||
- const
|
|
||||||
- type
|
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,3 @@ add_subdirectory(Externals)
|
||||||
add_subdirectory(Connection)
|
add_subdirectory(Connection)
|
||||||
add_subdirectory(Graphics)
|
add_subdirectory(Graphics)
|
||||||
add_subdirectory(Objects)
|
add_subdirectory(Objects)
|
||||||
add_subdirectory(Chat)
|
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.2)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
|
||||||
|
|
||||||
project(Chat)
|
|
||||||
|
|
||||||
### ---------------------- Externals --------------------- ###
|
|
||||||
set(BINDINGS_INCLUDE ${EXTERNALS}/glfw/include ${EXTERNALS}/glew/include)
|
|
||||||
set(BINDINGS_LIBS glfw glew_s Imgui Nanovg)
|
|
||||||
|
|
||||||
### ---------------------- Static Library --------------------- ###
|
|
||||||
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
|
||||||
file(GLOB HEADERS "./public/*.hpp")
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection)
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS})
|
|
||||||
|
|
||||||
### -------------------------- Examples -------------------------- ###
|
|
||||||
add_executable(ChatGUI applications/ChatGUI.cpp)
|
|
||||||
target_link_libraries(ChatGUI ${PROJECT_NAME} ${BINDINGS_LIBS})
|
|
||||||
target_include_directories(ChatGUI PRIVATE ${BINDINGS_INCLUDE})
|
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
|
||||||
enable_testing()
|
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils)
|
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib)
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
|
|
||||||
#include "NewPlacement.hpp"
|
|
||||||
|
|
||||||
#include "ClientGui.hpp"
|
|
||||||
#include "Window.hpp"
|
|
||||||
|
|
||||||
using namespace tp;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
ModuleManifest* deps[] = { &tp::gModuleChat, nullptr };
|
|
||||||
ModuleManifest testModule("ClientGUI", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
ChatAPI chat;
|
|
||||||
ClientGUI gui;
|
|
||||||
|
|
||||||
auto window = Window::createWindow(1000, 700, "Window 1");
|
|
||||||
|
|
||||||
if (window) {
|
|
||||||
|
|
||||||
window->getGraphics().getDebugGui().setFontSize(4);
|
|
||||||
|
|
||||||
while (!window->shouldClose()) {
|
|
||||||
window->processEvents();
|
|
||||||
|
|
||||||
gui.draw(chat);
|
|
||||||
|
|
||||||
window->draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Window::destroyWindow(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
testModule.deinitialize();
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
|
|
||||||
#include "NewPlacement.hpp"
|
|
||||||
|
|
||||||
#include "Chat.hpp"
|
|
||||||
|
|
||||||
#include "Graphics.hpp"
|
|
||||||
|
|
||||||
using namespace tp;
|
|
||||||
|
|
||||||
static ModuleManifest* deps[] = { &gModuleGraphics, nullptr };
|
|
||||||
|
|
||||||
ModuleManifest tp::gModuleChat = ModuleManifest("Chat", nullptr, nullptr, deps );
|
|
||||||
|
|
||||||
bool ChatAPI::isLogged() const {
|
|
||||||
return mLogged;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatAPI::login(const Credentials& credentials) {
|
|
||||||
mLogged = String::Logic::isEqualLogic(credentials.pass, "1812") && String::Logic::isEqualLogic(credentials.name, "Igor");
|
|
||||||
mChatsList = { "Serg", "Friends" };
|
|
||||||
mChatHistories.put("Serg", { { "Serg", "Hello wanna some coke-cola?" }, { "Serg", "Will be in 5 mins" } });
|
|
||||||
mChatHistories.put("Friends", { { "Artem", "Whos is that Serg?" }, { "Erog", "idunno" } });
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatAPI::logout() {
|
|
||||||
mLogged = false;
|
|
||||||
mChatsList.removeAll();
|
|
||||||
mChatHistories.removeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
const ChatAPI::ChatsList* ChatAPI::getChatsList() const {
|
|
||||||
return mLogged ? &mChatsList : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ChatAPI::ChatHistory* ChatAPI::getChatHistory(const String& chatName) const {
|
|
||||||
if (!mLogged) return nullptr;
|
|
||||||
|
|
||||||
auto history = mChatHistories.presents(chatName);
|
|
||||||
return history ? &mChatHistories.getSlotVal(history) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatAPI::send(const String& chatName, const Message& message) {
|
|
||||||
if (!mLogged) return;
|
|
||||||
|
|
||||||
auto iter = mChatHistories.presents(chatName);
|
|
||||||
auto history = iter ? &mChatHistories.getSlotVal(iter) : nullptr;
|
|
||||||
|
|
||||||
if (!history) return;
|
|
||||||
|
|
||||||
history->pushBack(message);
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
|
|
||||||
#include "ClientGui.hpp"
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_internal.h"
|
|
||||||
|
|
||||||
using namespace tp;
|
|
||||||
using namespace ImGui;
|
|
||||||
|
|
||||||
void ClientGUI::draw(ChatAPI& api) {
|
|
||||||
DockSpaceOverViewport(GetWindowViewport());
|
|
||||||
|
|
||||||
if (api.isLogged()) {
|
|
||||||
drawChat(api);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (Begin("Authentication")) {
|
|
||||||
InputText("Name", mCredentials.name, ChatAPI::Credentials::SIZE);
|
|
||||||
InputText("Pass", mCredentials.pass, ChatAPI::Credentials::SIZE);
|
|
||||||
|
|
||||||
if (mInvalidCredentials) {
|
|
||||||
Text("Invalid Credentials");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Button("Login")) {
|
|
||||||
api.login(mCredentials);
|
|
||||||
mInvalidCredentials = !api.isLogged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
End();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientGUI::drawChat(tp::ChatAPI& api) {
|
|
||||||
if (Begin("Chats")) {
|
|
||||||
if (Button("Logout", {GetContentRegionAvail().x, 0})) {
|
|
||||||
api.logout();
|
|
||||||
mCredentials.pass[0] = 0;
|
|
||||||
mActiveChatName = "Not Selected";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BeginListBox("##chats", GetContentRegionAvail())) {
|
|
||||||
auto chats = api.getChatsList();
|
|
||||||
if (chats) {
|
|
||||||
for (auto user : *chats) {
|
|
||||||
if (Selectable(user->read())) {
|
|
||||||
mActiveChatName = user.data();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Text("Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
EndListBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
End();
|
|
||||||
|
|
||||||
if (Begin("History")) {
|
|
||||||
Text("%s", mActiveChatName.read());
|
|
||||||
|
|
||||||
auto history = api.getChatHistory(mActiveChatName);
|
|
||||||
|
|
||||||
if (history) {
|
|
||||||
if (BeginListBox("##History", GetContentRegionAvail())) {
|
|
||||||
for (auto message : *history) {
|
|
||||||
Text("%s : %s", message->user.read(), message->text.read());
|
|
||||||
Separator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EndListBox();
|
|
||||||
} else {
|
|
||||||
Text("No History");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
End();
|
|
||||||
|
|
||||||
if (Begin("Message")) {
|
|
||||||
if (Button("Send")) {
|
|
||||||
if (String::Logic::calcLength(mMessageBuff) > 0) {
|
|
||||||
api.send(mActiveChatName, {mCredentials.name, mMessageBuff});
|
|
||||||
}
|
|
||||||
mMessageBuff[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
InputTextMultiline("##Message", mMessageBuff, MESSAGE_SIZE, GetContentRegionAvail());
|
|
||||||
}
|
|
||||||
End();
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Strings.hpp"
|
|
||||||
#include "Map.hpp"
|
|
||||||
#include "List.hpp"
|
|
||||||
|
|
||||||
namespace tp {
|
|
||||||
|
|
||||||
extern ModuleManifest gModuleChat;
|
|
||||||
|
|
||||||
class ChatAPI {
|
|
||||||
public:
|
|
||||||
struct Credentials {
|
|
||||||
enum { SIZE = 64 };
|
|
||||||
tp::int1 name[SIZE] {0};
|
|
||||||
tp::int1 pass[SIZE] {0};
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef List<String> ChatsList;
|
|
||||||
|
|
||||||
struct Message {
|
|
||||||
String user;
|
|
||||||
String text;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef List<Message> ChatHistory;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ChatAPI() = default;
|
|
||||||
[[nodiscard]] bool isLogged() const;
|
|
||||||
void login(const Credentials& credentials);
|
|
||||||
[[nodiscard]] const ChatsList* getChatsList() const;
|
|
||||||
[[nodiscard]] const ChatHistory* getChatHistory(const String& chatName) const;
|
|
||||||
void logout();
|
|
||||||
void send(const String& chatName, const Message& message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mLogged = false;
|
|
||||||
Credentials mCredentials;
|
|
||||||
ChatsList mChatsList;
|
|
||||||
|
|
||||||
Map<String, ChatHistory> mChatHistories;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Chat.hpp"
|
|
||||||
|
|
||||||
namespace tp {
|
|
||||||
class ClientGUI {
|
|
||||||
enum { MESSAGE_SIZE = 1024 };
|
|
||||||
ChatAPI::Credentials mCredentials;
|
|
||||||
bool mInvalidCredentials = false;
|
|
||||||
char mMessageBuff[1000] {0};
|
|
||||||
String mActiveChatName = "Not Selected";
|
|
||||||
|
|
||||||
public:
|
|
||||||
ClientGUI() = default;
|
|
||||||
void draw(ChatAPI& api);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void drawChat(ChatAPI& api);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
int main () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -18,7 +18,7 @@ int main() {
|
||||||
while (!window->shouldClose()) {
|
while (!window->shouldClose()) {
|
||||||
window->processEvents();
|
window->processEvents();
|
||||||
|
|
||||||
window->getGraphics().getDebugGui().drawDebugInfoWindow();
|
ImGui::Text("Hello!");
|
||||||
|
|
||||||
window->draw();
|
window->draw();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#include "Window.hpp"
|
#include "Window.hpp"
|
||||||
|
|
||||||
#include "Timing.hpp"
|
|
||||||
|
|
||||||
#include "WindowContext.hpp"
|
#include "WindowContext.hpp"
|
||||||
|
|
||||||
// -------- Debug UI -------- //
|
// -------- Debug UI -------- //
|
||||||
|
|
@ -9,21 +7,11 @@
|
||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_impl_glfw.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
|
|
||||||
#include "DefaultFont.bin"
|
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
class Graphics::GUI::Context {
|
class Graphics::GUI::Context {
|
||||||
public:
|
public:
|
||||||
ImGuiIO* io{};
|
ImGuiIO* io{};
|
||||||
ImGuiContext* ctx{};
|
ImGuiContext* ctx{};
|
||||||
|
|
||||||
halnf dpmm = 3;
|
|
||||||
halnf uiScale = 1;
|
|
||||||
halnf fontSizeMM = 2.55f;
|
|
||||||
|
|
||||||
Timer timer = Timer(1000);
|
|
||||||
ualni fps {};
|
|
||||||
ualni frames = 0;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,19 +27,12 @@ Graphics::GUI::~GUI() {
|
||||||
|
|
||||||
void Graphics::GUI::init(Window* window) {
|
void Graphics::GUI::init(Window* window) {
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
|
|
||||||
mContext->ctx = ImGui::CreateContext();
|
mContext->ctx = ImGui::CreateContext();
|
||||||
mContext->io = &ImGui::GetIO();
|
mContext->io = &ImGui::GetIO();
|
||||||
|
|
||||||
mContext->io->ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
||||||
|
|
||||||
// Initialize ImGui with GLFW and OpenGL
|
// Initialize ImGui with GLFW and OpenGL
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window->getContext()->window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window->getContext()->window, true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 330");
|
ImGui_ImplOpenGL3_Init("#version 330");
|
||||||
|
|
||||||
mContext->dpmm = (window->getMonitor().pixelSize.x / window->getMonitor().mmSize.x);
|
|
||||||
|
|
||||||
setStyle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::GUI::deinit() {
|
void Graphics::GUI::deinit() {
|
||||||
|
|
@ -69,210 +50,12 @@ void Graphics::GUI::proc() {
|
||||||
|
|
||||||
tp::HeapAllocGlobal::stopIgnore();
|
tp::HeapAllocGlobal::stopIgnore();
|
||||||
|
|
||||||
// ImGui::DockSpaceOverViewport(NULL, ImGuiDockNodeFlags_PassthruCentralNode);
|
// ImGui code goes here
|
||||||
|
ImGui::Begin("Window");
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::GUI::draw() {
|
void Graphics::GUI::draw() {
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
mContext->frames++;
|
|
||||||
|
|
||||||
if (mContext->timer.isTimeout()) {
|
|
||||||
mContext->fps = mContext->frames;
|
|
||||||
mContext->frames = 0;
|
|
||||||
mContext->timer.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
halnf Graphics::GUI::getFontSize() const { return mContext->fontSizeMM; }
|
|
||||||
halnf Graphics::GUI::getUIScale() const { return mContext->uiScale; }
|
|
||||||
|
|
||||||
void Graphics::GUI::setDPMM(ualni dpmm) {
|
|
||||||
mContext->dpmm = dpmm;
|
|
||||||
setStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::GUI::setFontSize(ualni size) {
|
|
||||||
mContext->fontSizeMM = size;
|
|
||||||
setStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::GUI::setUIScale(ualni scale) {
|
|
||||||
mContext->uiScale = scale;
|
|
||||||
setStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::GUI::drawDebugInfoWindow() {
|
|
||||||
ImGui::Begin("Debug Info");
|
|
||||||
|
|
||||||
ImGui::Text("FPS : %llu", mContext->fps);
|
|
||||||
|
|
||||||
ImGui::SliderFloat("UI Scale", &mContext->uiScale, 0, 10);
|
|
||||||
ImGui::SliderFloat("Font Size MM", &mContext->fontSizeMM, 3, 20);
|
|
||||||
ImGui::SliderFloat("DPMM", &mContext->dpmm, 2, 10);
|
|
||||||
|
|
||||||
setStyle();
|
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::GUI::setStyle() {
|
|
||||||
auto dpmm = mContext->dpmm;
|
|
||||||
auto font_size_mm = mContext->fontSizeMM;
|
|
||||||
auto ui_scale = mContext->uiScale;
|
|
||||||
|
|
||||||
#define VAL(val) (val * dpmm * ui_scale)
|
|
||||||
#define VEC(x, y) ImVec2(x * dpmm, y * dpmm * ui_scale)
|
|
||||||
|
|
||||||
ImGuiStyle* style = &ImGui::GetStyle();
|
|
||||||
auto& io = *mContext->io;
|
|
||||||
bool first_init = io.Fonts->Fonts.Size == 0;
|
|
||||||
auto font_path = ".";
|
|
||||||
//auto font_path = getFontPath();
|
|
||||||
|
|
||||||
// supports PDMM from 0.3 to 10
|
|
||||||
const float min_dpmm = 0.3f;
|
|
||||||
const float max_dpmm = 20.f;
|
|
||||||
dpmm = tp::clamp(dpmm, min_dpmm, max_dpmm);
|
|
||||||
|
|
||||||
// calc font
|
|
||||||
const float font_size_mm_max = 10;
|
|
||||||
const float font_size_pixels_min = 9;
|
|
||||||
float font_size_mm_min = font_size_pixels_min / dpmm;
|
|
||||||
const int font_quality_steps = 3;
|
|
||||||
font_size_mm = tp::clamp(font_size_mm, font_size_mm_min, font_size_mm_max);
|
|
||||||
|
|
||||||
float font_sizes[font_quality_steps];
|
|
||||||
for (auto i = 0; i < font_quality_steps; i++) {
|
|
||||||
auto mm = font_size_mm_min + (font_size_mm_max - font_size_mm_min) * tp::pow(((tp::halnf) (i + 1) / font_quality_steps), 3);
|
|
||||||
font_sizes[i] = dpmm * mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_init) {
|
|
||||||
for (auto i = 0; i < font_quality_steps; i++) {
|
|
||||||
//io.Fonts->AddFontFromFileTTF(font_path, font_sizes[i] * 1);
|
|
||||||
ImFontConfig font_cfg_template;
|
|
||||||
font_cfg_template.FontDataOwnedByAtlas = false;
|
|
||||||
io.Fonts->AddFontFromMemoryTTF(CONSOLAB_TTF, CONSOLAB_TTF_len, font_sizes[i] * 1, &font_cfg_template);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// select fonts
|
|
||||||
auto const pixels_required = dpmm * font_size_mm;
|
|
||||||
auto idx = -1;
|
|
||||||
for (auto i = 0; i < font_quality_steps; i++) {
|
|
||||||
idx = i;
|
|
||||||
if (pixels_required <= font_sizes[i]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
io.FontDefault = io.Fonts->Fonts[idx];
|
|
||||||
io.FontGlobalScale = font_size_mm / (font_size_mm_min + ((font_size_mm_max - font_size_mm_min) / font_quality_steps) * (idx + 1));
|
|
||||||
io.FontGlobalScale = pixels_required / font_sizes[idx];
|
|
||||||
|
|
||||||
auto rounding = VAL(1);
|
|
||||||
auto pudding = VEC(1, 1);
|
|
||||||
|
|
||||||
// style->WindowPadding = pudding;
|
|
||||||
style->WindowRounding = rounding;
|
|
||||||
//style->WindowMinSize = VEC(11, 11);
|
|
||||||
style->ChildRounding = rounding;
|
|
||||||
style->PopupRounding = rounding;
|
|
||||||
style->FramePadding = pudding;
|
|
||||||
style->FrameRounding = rounding;
|
|
||||||
style->ItemSpacing = VEC(1, 2);
|
|
||||||
style->ItemInnerSpacing = VEC(1, 1);
|
|
||||||
style->CellPadding = pudding;
|
|
||||||
style->TouchExtraPadding = pudding;
|
|
||||||
style->IndentSpacing = VAL(3);
|
|
||||||
style->ColumnsMinSpacing = VAL(1.2);
|
|
||||||
style->ScrollbarSize = VAL(5);
|
|
||||||
style->ScrollbarRounding = rounding;
|
|
||||||
style->GrabMinSize = VAL(0.6);
|
|
||||||
style->GrabRounding = rounding;
|
|
||||||
style->LogSliderDeadzone = VAL(0.6);
|
|
||||||
style->TabRounding = rounding;
|
|
||||||
style->TabMinWidthForCloseButton = VAL(1.3);
|
|
||||||
style->DisplayWindowPadding = pudding;
|
|
||||||
style->DisplaySafeAreaPadding = pudding;
|
|
||||||
// style->MouseCursorScale = VAL(1.3);
|
|
||||||
|
|
||||||
// style->FrameBorderSize = VAL(0);
|
|
||||||
style->WindowBorderSize = VAL(0.5);
|
|
||||||
style->ChildBorderSize = VAL(0.6);
|
|
||||||
|
|
||||||
// style->WindowTitleAlign = VEC(0.1f, 0.2f);
|
|
||||||
style->WindowMenuButtonPosition = ImGuiDir_Right;
|
|
||||||
|
|
||||||
if (!first_init)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImVec4* colors = ImGui::GetStyle().Colors;
|
|
||||||
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
|
||||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f);
|
|
||||||
colors[ImGuiCol_WindowBg] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_ChildBg] = ImVec4(0.09f, 0.09f, 0.10f, 1.00f);
|
|
||||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.10f, 1.00f);
|
|
||||||
colors[ImGuiCol_Border] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f);
|
|
||||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
|
||||||
colors[ImGuiCol_FrameBg] = ImVec4(0.14f, 0.14f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.27f, 0.27f, 0.33f, 1.00f);
|
|
||||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.43f, 0.43f, 0.53f, 1.00f);
|
|
||||||
colors[ImGuiCol_TitleBg] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.09f, 0.09f, 0.10f, 0.00f);
|
|
||||||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.15f, 0.15f, 0.19f, 1.00f);
|
|
||||||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.21f, 0.20f, 0.25f, 1.00f);
|
|
||||||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.30f, 0.29f, 0.35f, 1.00f);
|
|
||||||
colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.48f, 0.50f, 1.00f);
|
|
||||||
colors[ImGuiCol_SliderGrab] = ImVec4(0.53f, 0.57f, 0.64f, 1.00f);
|
|
||||||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.69f, 0.74f, 0.83f, 1.00f);
|
|
||||||
colors[ImGuiCol_Button] = ImVec4(0.14f, 0.14f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.27f, 0.27f, 0.33f, 1.00f);
|
|
||||||
colors[ImGuiCol_ButtonActive] = ImVec4(0.43f, 0.43f, 0.53f, 1.00f);
|
|
||||||
colors[ImGuiCol_Header] = ImVec4(0.14f, 0.14f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.27f, 0.27f, 0.33f, 1.00f);
|
|
||||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.33f, 0.33f, 0.40f, 1.00f);
|
|
||||||
colors[ImGuiCol_Separator] = ImVec4(0.37f, 0.37f, 0.40f, 1.00f);
|
|
||||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.33f, 0.35f, 0.38f, 1.00f);
|
|
||||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.37f, 0.39f, 0.42f, 1.00f);
|
|
||||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.16f, 0.17f, 0.19f, 1.00f);
|
|
||||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.33f, 0.35f, 0.38f, 1.00f);
|
|
||||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.28f, 0.34f, 0.42f, 1.00f);
|
|
||||||
colors[ImGuiCol_Tab] = ImVec4(0.14f, 0.14f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabHovered] = ImVec4(0.23f, 0.23f, 0.28f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabActive] = ImVec4(0.23f, 0.23f, 0.28f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.43f, 0.45f, 0.48f, 1.00f);
|
|
||||||
colors[ImGuiCol_DockingPreview] = ImVec4(0.81f, 0.81f, 0.81f, 0.18f);
|
|
||||||
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
|
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.33f, 0.35f, 0.38f, 1.00f);
|
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
|
||||||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.49f, 0.51f, 0.54f, 1.00f);
|
|
||||||
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.13f, 0.13f, 0.20f, 1.00f);
|
|
||||||
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f);
|
|
||||||
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f);
|
|
||||||
colors[ImGuiCol_TableRowBg] = ImVec4(0.23f, 0.20f, 0.20f, 0.00f);
|
|
||||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
|
|
||||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
|
||||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
|
||||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
|
||||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
|
||||||
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.38f, 0.22f, 0.22f, 0.20f);
|
|
||||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
|
|
||||||
|
|
||||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.10f, 1.00f);
|
|
||||||
colors[ImGuiCol_DockingPreview] = ImVec4(0.64f, 0.75f, 0.83f, 0.18f);
|
|
||||||
colors[ImGuiCol_TabHovered] = ImVec4(0.39f, 0.39f, 0.47f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabActive] = ImVec4(0.27f, 0.27f, 0.33f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabUnfocused] = ImVec4(0.14f, 0.14f, 0.17f, 1.00f);
|
|
||||||
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.24f, 0.24f, 0.29f, 1.00f);
|
|
||||||
colors[ImGuiCol_Border] = ImVec4(0.65f, 0.65f, 0.65f, 0.70f);
|
|
||||||
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -101,16 +101,6 @@ Window::Window(int width, int height, const char* title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get some common information. maybe call it in loop to pick up monitor changes
|
|
||||||
int width_mm, height_mm;
|
|
||||||
auto monitor = glfwGetPrimaryMonitor();
|
|
||||||
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
|
|
||||||
mMonitor.mmSize = { width_mm, height_mm };
|
|
||||||
|
|
||||||
const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
|
||||||
mMonitor.pixelSize = { mode->width, mode->height };
|
|
||||||
mMonitor.refreshRate = mode->refreshRate;
|
|
||||||
|
|
||||||
mGraphics.init(this);
|
mGraphics.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,8 @@ namespace tp {
|
||||||
void proc();
|
void proc();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void setStyle();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void drawDebugInfoWindow();
|
// TODO : API
|
||||||
|
|
||||||
halnf getFontSize() const;
|
|
||||||
halnf getUIScale() const;
|
|
||||||
|
|
||||||
void setDPMM(ualni);
|
|
||||||
void setFontSize(ualni);
|
|
||||||
void setUIScale(ualni);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Canvas {
|
class Canvas {
|
||||||
|
|
@ -78,9 +69,6 @@ namespace tp {
|
||||||
void draw();
|
void draw();
|
||||||
void proc();
|
void proc();
|
||||||
|
|
||||||
public:
|
|
||||||
GUI& getDebugGui() { return mGui; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GUI mGui;
|
GUI mGui;
|
||||||
GL mGl;
|
GL mGl;
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,6 @@ namespace tp {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Monitor {
|
|
||||||
ualni refreshRate = 60;
|
|
||||||
Vec2F pixelSize;
|
|
||||||
Vec2F mmSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Window(int width, int height, const char* title);
|
Window(int width, int height, const char* title);
|
||||||
~Window();
|
~Window();
|
||||||
|
|
@ -39,14 +33,10 @@ namespace tp {
|
||||||
|
|
||||||
auto getContext() -> Context*;
|
auto getContext() -> Context*;
|
||||||
|
|
||||||
Graphics& getGraphics() { return mGraphics; }
|
|
||||||
|
|
||||||
[[nodiscard]] const Monitor& getMonitor() const { return mMonitor; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Context* mContext;
|
Context* mContext;
|
||||||
Graphics mGraphics;
|
Graphics mGraphics;
|
||||||
|
|
||||||
Buffer<Event> mEvents;
|
Buffer<Event> mEvents;
|
||||||
Monitor mMonitor;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue