mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 21:47:40 -05:00
sys: Use custom literals for scaled values
This commit is contained in:
@@ -23,8 +23,14 @@
|
||||
#define TOKEN_CONCAT(x, y) TOKEN_CONCAT_IMPL(x, y)
|
||||
#define ANONYMOUS_VARIABLE(prefix) TOKEN_CONCAT(prefix, __COUNTER__)
|
||||
|
||||
struct ImVec2;
|
||||
|
||||
namespace hex {
|
||||
|
||||
long double operator""_scaled(long double value);
|
||||
long double operator""_scaled(unsigned long long value);
|
||||
ImVec2 scaled(const ImVec2 &vector);
|
||||
|
||||
std::string to_string(u128 value);
|
||||
std::string to_string(s128 value);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
|
||||
#if defined (OS_WINDOWS)
|
||||
#include <windows.h>
|
||||
@@ -18,6 +19,18 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
long double operator""_scaled(long double value) {
|
||||
return value * SharedData::globalScale;
|
||||
}
|
||||
|
||||
long double operator""_scaled(unsigned long long value) {
|
||||
return value * SharedData::globalScale;
|
||||
}
|
||||
|
||||
ImVec2 scaled(const ImVec2 &vector) {
|
||||
return vector * SharedData::globalScale;
|
||||
}
|
||||
|
||||
std::string to_string(u128 value) {
|
||||
char data[45] = { 0 };
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
void View::drawCommonInterfaces() {
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(400, 100) * SharedData::globalScale, ImVec2(600, 300) * SharedData::globalScale);
|
||||
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
|
||||
if (ImGui::BeginPopupModal("hex.common.info"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::TextWrapped("%s", SharedData::popupMessage.c_str());
|
||||
ImGui::NewLine();
|
||||
@@ -35,7 +35,7 @@ namespace hex {
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(400, 100) * SharedData::globalScale, ImVec2(600, 300) * SharedData::globalScale);
|
||||
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
|
||||
if (ImGui::BeginPopupModal("hex.common.error"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::TextWrapped("%s", SharedData::popupMessage.c_str());
|
||||
ImGui::NewLine();
|
||||
@@ -47,7 +47,7 @@ namespace hex {
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(400, 100) * SharedData::globalScale, ImVec2(600, 300) * SharedData::globalScale);
|
||||
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
|
||||
if (ImGui::BeginPopupModal("hex.common.fatal"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::TextWrapped("%s", SharedData::popupMessage.c_str());
|
||||
ImGui::NewLine();
|
||||
@@ -85,7 +85,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
ImVec2 View::getMinSize() const {
|
||||
return ImVec2(480, 720) * SharedData::globalScale;
|
||||
return scaled(ImVec2(480, 720));
|
||||
}
|
||||
|
||||
ImVec2 View::getMaxSize() const {
|
||||
|
||||
Reference in New Issue
Block a user