Skip to content

Commit

Permalink
Set swap interval to 1, changed utf-16 font files to utf-8 included h…
Browse files Browse the repository at this point in the history
…eaders needed on linux, resolved some clang warnings
  • Loading branch information
SkylerRankin committed Dec 28, 2024
1 parent 3779bc0 commit 7319953
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(cormorant LANGUAGES CXX)
project(cormorant LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ project(cormorant LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(include)

# Header files
set(CXX_HEADERS
include/application.h
Expand Down Expand Up @@ -47,6 +45,8 @@ endif()

add_executable(cormorant ${CXX_SRCS} ${CXX_HEADERS} ${RESOURCE_FILE})
target_link_libraries(cormorant PRIVATE glad glfw imgui implot tinyfiledialogs glm stb_image tinyxml2 tinyEXIF whereami)
target_include_directories(cormorant PRIVATE include)
target_include_directories(cormorant PRIVATE res)

# Use the Windows subsystem (instead of console) for Windows release builds.
if (WIN32)
Expand Down
1 change: 1 addition & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <filesystem>
#include <fstream>
#include <optional>
#include <whereami.h>
#include "config.h"
#include "version.h"
Expand Down
1 change: 1 addition & 0 deletions src/export.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <chrono>
#include <format>
#include <fstream>
#include "application.h"
Expand Down
2 changes: 1 addition & 1 deletion src/imageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void ImageViewer::clampPanToEdges() {
}

void ImageViewer::updateZoom(double elapsed) {
if (abs(currentZoom - targetZoom) <= 0.01f) {
if (std::abs(currentZoom - targetZoom) <= 0.01f) {
currentZoom = targetZoom;
animatingZoom = false;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/include/cache.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <atomic>
#include <condition_variable>
#include <deque>
#include <set>
#include <map>
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ int main() {
glfwSetCursorPosCallback(window, &mousePositionCallback);
glfwSetScrollCallback(window, &scrollCallback);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
glfwSwapInterval(1);

#ifndef NDEBUG
glfwSetErrorCallback(errorCallback);
Expand Down
Binary file modified src/res/fontFA6.h
Binary file not shown.
Binary file modified src/res/fontOpenSans.h
Binary file not shown.
34 changes: 16 additions & 18 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ void UI::inputKey(int key) {
}
}
break;
case Config::KeyAction_Count:
break;
}
}
}
Expand Down Expand Up @@ -405,12 +407,8 @@ void UI::renderFrame(double elapsed) {

// UI updates when leaving a control panel state
if (prevControlPanelState != controlPanelState) {
switch (prevControlPanelState) {
case ControlPanel_ShowFiles:
if (prevControlPanelState == ControlPanel_ShowFiles) {
uiState.scrollToTopOfFiles = true;
break;
case ControlPanel_ShowGroups:
break;
}
}
}
Expand Down Expand Up @@ -484,7 +482,7 @@ void UI::renderControlPanelGroupOptions() {
if (groups.size() == 1) {
ImGui::Text("1 Group");
} else {
ImGui::Text("%d Groups", groups.size());
ImGui::Text("%zu Groups", groups.size());
}

int countGroupsWithNoSaves = 0;
Expand Down Expand Up @@ -534,7 +532,7 @@ void UI::renderControlPanelGroupsList() {
ImGui::TableSetColumnIndex(1);
ImGui::Text("Group %d", i + 1);
ImGui::Separator();
ImGui::Text("%d image%s", groups[i].ids.size(), groups[i].ids.size() == 1 ? "" : "s");
ImGui::Text("%zu image%s", groups[i].ids.size(), groups[i].ids.size() == 1 ? "" : "s");

if (groups[i].skippedCount == groups[i].ids.size()) {
ImGui::Text("All images skipped");
Expand Down Expand Up @@ -679,7 +677,7 @@ void UI::renderControlPanelFiles() {
}

ImGui::Text("Group %d", selectedGroup + 1);
ImGui::Text("%d images, %d saved, %d skipped", groups[selectedGroup].ids.size(), groups[selectedGroup].savedCount, groups[selectedGroup].skippedCount);
ImGui::Text("%zu images, %d saved, %d skipped", groups[selectedGroup].ids.size(), groups[selectedGroup].savedCount, groups[selectedGroup].skippedCount);
ImGui::Spacing();

endSection();
Expand Down Expand Up @@ -734,7 +732,7 @@ void UI::renderControlPanelFiles() {
setTextColorDisabled = true;
}

ImGui::Text(image->shortFilename.c_str());
ImGui::Text("%s", image->shortFilename.c_str());

if (image->saved) {
ImGui::PopStyleColor();
Expand All @@ -745,7 +743,7 @@ void UI::renderControlPanelFiles() {

if (image->metadata.timestamp.has_value()) {
ImageTimestamp t = image->metadata.timestamp.value();
ImGui::Text(std::format("{}:{:0>2} {}/{}/{}", t.hour, t.minute, t.month, t.day, t.year).c_str());
ImGui::Text("%s", std::format("{}:{:0>2} {}/{}/{}", t.hour, t.minute, t.month, t.day, t.year).c_str());
} else {
ImGui::Text("Date unknown");
}
Expand Down Expand Up @@ -794,7 +792,7 @@ void UI::renderControlPanelFiles() {
ImGui::PushStyleColor(ImGuiCol_ChildBg, Colors::gray1);
if (ImGui::BeginPopupContextItem()) {
ImGui::BeginChild(std::format("file popup {}", imageID).c_str(), ImVec2(rightClickMenuWidth, 0), ImGuiChildFlags_AutoResizeY);
ImGui::TextWrapped(image->filename.c_str());
ImGui::TextWrapped("%s", image->filename.c_str());
ImGui::Separator();
if (ImGui::Selectable(image->saved ? "Undo save" : "Save")) {
onSaveImage(imageID);
Expand Down Expand Up @@ -1070,7 +1068,7 @@ void UI::renderStatsWindow() {
const unsigned char* version = glGetString(GL_VERSION);
uiState.glVersionString = std::format("OpenGL Version {}", reinterpret_cast<const char*>(version));
}
ImGui::Text(uiState.glVersionString.c_str());
ImGui::Text("%s", uiState.glVersionString.c_str());

ImGui::Spacing();

Expand Down Expand Up @@ -1100,13 +1098,13 @@ void UI::renderStatsWindow() {
ImGui::Text("Moving average");
ImGui::TableSetColumnIndex(1);
double ms = monitor->frameTimeAverage;
ImGui::Text(std::format("{:.4f} s, {:.0f} FPS", ms, 1 / ms).c_str());
ImGui::Text("%s", std::format("{:.4f} s, {:.0f} FPS", ms, 1 / ms).c_str());

ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("1k Frame Peak");
ImGui::TableSetColumnIndex(1);
ImGui::Text(std::format("{:.4f} s", maxFrameTime).c_str());
ImGui::Text("%s", std::format("{:.4f} s", maxFrameTime).c_str());
ImGui::EndTable();

if (ImPlot::BeginPlot("##frametime_plot", ImVec2(-1, 100), ImPlotFlags_CanvasOnly | ImPlotFlags_NoInputs | ImPlotFlags_NoChild)) {
Expand Down Expand Up @@ -1137,7 +1135,7 @@ void UI::renderStatsWindow() {
ImGui::TableSetColumnIndex(0);
ImGui::Text("Estimated size");
ImGui::TableSetColumnIndex(1);
ImGui::Text(bytesToSizeString(cacheData.estimatedPreviewBytes).c_str());
ImGui::Text("%s", bytesToSizeString(cacheData.estimatedPreviewBytes).c_str());
ImGui::EndTable();

ImGui::Unindent();
Expand All @@ -1159,7 +1157,7 @@ void UI::renderStatsWindow() {
ImGui::TableSetColumnIndex(0);
ImGui::Text("Estimated size");
ImGui::TableSetColumnIndex(1);
ImGui::Text(bytesToSizeString(cacheData.estimatedFullTextureBytes).c_str());
ImGui::Text("%s", bytesToSizeString(cacheData.estimatedFullTextureBytes).c_str());
ImGui::EndTable();

ImGui::Unindent();
Expand Down Expand Up @@ -1189,7 +1187,7 @@ void UI::renderStatsWindow() {
for (int i = 0; i < 6; i++) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text(rowLabels[i]);
ImGui::Text("%s", rowLabels[i]);
ImGui::TableSetColumnIndex(1);
ImGui::Text("%d", rowValues[i]);
}
Expand Down Expand Up @@ -1302,7 +1300,7 @@ void UI::renderSettingsWindow() {
for (int i = 0; i < Config::KeyAction_Count; i++) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text(keyActions[i]);
ImGui::Text("%s", keyActions[i]);
ImGui::TableSetColumnIndex(1);
for (int j = 0; j < 4; j++) {
if (keyBindings[i][j] == nullptr) break;
Expand Down

0 comments on commit 7319953

Please sign in to comment.