diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 8ad94fe..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 79ee123..0000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
new file mode 100644
index 0000000..ebda570
--- /dev/null
+++ b/.idea/editor.xml
@@ -0,0 +1,346 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 53624c9..ce52bcf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -15,4 +15,5 @@
+
\ No newline at end of file
diff --git a/.idea/modeler.iml b/.idea/modeler.iml
deleted file mode 100644
index 7fb9afb..0000000
--- a/.idea/modeler.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 2a284c4..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..5fa7779
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,297 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "lastFilter": {
+ "state": "OPEN",
+ "assignee": "chapatt"
+ }
+}
+ {
+ "selectedUrlAndAccountId": {
+ "url": "git@github.com:chapatt/modeler.git",
+ "accountId": "2985e6c7-a2cc-4147-a551-f05898efe2fe"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 5,
+ "fromUser": false
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1780247400911
+
+
+ 1780247400911
+
+
+
+
+
+
+
+ 1780972061912
+
+
+
+ 1780972061912
+
+
+
+ 1780972108913
+
+
+
+ 1780972108913
+
+
+
+ 1780972127971
+
+
+
+ 1780972127971
+
+
+
+ 1780972157681
+
+
+
+ 1780972157681
+
+
+
+ 1780972174549
+
+
+
+ 1780972174549
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
deleted file mode 100644
index 659f1a6..0000000
--- a/.vscode/c_cpp_properties.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "configurations": [
- {
- "name": "Win32",
- "includePath": [
- "${workspaceFolder}/**",
- "C:\\VulkanSDK\\1.3.250.0\\Include",
- "/Users/chase/VulkanSDK/1.3.250.0/macOS/include"
- ],
- "defines": [
- "_DEBUG",
- "UNICODE",
- "_UNICODE"
- ],
- "compilerPath": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
- "cStandard": "c99",
- "cppStandard": "gnu++17",
- "intelliSenseMode": "windows-gcc-x64",
- "configurationProvider": "ms-vscode.makefile-tools"
- }
- ],
- "version": 4
-}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 6d55d5f..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "files.associations": {
- "vulkan.h": "c",
- "vulkan_metal.h": "c"
-}
-}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
deleted file mode 100644
index 01a2e40..0000000
--- a/.vscode/tasks.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "tasks": [
- {
- "label": "make build",
- "type": "shell",
- "command": "",
- "args": [
- "make",
- "--directory=${workspaceFolder};"
- ],
- "problemMatcher": [
- "$gcc"
- ],
- "group": "build"
- },
- {
- "type": "cppbuild",
- "label": "C/C++: gcc.exe build active file",
- "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
- "args": [
- "-fdiagnostics-color=always",
- "-g",
- "${file}",
- "-o",
- "${fileDirname}\\${fileBasenameNoExtension}.exe"
- ],
- "options": {
- "cwd": "${fileDirname}"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": {
- "kind": "build",
- "isDefault": true
- },
- "detail": "Task generated by Debugger."
- }
- ],
- "version": "2.0.0"
-}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 656e346..e0dbe70 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ ifeq ($(OS),Windows_NT)
SED=sed
ANDROID_NDK=/Users/chapa/AppData/Local/Android/Sdk/ndk/28.0.12674087
ANDROID_TOOLCHAIN=$(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
- VULKAN_SDK=/VulkanSDK/1.4.328.1
+ VULKAN_SDK=/VulkanSDK/1.4.350.0
GLSLC=$(VULKAN_SDK)/Bin/glslc
else
UNAME_S := $(shell uname -s)
@@ -38,7 +38,10 @@ ifdef ANDROID
TARGET=aarch64-linux-android
API=21
LDLIBS+=-lvulkan
- ALL_TARGET=modeler_android.a imgui.a
+ ALL_TARGET=modeler_android.a
+ifdef ENABLE_IMGUI
+ ALL_TARGET+=imgui.a
+endif
CFLAGS+=--target=$(TARGET)$(API)
CFLAGS+=-I$(ANDROID_TOOLCHAIN)/sysroot/usr/include
CFLAGS+=-DVK_USE_PLATFORM_ANDROID_KHR
@@ -51,8 +54,6 @@ else ifdef IOS
CFLAGS+=-DVK_USE_PLATFORM_METAL_EXT
CFLAGS+=--target=arm64-apple-ios
else ifeq ($(OS),Windows_NT)
- CC=/msys64/mingw64/bin/gcc
- CXX=/msys64/mingw64/bin/g++
CFLAGS+=-I$(VULKAN_SDK)/Include -mwindows -municode
LDFLAGS+=-L$(VULKAN_SDK)/Lib
LDLIBS+=-lvulkan-1 -ldwmapi
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index f7260c5..144502e 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -4,17 +4,21 @@ plugins {
}
android {
- namespace = "io.abalog.modeler"
+ namespace = "io.abalog.chess"
compileSdk = 35
defaultConfig {
- applicationId = "io.abalog.modeler"
+ applicationId = "io.abalog.chess"
minSdk = 30
targetSdk = 35
- versionCode = 1
- versionName = "1.0"
+ versionCode = 3
+ versionName = "1.0.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+
+ ndk {
+ abiFilters.add("arm64-v8a")
+ }
}
buildTypes {
diff --git a/android/app/src/main/ic_launcher-playstore.png b/android/app/src/main/ic_launcher-playstore.png
new file mode 100644
index 0000000..e084865
Binary files /dev/null and b/android/app/src/main/ic_launcher-playstore.png differ
diff --git a/android/app/src/main/java/io/abalog/modeler/MainActivity.kt b/android/app/src/main/java/io/abalog/modeler/MainActivity.kt
index 330f9ba..3526c72 100644
--- a/android/app/src/main/java/io/abalog/modeler/MainActivity.kt
+++ b/android/app/src/main/java/io/abalog/modeler/MainActivity.kt
@@ -1,4 +1,4 @@
-package io.abalog.modeler
+package io.abalog.chess
import com.google.androidgamesdk.GameActivity
import android.view.WindowInsets
diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/android/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 07d5da9..0000000
--- a/android/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/android/app/src/main/res/drawable/ic_launcher_foreground.xml
deleted file mode 100644
index 2b068d1..0000000
--- a/android/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..036d09b
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..036d09b
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/android/app/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/android/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp
index c209e78..b4235ff 100644
Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..f8ba548
Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
index b2dfe3d..5ecb8ad 100644
Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp
index 4f0f1d6..0be915c 100644
Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..31c0007
Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
index 62b611d..5dc5e8d 100644
Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
index 948a307..05a6f7b 100644
Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..d563933
Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
index 1b9a695..6364502 100644
Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
index 28d4b77..60b11c1 100644
Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..0bf921f
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
index 9287f50..305a33d 100644
Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
index aa7d642..15b0361 100644
Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..c587eed
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
index 9126ae3..f8fd2a5 100644
Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/ic_launcher_background.xml
new file mode 100644
index 0000000..8e73c0e
--- /dev/null
+++ b/android/app/src/main/res/values/ic_launcher_background.xml
@@ -0,0 +1,4 @@
+
+
+ #DBEFFF
+
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 8ae459b..8e95ed5 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- modeler
+ Visual Chess
\ No newline at end of file
diff --git a/src/chess_board.c b/src/chess_board.c
index 5b37cfb..75f4ca1 100644
--- a/src/chess_board.c
+++ b/src/chess_board.c
@@ -5,6 +5,7 @@
#include "lodepng.h"
#include "chess_board.h"
+#include "buffer.h"
#include "descriptor.h"
#include "image.h"
#include "image_view.h"
@@ -601,7 +602,7 @@ static bool createBoardIndexBuffer(ChessBoard self, char **error)
indices[indicesOffset + 5] = verticesOffset + 0;
}
- if (!createStaticBuffer(self->device, self->allocator, self->commandPool, self->queue, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, &self->boardIndexBuffer, &self->boardIndexBufferAllocation, indices, sizeof(indices[0]), CHESS_INDEX_COUNT + 48, error)) {
+ if (!createStaticBuffer(self->device, self->allocator, self->commandPool, self->queue, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, &self->boardIndexBuffer, &self->boardIndexBufferAllocation, indices, CHESS_INDEX_COUNT + 48, sizeof(indices[0]), error)) {
return false;
}
diff --git a/src/component.h b/src/component.h
new file mode 100644
index 0000000..378f585
--- /dev/null
+++ b/src/component.h
@@ -0,0 +1,19 @@
+#ifndef MODELER_COMPONENT_H
+#define MODELER_COMPONENT_H
+
+typedef struct offset_t {
+ float x;
+ float y;
+} Offset;
+
+typedef struct extent_t {
+ float width;
+ float height;
+} Extent;
+
+typedef struct normalized_rectangle_t {
+ Offset offset;
+ Extent extent;
+} NormalizedRectangle;
+
+#endif /* MODELER_COMPONENT_H */
diff --git a/src/modeler.c b/src/modeler.c
index 1f6edd9..f4a49a8 100644
--- a/src/modeler.c
+++ b/src/modeler.c
@@ -218,14 +218,14 @@ void *threadProc(void *arg)
}
float aspectRatio = (float) windowDimensions.activeArea.extent.width / windowDimensions.titlebarHeight;
- float titlebarHeight = (float) windowDimensions.titlebarHeight / windowDimensions.activeArea.extent.height;
+ float titlebarHeight = (float) windowDimensions.titlebarHeight / (windowDimensions.titlebarHeight + windowDimensions.insets.top);
#ifdef ENABLE_IMGUI
int titlebarSubpass = 2;
#else /* ENABLE_IMGUI */
int titlebarSubpass = 1;
#endif /* ENABLE_IMGUI */
Titlebar titlebar;
- if (!createTitlebar(&titlebar, device, allocator, commandPool, queueInfo.graphicsQueue, renderPass, titlebarSubpass, getMaxSampleCount(physicalDeviceCharacteristics.deviceProperties), resourcePath, aspectRatio, &sendCloseSignal, platformWindow, &sendMaximizeSignal, platformWindow, &sendMinimizeSignal, platformWindow, error)) {
+ if (!createTitlebar(&titlebar, device, allocator, commandPool, queueInfo.graphicsQueue, renderPass, titlebarSubpass, getMaxSampleCount(physicalDeviceCharacteristics.deviceProperties), resourcePath, aspectRatio, titlebarHeight, &sendCloseSignal, platformWindow, &sendMaximizeSignal, platformWindow, &sendMinimizeSignal, platformWindow, error)) {
sendThreadFailureSignal(platformWindow);
}
diff --git a/src/shaders/titlebar.frag.glsl b/src/shaders/titlebar.frag.glsl
index 6982561..061d21a 100644
--- a/src/shaders/titlebar.frag.glsl
+++ b/src/shaders/titlebar.frag.glsl
@@ -1,23 +1,13 @@
#version 450
-layout(location = 0) in vec2 fragTexCoord;
-layout(location = 1) in vec4 fragColor;
-layout(location = 2) in vec4 backgroundColor;
-layout(location = 3) in flat int drawTexture;
-
+layout(location = 0) in vec3 fragColor;
+layout(location = 1) in vec2 fragTexCoord;
layout(binding = 0) uniform sampler2D texSampler;
layout(location = 0) out vec4 outColor;
-float median(float r, float g, float b) {
- return max(min(r, g), min(max(r, g), b));
-}
-
void main() {
- if (drawTexture == 1) {
- vec4 texture = texture(texSampler, fragTexCoord);
- outColor = mix(backgroundColor, fragColor, texture.a);
- } else {
- outColor = backgroundColor;
- }
-}
\ No newline at end of file
+ vec4 background = vec4(fragColor, 1.0);
+ vec4 texture = texture(texSampler, fragTexCoord);
+ outColor = mix(background, vec4(1.0, 1.0, 1.0, 1.0), texture.a);
+}
diff --git a/src/shaders/titlebar.vert.glsl b/src/shaders/titlebar.vert.glsl
index 41c0824..eb84b7a 100644
--- a/src/shaders/titlebar.vert.glsl
+++ b/src/shaders/titlebar.vert.glsl
@@ -1,111 +1,20 @@
#version 450
layout (push_constant) uniform _push_constants {
- vec4 minimizeColor;
- vec4 maximizeColor;
- vec4 closeColor;
float aspectRatio;
} PushConstants;
-layout(location = 0) out vec2 fragTexCoord;
-layout(location = 1) out vec4 fragColor;
-layout(location = 2) out vec4 backgroundColor;
-layout(location = 3) out flat int drawTexture;
+layout(location = 0) in vec2 inPosition;
+layout(location = 1) in vec3 inColor;
+layout(location = 2) in vec2 inTexCoord;
-float aspectRatio = PushConstants.aspectRatio;
-float buttonWidth = 2.0 / aspectRatio;
-
-vec2 positions[] = vec2[](
- vec2(-1, -1), vec2(-1, 1), vec2(1, 1), vec2(1, -1),
- vec2(1.0 - buttonWidth, -1), vec2(1.0 - buttonWidth, 1), vec2(1, 1), vec2(1, -1),
- vec2(1.0 - buttonWidth * 2, -1), vec2(1.0 - buttonWidth * 2, 1), vec2(1 - buttonWidth, 1), vec2(1 - buttonWidth, -1),
- vec2(1.0 - buttonWidth * 3, -1), vec2(1.0 - buttonWidth * 3, 1), vec2(1 - buttonWidth * 2, 1), vec2(1 - buttonWidth * 2, -1)
-);
+layout(location = 0) out vec3 fragColor;
+layout(location = 1) out vec2 fragTexCoord;
-int indices[] = int[](
- 0, 1, 2, 0, 2, 3,
- 4, 5, 6, 4, 6, 7,
- 8, 9, 10, 8, 10, 11,
- 12, 13, 14, 12, 14, 15
-);
+float aspectRatio = PushConstants.aspectRatio;
void main() {
- gl_Position = vec4(positions[indices[gl_VertexIndex]], 0.0, 1.0);
-
- if (gl_VertexIndex < 6) {
- fragColor = vec4(0.0, 0.0, 0.0, 0.0);
- backgroundColor = vec4(1.0, 1.0, 1.0, 0.01);
- drawTexture = 0;
- } else if (gl_VertexIndex < 12) {
- fragColor = vec4(1.0, 1.0, 1.0, 1.0);
- backgroundColor = PushConstants.closeColor;
- drawTexture = 1;
- } else if (gl_VertexIndex < 18) {
- fragColor = vec4(1.0, 1.0, 1.0, 1.0);
- backgroundColor = PushConstants.maximizeColor;
- drawTexture = 1;
- } else if (gl_VertexIndex < 24) {
- fragColor = vec4(1.0, 1.0, 1.0, 1.0);
- backgroundColor = PushConstants.minimizeColor;
- drawTexture = 1;
- }
-
- switch (gl_VertexIndex) {
- case 6:
- fragTexCoord = vec2(0.0, 0.0);
- break;
- case 7:
- fragTexCoord = vec2(0.0, 0.5);
- break;
- case 8:
- fragTexCoord = vec2(0.5, 0.5);
- break;
- case 9:
- fragTexCoord = vec2(0.0, 0.0);
- break;
- case 10:
- fragTexCoord = vec2(0.5, 0.5);
- break;
- case 11:
- fragTexCoord = vec2(0.5, 0.0);
- break;
- case 12:
- fragTexCoord = vec2(0.5, 0.0);
- break;
- case 13:
- fragTexCoord = vec2(0.5, 0.5);
- break;
- case 14:
- fragTexCoord = vec2(1.0, 0.5);
- break;
- case 15:
- fragTexCoord = vec2(0.5, 0.0);
- break;
- case 16:
- fragTexCoord = vec2(1.0, 0.5);
- break;
- case 17:
- fragTexCoord = vec2(1.0, 0.0);
- break;
- case 18:
- fragTexCoord = vec2(0.0, 0.5);
- break;
- case 19:
- fragTexCoord = vec2(0.0, 1.0);
- break;
- case 20:
- fragTexCoord = vec2(0.5, 1.0);
- break;
- case 21:
- fragTexCoord = vec2(0.0, 0.5);
- break;
- case 22:
- fragTexCoord = vec2(0.5, 1.0);
- break;
- case 23:
- fragTexCoord = vec2(0.5, 0.5);
- break;
- default:
- fragTexCoord = vec2(0.0, 0.5);
- }
+ gl_Position = vec4(inPosition, 0.0, 1.0);
+ fragColor = inColor;
+ fragTexCoord = inTexCoord;
}
diff --git a/src/textures/icon.png b/src/textures/icon.png
new file mode 100644
index 0000000..6b5d626
Binary files /dev/null and b/src/textures/icon.png differ
diff --git a/src/textures/titlebar.png b/src/textures/titlebar.png
index e501572..1abd12e 100644
Binary files a/src/textures/titlebar.png and b/src/textures/titlebar.png differ
diff --git a/src/textures/titlebar.svg b/src/textures/titlebar.svg
index 96b88bd..0fed3d6 100644
--- a/src/textures/titlebar.svg
+++ b/src/textures/titlebar.svg
@@ -26,9 +26,9 @@
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
- inkscape:zoom="1.6751757"
- inkscape:cx="21.78876"
- inkscape:cy="72.231231"
+ inkscape:zoom="2.7566943"
+ inkscape:cx="68.197623"
+ inkscape:cy="67.83487"
inkscape:window-width="1328"
inkscape:window-height="723"
inkscape:window-x="0"
@@ -46,4 +46,20 @@
d="m 51.978516,80.283203 v 7.677734 h 7.677734 v -7.677734 z m 0.794921,0.794922 h 6.089844 v 6.089844 h -6.089844 z"
id="rect3" />
+ id="path4"
+ style="fill:#000000" />
diff --git a/src/titlebar.c b/src/titlebar.c
index 9de0650..8028230 100644
--- a/src/titlebar.c
+++ b/src/titlebar.c
@@ -3,6 +3,8 @@
#include "lodepng.h"
#include "titlebar.h"
+#include "component.h"
+#include "buffer.h"
#include "descriptor.h"
#include "image.h"
#include "image_view.h"
@@ -21,16 +23,36 @@
#include "../texture_titlebar.h"
#endif /* EMBED_TEXTURES */
+#define TITLEBAR_VERTEX_COUNT 5 * 4
+#define TITLEBAR_INDEX_COUNT 5 * 6
+
static const float VIEWPORT_WIDTH = 2.0f;
static const float VIEWPORT_HEIGHT = 2.0f;
typedef struct titlebar_push_constants_t {
- float minimizeColor[4];
- float maximizeColor[4];
- float closeColor[4];
float aspectRatio;
} TitlebarPushConstants;
+typedef enum action_t {
+ TITLEBAR_ACTION_CLOSE,
+ TITLEBAR_ACTION_MAXIMIZE,
+ TITLEBAR_ACTION_MINIMIZE,
+ TITLEBAR_ACTION_MENU
+} TITLEBAR_ACTION;
+
+float actionSpriteOriginMap[4][2] = {
+ {0.0f, 0.0f},
+ {0.5f, 0.0f},
+ {0.0f, 0.5f},
+ {0.5f, 0.5f}
+};
+
+typedef struct board_vertex_t {
+ float pos[2];
+ float color[3];
+ float texCoord[2];
+} TitlebarVertex;
+
struct titlebar_t {
VkDevice device;
VmaAllocator allocator;
@@ -52,9 +74,12 @@ struct titlebar_t {
VkDescriptorSetLayout descriptorSetLayouts[MAX_FRAMES_IN_FLIGHT];
NormalizedPointerPosition pointerPosition;
float aspectRatio;
+ float height;
+ bool hoveringMenu;
bool hoveringMinimize;
bool hoveringMaximize;
bool hoveringClose;
+ bool pressedMenu;
bool pressedMinimize;
bool pressedMaximize;
bool pressedClose;
@@ -64,16 +89,32 @@ struct titlebar_t {
void *maximizeArg;
void (*minimize)(void *);
void *minimizeArg;
+ NormalizedRectangle buttonRectangles[4];
+ TitlebarVertex vertices[TITLEBAR_VERTEX_COUNT];
+ VkBuffer vertexBuffer;
+ VmaAllocation vertexBufferAllocation;
+ void *vertexBufferMappedMemory;
+ uint16_t indices[TITLEBAR_INDEX_COUNT];
+ VkBuffer indexBuffer;
+ VmaAllocation indexBufferAllocation;
+ void *indexBufferMappedMemory;
};
static bool createTitlebarTexture(Titlebar self, char **error);
static bool createTitlebarTextureSampler(Titlebar self, char **error);
static bool createTitlebarDescriptors(Titlebar self, char **error);
+static void updateButtonRectangles(Titlebar self);
+static void updateMesh(Titlebar self);
+static bool createVertexBuffer(Titlebar self, char **error);
+static void updateVertexBuffer(Titlebar self);
+static void updateIndices(Titlebar self);
+static bool createIndexBuffer(Titlebar self, char **error);
+static void updateIndexBuffer(Titlebar self);
static bool createTitlebarPipeline(Titlebar self, char **error);
static void updateHovering(Titlebar self);
static void updatePressed(Titlebar self);
-bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator, VkCommandPool commandPool, VkQueue queue, VkRenderPass renderPass, uint32_t subpass, VkSampleCountFlagBits sampleCount, const char *resourcePath, float aspectRatio, void (*close)(void *), void *closeArg, void (*maximize)(void *), void *maximizeArg, void (*minimize)(void *), void *minimizeArg, char **error)
+bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator, VkCommandPool commandPool, VkQueue queue, VkRenderPass renderPass, uint32_t subpass, VkSampleCountFlagBits sampleCount, const char *resourcePath, float aspectRatio, float height, void (*close)(void *), void *closeArg, void (*maximize)(void *), void *maximizeArg, void (*minimize)(void *), void *minimizeArg, char **error)
{
*titlebar = malloc(sizeof(**titlebar));
@@ -88,9 +129,15 @@ bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator,
self->sampleCount = sampleCount;
self->resourcePath = resourcePath;
self->aspectRatio = aspectRatio;
+ self->height = height;
+ self->hoveringMenu = false;
self->hoveringMinimize = false;
self->hoveringMaximize = false;
self->hoveringClose = false;
+ self->pressedMenu = false;
+ self->pressedMinimize = false;
+ self->pressedMaximize = false;
+ self->hoveringClose = false;
self->close = close;
self->closeArg = closeArg;
self->maximize = maximize;
@@ -98,6 +145,18 @@ bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator,
self->minimize = minimize;
self->minimizeArg = minimizeArg;
+ updateButtonRectangles(self);
+ updateMesh(self);
+ updateIndices(self);
+
+ if (!createVertexBuffer(self, error)) {
+ return false;
+ }
+
+ if (!createIndexBuffer(self, error)) {
+ return false;
+ }
+
if (!createTitlebarTexture(self, error)) {
return false;
}
@@ -192,6 +251,113 @@ static bool createTitlebarTexture(Titlebar self, char **error)
return true;
}
+static void updateButtonRectangles(Titlebar self)
+{
+ float buttonHeight = self->height * 2;
+ float buttonWidth = buttonHeight / self->aspectRatio;
+
+ self->buttonRectangles[TITLEBAR_ACTION_CLOSE] = (NormalizedRectangle) {
+ .offset = {
+ .x = 1.0f - buttonWidth,
+ .y = 1.0f - buttonHeight
+ },
+ .extent = {
+ .width = buttonWidth,
+ .height = buttonHeight
+ }
+ };
+
+ self->buttonRectangles[TITLEBAR_ACTION_MAXIMIZE] = (NormalizedRectangle) {
+ .offset = {
+ .x = 1.0f - buttonWidth * 2,
+ .y = 1.0f - buttonHeight
+ },
+ .extent = {
+ .width = buttonWidth,
+ .height = buttonHeight
+ }
+ };
+
+ self->buttonRectangles[TITLEBAR_ACTION_MINIMIZE] = (NormalizedRectangle) {
+ .offset = {
+ .x = 1.0f - buttonWidth * 3,
+ .y = 1.0f - buttonHeight
+ },
+ .extent = {
+ .width = buttonWidth,
+ .height = buttonHeight
+ }
+ };
+
+ self->buttonRectangles[TITLEBAR_ACTION_MENU] = (NormalizedRectangle) {
+ .offset = {
+ .x = 1.0f - buttonWidth * 4,
+ .y = 1.0f - buttonHeight
+ },
+ .extent = {
+ .width = buttonWidth,
+ .height = buttonHeight
+ }
+ };
+}
+
+static void updateMesh(Titlebar self)
+{
+ float hoverColor[] = {1.0f, 1.0f, 1.0f, 0.01f};
+ float pressedColor[] = {1.0f, 1.0f, 1.0f, 0.05f};
+
+ float barColor[] = {0.0f, 0.5f, 0.5f};
+ srgbToLinear(barColor);
+ float defaultBackground[] = {0.71f, 0.533f, 0.388f};
+ srgbToLinear(defaultBackground);
+ float hoverBackground[] = {0.71f, 0.533f, 0.388f};
+ srgbToLinear(hoverBackground);
+
+ bool hovering[] = {self->hoveringClose, self->hoveringMaximize, self->hoveringMinimize, self->hoveringMenu};
+ float buttonColors[4][3];
+ for (size_t i = 0; i <= TITLEBAR_ACTION_MENU; ++i) {
+ if (hovering[i]) {
+ buttonColors[i][0] = hoverBackground[0];
+ buttonColors[i][1] = hoverBackground[1];
+ buttonColors[i][2] = hoverBackground[2];
+ } else {
+ buttonColors[i][0] = defaultBackground[0];
+ buttonColors[i][1] = defaultBackground[1];
+ buttonColors[i][2] = defaultBackground[2];
+ }
+ }
+
+ self->vertices[0] = (TitlebarVertex) {{-1.0f, -1.0f}, {barColor[0], barColor[1], barColor[2]}, {0.0f, 0.0f}};
+ self->vertices[1] = (TitlebarVertex) {{-1.0f, 1.0f}, {barColor[0], barColor[1], barColor[2]}, {0.0f, 0.0f}};
+ self->vertices[2] = (TitlebarVertex) {{1.0f, 1.0f}, {barColor[0], barColor[1], barColor[2]}, {0.0f, 0.0f}};
+ self->vertices[3] = (TitlebarVertex) {{1.0f, -1.0f}, {barColor[0], barColor[1], barColor[2]}, {0.0f, 0.0f}};
+ for (size_t i = 0; i <= TITLEBAR_ACTION_MENU; ++i) {
+ NormalizedRectangle rectangle = self->buttonRectangles[i];
+ float *color = buttonColors[i];
+ float *spriteOrigin = actionSpriteOriginMap[i];
+ self->vertices[(i + 1) * 4] = (TitlebarVertex) {
+ {rectangle.offset.x, rectangle.offset.y},
+ {color[0], color[1], color[2]},
+ {spriteOrigin[0], spriteOrigin[1]}
+ };
+ self->vertices[(i + 1) * 4 + 1] = (TitlebarVertex) {
+ {rectangle.offset.x, rectangle.offset.y + rectangle.extent.height},
+ {color[0], color[1], color[2]},
+ {spriteOrigin[0], spriteOrigin[1] + 0.5f}
+ };
+ self->vertices[(i + 1) * 4 + 2] = (TitlebarVertex) {
+ {rectangle.offset.x + rectangle.extent.width, rectangle.offset.y + rectangle.extent.height},
+ {color[0], color[1], color[2]},
+ {spriteOrigin[0] + 0.5f, spriteOrigin[1] + 0.5f}
+ };
+ self->vertices[(i + 1) * 4 + 3] = (TitlebarVertex) {
+ {rectangle.offset.x + rectangle.extent.width, rectangle.offset.y},
+ {color[0], color[1], color[2]},
+ {spriteOrigin[0] + 0.5f, spriteOrigin[1]}
+ };
+ }
+}
+
static bool createTitlebarTextureSampler(Titlebar self, char **error)
{
if (!createSampler(self->device, 0, 1, &self->sampler, error)) {
@@ -238,8 +404,76 @@ static bool createTitlebarDescriptors(Titlebar self, char **error)
return true;
}
+static bool createVertexBuffer(Titlebar self, char **error)
+{
+ if (!createHostVisibleMutableBuffer(self->device, self->allocator, self->commandPool, self->queue, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, &self->vertexBufferMappedMemory, &self->vertexBuffer, &self->vertexBufferAllocation, self->vertices, TITLEBAR_VERTEX_COUNT, sizeof(*self->vertices), error)) {
+ return false;
+ }
+
+ return true;
+}
+
+static void updateVertexBuffer(Titlebar self)
+{
+ updateHostVisibleMutableBuffer(self->device, self->vertexBufferMappedMemory, self->vertices, TITLEBAR_VERTEX_COUNT, sizeof(*self->vertices));
+}
+
+static void updateIndices(Titlebar self)
+{
+ for (size_t i = 0; i < 5; ++i) {
+ size_t verticesOffset = i * 4;
+ size_t indicesOffset = i * 6;
+
+ self->indices[indicesOffset] = verticesOffset + 0;
+ self->indices[indicesOffset + 1] = verticesOffset + 1;
+ self->indices[indicesOffset + 2] = verticesOffset + 2;
+ self->indices[indicesOffset + 3] = verticesOffset + 0;
+ self->indices[indicesOffset + 4] = verticesOffset + 2;
+ self->indices[indicesOffset + 5] = verticesOffset + 3;
+ }
+}
+
+static bool createIndexBuffer(Titlebar self, char **error)
+{
+ if (!createHostVisibleMutableBuffer(self->device, self->allocator, self->commandPool, self->queue, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, &self->indexBufferMappedMemory, &self->indexBuffer, &self->indexBufferAllocation, self->indices, TITLEBAR_INDEX_COUNT, sizeof(*self->indices), error)) {
+ return false;
+ }
+
+ return true;
+}
+
+static void updateIndexBuffer(Titlebar self)
+{
+ updateHostVisibleMutableBuffer(self->device, self->indexBufferMappedMemory, self->indices, TITLEBAR_INDEX_COUNT, sizeof(*self->indices));
+}
+
static bool createTitlebarPipeline(Titlebar self, char **error)
{
+ VkVertexInputBindingDescription vertexBindingDescription = {
+ .binding = 0,
+ .stride = sizeof(TitlebarVertex),
+ .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
+ };
+
+ VkVertexInputAttributeDescription vertexAttributeDescriptions[] = {
+ {
+ .binding = 0,
+ .location = 0,
+ .format = VK_FORMAT_R32G32_SFLOAT,
+ .offset = offsetof(TitlebarVertex, pos)
+ }, {
+ .binding = 0,
+ .location = 1,
+ .format = VK_FORMAT_R32G32B32_SFLOAT,
+ .offset = offsetof(TitlebarVertex, color)
+ }, {
+ .binding = 0,
+ .location = 2,
+ .format = VK_FORMAT_R32G32_SFLOAT,
+ .offset = offsetof(TitlebarVertex, texCoord)
+ }
+ };
+
#ifndef EMBED_SHADERS
char *titlebarVertShaderPath;
char *titlebarFragShaderPath;
@@ -287,10 +521,10 @@ static bool createTitlebarPipeline(Titlebar self, char **error)
.vertexShaderSize = titlebarVertShaderSize,
.fragmentShaderBytes = titlebarFragShaderBytes,
.fragmentShaderSize = titlebarFragShaderSize,
- .vertexBindingDescriptionCount = 0,
- .vertexBindingDescriptions = NULL,
- .vertexAttributeDescriptionCount = 0,
- .VertexAttributeDescriptions = NULL,
+ .vertexBindingDescriptionCount = 1,
+ .vertexBindingDescriptions = &vertexBindingDescription,
+ .vertexAttributeDescriptionCount = sizeof(vertexAttributeDescriptions) / sizeof(*vertexAttributeDescriptions),
+ .VertexAttributeDescriptions = vertexAttributeDescriptions,
.descriptorSetLayouts = self->descriptorSetLayouts,
.descriptorSetLayoutCount = 1,
.pushConstantRangeCount = 1,
@@ -315,6 +549,7 @@ static void updateHovering(Titlebar self)
self->hoveringClose = false;
self->hoveringMaximize = false;
self->hoveringMinimize = false;
+ self->hoveringMenu = false;
if (self->pointerPosition.x >= 1.0f - (1.0f / self->aspectRatio)) {
self->hoveringClose = true;
@@ -357,35 +592,17 @@ static void handleButtonUp(Titlebar self)
bool drawTitlebar(Titlebar self, VkCommandBuffer commandBuffer, char **error)
{
- float hoverColor[] = {1.0f, 1.0f, 1.0f, 0.01f};
- float pressedColor[] = {1.0f, 1.0f, 1.0f, 0.05f};
-
TitlebarPushConstants pushConstants = {
- .minimizeColor = {0.0f, 0.0f, 0.0f, 0.0f},
- .maximizeColor = {0.0f, 0.0f, 0.0f, 0.0f},
- .closeColor = {0.0f, 0.0f, 0.0f, 0.0f},
.aspectRatio = self->aspectRatio
};
- if (self->pressedClose) {
- vec4Copy(pressedColor, pushConstants.closeColor);
- } else if (self->pressedMaximize) {
- vec4Copy(pressedColor, pushConstants.maximizeColor);
- } else if (self->pressedMinimize) {
- vec4Copy(pressedColor, pushConstants.minimizeColor);
- } else if (self->hoveringClose) {
- vec4Copy(hoverColor, pushConstants.closeColor);
- } else if (self->hoveringMaximize) {
- vec4Copy(hoverColor, pushConstants.maximizeColor);
- } else if (self->hoveringMinimize) {
- vec4Copy(hoverColor, pushConstants.minimizeColor);
- }
-
VkDeviceSize offsets[] = {0};
+ vkCmdBindVertexBuffers(commandBuffer, 0, 1, &self->vertexBuffer, offsets);
+ vkCmdBindIndexBuffer(commandBuffer, self->indexBuffer, 0, VK_INDEX_TYPE_UINT16);
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, self->pipeline);
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, self->pipelineLayout, 0, 1, self->descriptorSets, 0, NULL);
vkCmdPushConstants(commandBuffer, self->pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(pushConstants), &pushConstants);
- vkCmdDraw(commandBuffer, 24, 1, 0, 0);
+ vkCmdDrawIndexed(commandBuffer, TITLEBAR_INDEX_COUNT, 1, 0, 0, 0);
return true;
}
@@ -421,6 +638,10 @@ void destroyTitlebar(Titlebar self)
for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
destroyDescriptorSetLayout(self->device, self->descriptorSetLayouts[i]);
}
+ vmaUnmapMemory(self->allocator, self->vertexBufferAllocation);
+ destroyBuffer(self->allocator, self->vertexBuffer, self->vertexBufferAllocation);
+ vmaUnmapMemory(self->allocator, self->indexBufferAllocation);
+ destroyBuffer(self->allocator, self->indexBuffer, self->indexBufferAllocation);
destroySampler(self->device, self->sampler);
destroyImageView(self->device, self->textureImageView);
destroyImage(self->allocator, self->textureImage, self->textureImageAllocation);
@@ -430,4 +651,7 @@ void destroyTitlebar(Titlebar self)
void titlebarSetAspectRatio(Titlebar self, float aspectRatio)
{
self->aspectRatio = aspectRatio;
+ updateButtonRectangles(self);
+ updateMesh(self);
+ updateVertexBuffer(self);
}
diff --git a/src/titlebar.h b/src/titlebar.h
index 24fa0aa..8af2747 100644
--- a/src/titlebar.h
+++ b/src/titlebar.h
@@ -11,7 +11,7 @@ typedef struct titlebar_t *Titlebar;
#include "vulkan_utils.h"
#include "vk_mem_alloc.h"
-bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator, VkCommandPool commandPool, VkQueue queue, VkRenderPass renderPass, uint32_t subpass, VkSampleCountFlagBits sampleCount, const char *resourcePath, float aspectRatio, void (*close)(void *), void *closeArg, void (*maximize)(void *), void *maximizeArg, void (*minimize)(void *), void *minimizeArg, char **error);
+bool createTitlebar(Titlebar *titlebar, VkDevice device, VmaAllocator allocator, VkCommandPool commandPool, VkQueue queue, VkRenderPass renderPass, uint32_t subpass, VkSampleCountFlagBits sampleCount, const char *resourcePath, float aspectRatio, float height, void (*close)(void *), void *closeArg, void (*maximize)(void *), void *maximizeArg, void (*minimize)(void *), void *minimizeArg, char **error);
bool drawTitlebar(Titlebar self, VkCommandBuffer commandBuffer, char **error);
void destroyTitlebar(Titlebar self);
void titlebarHandleInputEvent(void *titlebar, InputEvent *inputEvent);
diff --git a/xcode/modeler/ModelerApp.swift b/xcode/modeler/ModelerApp.swift
index c5f092f..d24d625 100644
--- a/xcode/modeler/ModelerApp.swift
+++ b/xcode/modeler/ModelerApp.swift
@@ -5,7 +5,7 @@ struct ModelerApp: App {
var body: some Scene {
WindowGroup {
GeometryReader { geometry in
- ModelerViewControllerRepresentable(titlebarHeight: Float(geometry.safeAreaInsets.top))
+ ModelerViewControllerRepresentable(titlebarHeight: Float(30))
.ignoresSafeArea()
}
}.windowStyle(.hiddenTitleBar)