Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ImGui modifier keys (again) #173

Merged
merged 27 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c40e43
Fixed ImGui modifier keys (again)
alexc71 Oct 4, 2023
b2e5518
Tabs instead of spaces for consistency
johannesugb Oct 9, 2023
420dce4
messing around with imgui
johannesugb Oct 9, 2023
1393316
Using JetBrainsMono-Regular.ttf as UI font and also accounting for di…
johannesugb Oct 10, 2023
d87438c
Cleaning up font data only once (as instructed by Omar: https://githu…
johannesugb Oct 13, 2023
abc43e0
Fixed ImGui modifier keys (again)
alexc71 Oct 4, 2023
ff903ba
Tabs instead of spaces for consistency
johannesugb Oct 9, 2023
293dc44
messing around with imgui
johannesugb Oct 9, 2023
333f0ea
Using JetBrainsMono-Regular.ttf as UI font and also accounting for di…
johannesugb Oct 10, 2023
f7c28ff
Cleaning up font data only once (as instructed by Omar: https://githu…
johannesugb Oct 13, 2023
c61b226
Added JetBrainsMono-Regular.cpp to CMakeLists.txt
johannesugb Oct 15, 2023
398fd32
GCC needs more hand-holding.
johannesugb Oct 15, 2023
038aec8
Using classic style again, using TTF font only if content scale != 1.…
johannesugb Oct 15, 2023
e915d53
Allow to change ImGui style and font settings
alexc71 Oct 16, 2023
c79e559
Font and style config refactoring
johannesugb Oct 21, 2023
3837514
Whoops
johannesugb Oct 21, 2023
046c061
Update imgui_manager.cpp
johannesugb Oct 21, 2023
fef91f2
Update cross-platform-check.yml
johannesugb Oct 21, 2023
2f69573
JetBrainsMono is no longer included as byte array
johannesugb Nov 30, 2023
c3650f4
JetBrainsMono is now includes as files under assets/3rd_party/fonts/
johannesugb Nov 30, 2023
bcb0113
Custom fonts must be loaded explicitly
johannesugb Nov 30, 2023
abe6b91
fmt::format -> std::format, welcome to the future
johannesugb Nov 30, 2023
503e77d
Renamed set_font_mode -> set_custom_font
johannesugb Nov 30, 2023
e7025a2
Update cross-platform-check.yml
johannesugb Dec 1, 2023
2591d43
Using GCC-13 for Linux
johannesugb Dec 1, 2023
d0b27ec
Using std::format also in examples, fmt::format no longer
johannesugb Dec 1, 2023
c96927a
Using TTF in orca_loader example
johannesugb Dec 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/cross-platform-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
#}
- {
name: "linux: gcc",
cc: "gcc-10",
cxx: "g++-10"
cc: "gcc-13",
cxx: "g++-13"
}
# note: if a specific vulkan version (e.g. 1.1.x, or < 1.2.135) needs testing, you can add it here:
# (not that ubuntu-latest (20.04) only supports >= v1.2.148 via apt)
Expand All @@ -56,13 +56,18 @@ jobs:
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-${{ matrix.vulkan-sdk }}-focal.list https://packages.lunarg.com/vulkan/${{ matrix.vulkan-sdk }}/lunarg-vulkan-${{ matrix.vulkan-sdk }}-focal.list
fi

# For GCC-13
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/ppa

# Update package lists
sudo apt-get update -qq
# Install dependencies
sudo apt-get install -y \
vulkan-sdk \
libassimp-dev \
xorg-dev
xorg-dev \
g++-13 \
gcc-13

# clang does not yet (<= 12) support "Down with typename" (P0634R3), which is used in libstdc++ >= 11 in the ranges-header
if [ "${{ matrix.config.cc }}" = "clang" ]; then
Expand Down Expand Up @@ -97,7 +102,7 @@ jobs:
run: cmake --build .

windows:
name: ${{ matrix.config.name }}, VulkanSDK ${{ matrix.vulkan-sdk }}
name: ${{ matrix.config.name }}, windows-2019, VulkanSDK ${{ matrix.vulkan-sdk }}
runs-on: windows-2019
env:
vulkan_sdk: "$GITHUB_WORKSPACE/vulkan_sdk/"
Expand Down Expand Up @@ -155,7 +160,7 @@ jobs:
run: VULKAN_SDK=${{ env.vulkan_sdk }} cmake --build . --config $BUILD_TYPE

windows-latest:
name: ${{ matrix.config.name }}, VulkanSDK ${{ matrix.vulkan-sdk }}
name: ${{ matrix.config.name }}, windows-latest, VulkanSDK ${{ matrix.vulkan-sdk }}
runs-on: windows-latest
env:
vulkan_sdk: "$GITHUB_WORKSPACE/vulkan_sdk/"
Expand Down
10 changes: 10 additions & 0 deletions assets/3rd_party/fonts/JetBrainsMono-2.304/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is the official list of project authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS.txt file.
# See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>

JetBrains <>
Philipp Nurullin <[email protected]>
Konstantin Bulenkov <[email protected]>
93 changes: 93 additions & 0 deletions assets/3rd_party/fonts/JetBrainsMono-2.304/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion auto_vk_toolkit/include/animation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ namespace avk

size_t pos2 = pos1 + (pos1 < maxIndex ? 1 : 0);
while (pos2 + 1 < maxIndex && aCollection[pos2 + 1].mTime < aTime) {
LOG_WARNING(fmt::format("Now that's strange: keys[{}].mTime {} < {}, despite keys[{}].mTime {} <= {}", pos2 + 1, aCollection[pos2 + 1].mTime, aTime, pos1, aCollection[pos1].mTime, aTime));
LOG_WARNING(std::format("Now that's strange: keys[{}].mTime {} < {}, despite keys[{}].mTime {} <= {}", pos2 + 1, aCollection[pos2 + 1].mTime, aTime, pos1, aCollection[pos1].mTime, aTime));
++pos2;
}

Expand Down
4 changes: 1 addition & 3 deletions auto_vk_toolkit/include/auto_vk_toolkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@

// ----------------------- externals -----------------------
#define FMT_HEADER_ONLY
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/chrono.h>
#include <format>
#include <stb_image.h>

#include <assimp/Importer.hpp> // C++ importer interface
Expand Down
8 changes: 4 additions & 4 deletions auto_vk_toolkit/include/composition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace avk
while (!sInputBufferCondVar.wait_for(lk, timeout, [thiz]{ return !thiz->mInputBufferSwapPending; })) {
cnt++;
totalWaitTime += timeout;
LOG_DEBUG(fmt::format("Condition variable waits for timed out. Total wait time in current frame is {}", totalWaitTime));
LOG_DEBUG(std::format("Condition variable waits for timed out. Total wait time in current frame is {}", totalWaitTime));
}
#else
sInputBufferCondVar.wait(lk, [thiz]{ return !thiz->mInputBufferSwapPending; });
Expand All @@ -180,7 +180,7 @@ namespace avk
//#ifdef _DEBUG
// if ((i+1) % 10000 == 0)
// {
// LOG_DEBUG(fmt::format("Warning: more than {} iterations in spin-lock", i+1));
// LOG_DEBUG(std::format("Warning: more than {} iterations in spin-lock", i+1));
// }
//#endif
#endif
Expand Down Expand Up @@ -297,9 +297,9 @@ namespace avk
mElementsToBeRemoved.erase(std::remove(std::begin(mElementsToBeRemoved), std::end(mElementsToBeRemoved), &pElement), std::end(mElementsToBeRemoved));
}
else {
LOG_DEBUG(fmt::format("Removing element with name[{}] and address[{}] issued from invokee's destructor",
LOG_DEBUG(std::format("Removing element with name[{}] and address[{}] issued from invokee's destructor",
pElement.name(),
fmt::ptr(&pElement)));
reinterpret_cast<intptr_t>(&pElement)));
}
}

Expand Down
24 changes: 21 additions & 3 deletions auto_vk_toolkit/include/imgui_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ namespace avk
{
public:
/** Create an ImGui manager element.
* @param aName You *can* give it a name, but you can also leave it at the default name "imgui_manager".
* @param aName You *can* give it a name, but you can also leave it at the default name "imgui_manager".
* @param aAlterSettingsBeforeInitialization Allows to modify the ImGui style, e.g., like follows:
* [](float uiScale) {
* auto& style = ImGui::GetStyle();
* style = ImGuiStyle(); // reset to default style (for non-color settings, like rounded corners)
* ImGui::StyleColorsClassic(); // change color theme
* style.ScaleAllSizes(uiScale); // and scale
* }
*/
imgui_manager(avk::queue& aQueueToSubmitTo, std::string aName = "imgui_manager", std::optional<avk::renderpass> aRenderpassToUse = {})
imgui_manager(avk::queue& aQueueToSubmitTo, std::string aName = "imgui_manager", std::optional<avk::renderpass> aRenderpassToUse = {}, std::function<void(float)> aAlterSettingsBeforeInitialization = {})
: invokee(std::move(aName))
, mQueue { &aQueueToSubmitTo }
, mUserInteractionEnabled{ true }
, mAlterSettingsBeforeInitialization{ std::move(aAlterSettingsBeforeInitialization) }
{
if (aRenderpassToUse.has_value()) {
mRenderpass = std::move(aRenderpassToUse.value());
Expand Down Expand Up @@ -89,6 +97,13 @@ namespace avk
mUsingSemaphoreInsteadOfFenceForFontUpload = true;
}

/** Configure imgui_manager which font to use.
* @param aPathToTtfFont Path to a custom TTF font file to be used, or empty for using ImGui's bundled default font.
*/
void set_custom_font(std::string aPathToTtfFont = {}) {
mCustomTtfFont = std::move(aPathToTtfFont);
}

/** Indicates whether or not ImGui wants to occupy the mouse.
* This could be because the mouse is over a window, or currently dragging
* some ImGui control.
Expand All @@ -111,7 +126,6 @@ namespace avk
bool end_wanting_to_occupy_mouse() const {
return !mOccupyMouse && mOccupyMouseLastFrame;
}

private:
void upload_fonts();
void construct_render_pass();
Expand All @@ -138,6 +152,10 @@ namespace avk
bool mUsingSemaphoreInsteadOfFenceForFontUpload;
bool mOccupyMouse = false;
bool mOccupyMouseLastFrame = false;

// customization
std::function<void(float)> mAlterSettingsBeforeInitialization = {};
std::string mCustomTtfFont = {};
};

}
Loading