Background color change, better keybinds
This commit is contained in:
@ -58,6 +58,7 @@ struct Context
|
|||||||
float DefaultPanelHeight = 600; // Height of panel in pixels
|
float DefaultPanelHeight = 600; // Height of panel in pixels
|
||||||
float DefaultInitialPanelWidth = 600; // Only applies when window first appears
|
float DefaultInitialPanelWidth = 600; // Only applies when window first appears
|
||||||
int MaxAnnotations = 1000; // Limit number of texel annotations for performance
|
int MaxAnnotations = 1000; // Limit number of texel annotations for performance
|
||||||
|
float InitialZoom = 1.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
Context *GContext = nullptr;
|
Context *GContext = nullptr;
|
||||||
@ -191,7 +192,7 @@ bool BeginInspectorPanel(const char *title, ImTextureID texture, ImVec2 textureS
|
|||||||
}
|
}
|
||||||
else if (justCreated)
|
else if (justCreated)
|
||||||
{
|
{
|
||||||
newScale = 1;
|
newScale = GContext->InitialZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newScale != -1)
|
if (newScale != -1)
|
||||||
@ -684,6 +685,11 @@ void SetZoomRate(float rate)
|
|||||||
GContext->ZoomRate = rate;
|
GContext->ZoomRate = rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetInitialZoom(float zoom)
|
||||||
|
{
|
||||||
|
GContext->InitialZoom = zoom;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// [SECTION] Life Cycle
|
// [SECTION] Life Cycle
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -32,7 +32,7 @@ enum InspectorAlphaMode
|
|||||||
typedef ImU64 InspectorFlags;
|
typedef ImU64 InspectorFlags;
|
||||||
enum InspectorFlags_
|
enum InspectorFlags_
|
||||||
{
|
{
|
||||||
InspectorFlags_ShowWrap = 1 << 0, // Draw beyong the [0,1] uv range. What you see will depend on API
|
InspectorFlags_ShowWrap = 1 << 0, // Draw beyond the [0,1] uv range. What you see will depend on API
|
||||||
InspectorFlags_NoForceFilterNearest = 1 << 1, // Normally we force nearest neighbour sampling when zoomed in. Set to disable this.
|
InspectorFlags_NoForceFilterNearest = 1 << 1, // Normally we force nearest neighbour sampling when zoomed in. Set to disable this.
|
||||||
InspectorFlags_NoGrid = 1 << 2, // By default a grid is shown at high zoom levels
|
InspectorFlags_NoGrid = 1 << 2, // By default a grid is shown at high zoom levels
|
||||||
InspectorFlags_NoTooltip = 1 << 3, // Disable tooltip on hover
|
InspectorFlags_NoTooltip = 1 << 3, // Disable tooltip on hover
|
||||||
@ -132,6 +132,7 @@ void DrawAlphaModeSelector(); // A combo box for selecting the alpha mode
|
|||||||
* scroll will increase zoom level by 50%. The factor used for zooming out is
|
* scroll will increase zoom level by 50%. The factor used for zooming out is
|
||||||
* 1/factor. */
|
* 1/factor. */
|
||||||
void SetZoomRate(float factor);
|
void SetZoomRate(float factor);
|
||||||
|
void SetInitialZoom(float zoom);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// [SECTION] ANNOTATION TOOLS
|
// [SECTION] ANNOTATION TOOLS
|
||||||
|
82
main.cpp
82
main.cpp
@ -516,13 +516,25 @@ int main(int argc, char* argv[]) {
|
|||||||
(SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
|
(SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
|
||||||
SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
|
||||||
|
float image_w = t.size.x;
|
||||||
int wh = 800;
|
float image_h = t.size.y;
|
||||||
int ww = 1280;
|
if (t.exif.ImageOrientation == "6" || t.exif.ImageOrientation == "8") {
|
||||||
if (t.size.y > t.size.x) {
|
std::swap(image_w, image_h);
|
||||||
ww = 500;
|
|
||||||
wh = 1280;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float aspect_ratio = image_w / image_h;
|
||||||
|
int viewer_h = image_h;
|
||||||
|
int viewer_w = image_w;
|
||||||
|
const int max_h = 1200;
|
||||||
|
|
||||||
|
if (viewer_h > max_h) {
|
||||||
|
viewer_h = max_h;
|
||||||
|
viewer_w = max_h * aspect_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ww = viewer_w * 1.25;
|
||||||
|
int wh = viewer_h * 1.25;
|
||||||
|
|
||||||
SDL_Window *window =
|
SDL_Window *window =
|
||||||
SDL_CreateWindow("tview", SDL_WINDOWPOS_CENTERED,
|
SDL_CreateWindow("tview", SDL_WINDOWPOS_CENTERED,
|
||||||
SDL_WINDOWPOS_CENTERED, ww, wh, window_flags);
|
SDL_WINDOWPOS_CENTERED, ww, wh, window_flags);
|
||||||
@ -554,10 +566,20 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.18f, 0.18f, 0.18f, 1.00f);
|
||||||
|
std::vector<ImVec4> background_colors = {
|
||||||
|
ImVec4(0.0f, 0.0f, 0.0f, 1.00f),
|
||||||
|
ImVec4(0.18f, 0.18f, 0.18f, 1.00f),
|
||||||
|
ImVec4(0.5f, 0.5f, 0.5f, 1.00f),
|
||||||
|
ImVec4(255.0f, 255.0f, 255.0f, 255.00f),
|
||||||
|
ImVec4(0.75f, 0.75f, 0.75f, 1.00f)
|
||||||
|
};
|
||||||
|
int background_color_index = 1;
|
||||||
|
|
||||||
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
||||||
|
|
||||||
t = LoadTexture(t);
|
t = LoadTexture(t);
|
||||||
|
ImGuiTexInspect::SetInitialZoom(0.80f);
|
||||||
Histogram histogram = Histogram(t.size.x, t.size.y, t.channels);
|
Histogram histogram = Histogram(t.size.x, t.size.y, t.channels);
|
||||||
auto histogram_future = std::async(std::launch::async, [&]() {
|
auto histogram_future = std::async(std::launch::async, [&]() {
|
||||||
histogram.Load(image);
|
histogram.Load(image);
|
||||||
@ -609,7 +631,7 @@ int main(int argc, char* argv[]) {
|
|||||||
case SDL_SCANCODE_A:
|
case SDL_SCANCODE_A:
|
||||||
AA_ENABLED = !AA_ENABLED;
|
AA_ENABLED = !AA_ENABLED;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_H:
|
case SDL_SCANCODE_SLASH:
|
||||||
SHOW_HELP = !SHOW_HELP;
|
SHOW_HELP = !SHOW_HELP;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_D:
|
case SDL_SCANCODE_D:
|
||||||
@ -625,9 +647,13 @@ int main(int argc, char* argv[]) {
|
|||||||
case SDL_SCANCODE_E:
|
case SDL_SCANCODE_E:
|
||||||
SHOW_EXIF = !SHOW_EXIF;
|
SHOW_EXIF = !SHOW_EXIF;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_C:
|
case SDL_SCANCODE_H:
|
||||||
SHOW_HISTOGRAM = !SHOW_HISTOGRAM;
|
SHOW_HISTOGRAM = !SHOW_HISTOGRAM;
|
||||||
break;
|
break;
|
||||||
|
case SDL_SCANCODE_B:
|
||||||
|
background_color_index = (background_color_index + 1) % background_colors.size();
|
||||||
|
clear_color = background_colors[background_color_index];
|
||||||
|
break;
|
||||||
case SDL_SCANCODE_LEFT:
|
case SDL_SCANCODE_LEFT:
|
||||||
if (current_image_index > 0) {
|
if (current_image_index > 0) {
|
||||||
current_image_index--;
|
current_image_index--;
|
||||||
@ -696,6 +722,11 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGuiTexInspect::SizeExcludingBorder(wSize)
|
ImGuiTexInspect::SizeExcludingBorder(wSize)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CurrentInspector_SetAlphaMode(
|
||||||
|
ImGuiTexInspect::InspectorAlphaMode_CustomColor
|
||||||
|
);
|
||||||
|
ImGuiTexInspect::CurrentInspector_SetCustomBackgroundColor(clear_color);
|
||||||
|
|
||||||
if (GRID_ENABLED) {
|
if (GRID_ENABLED) {
|
||||||
CurrentInspector_ClearFlags(ImGuiTexInspect::InspectorFlags_NoGrid);
|
CurrentInspector_ClearFlags(ImGuiTexInspect::InspectorFlags_NoGrid);
|
||||||
}else {
|
}else {
|
||||||
@ -746,6 +777,7 @@ int main(int argc, char* argv[]) {
|
|||||||
if (ImGui::BeginPopup("HelpPopup")) {
|
if (ImGui::BeginPopup("HelpPopup")) {
|
||||||
ImGui::Text("tview Help");
|
ImGui::Text("tview Help");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
ImGui::Text("b - cycle background color");
|
||||||
ImGui::Text("r - rotate 90 deg clockwise");
|
ImGui::Text("r - rotate 90 deg clockwise");
|
||||||
ImGui::Text("g - toggle grid");
|
ImGui::Text("g - toggle grid");
|
||||||
ImGui::Text("a - toggle filtering");
|
ImGui::Text("a - toggle filtering");
|
||||||
@ -753,14 +785,14 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGui::Text("d - cycle pixel detail mode");
|
ImGui::Text("d - cycle pixel detail mode");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("modes:");
|
ImGui::Text("modes:");
|
||||||
ImGui::Text("\tOff");
|
ImGui::Text(" Off");
|
||||||
ImGui::Text("\tGradient Arrow");
|
ImGui::Text(" Gradient Arrow");
|
||||||
ImGui::Text("\tHex Code");
|
ImGui::Text(" Hex Code");
|
||||||
ImGui::Text("\tRGB Values");
|
ImGui::Text(" RGB Values");
|
||||||
ImGui::Text("\tFloat Values");
|
ImGui::Text(" Float Values");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("h - show help popup");
|
ImGui::Text("? - show help popup");
|
||||||
ImGui::Text("c - toggle color histogram");
|
ImGui::Text("h - toggle color histogram");
|
||||||
ImGui::Text("e - toggle EXIF info");
|
ImGui::Text("e - toggle EXIF info");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("q - quit");
|
ImGui::Text("q - quit");
|
||||||
@ -768,13 +800,14 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGui::Text("click anywhere to continue");
|
ImGui::Text("click anywhere to continue");
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
if (SHOW_EXIF && t.exif.CameraMake != "NULL") {
|
if (SHOW_EXIF) {
|
||||||
|
if (t.exif.CameraMake != "NULL") {
|
||||||
ImGuiWindowClass topmost;
|
ImGuiWindowClass topmost;
|
||||||
topmost.ClassId = ImHashStr("TopMost");
|
topmost.ClassId = ImHashStr("TopMost");
|
||||||
topmost.ViewportFlagsOverrideSet = ImGuiViewportFlags_TopMost;
|
topmost.ViewportFlagsOverrideSet = ImGuiViewportFlags_TopMost;
|
||||||
ImGui::SetNextWindowClass(&topmost);
|
ImGui::SetNextWindowClass(&topmost);
|
||||||
ImGui::SetNextWindowSize(ImVec2(600, 600), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(600, 600), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin("EXIF", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoFocusOnAppearing);
|
ImGui::Begin("EXIF", &SHOW_EXIF, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||||
if(ImGui::BeginTable("Hardware", 2, ImGuiTableFlags_Resizable)) {
|
if(ImGui::BeginTable("Hardware", 2, ImGuiTableFlags_Resizable)) {
|
||||||
ImGui::TableSetupColumn("Field", ImGuiTableColumnFlags_WidthFixed, ImGuiTableColumnFlags_NoHide, 150.0f);
|
ImGui::TableSetupColumn("Field", ImGuiTableColumnFlags_WidthFixed, ImGuiTableColumnFlags_NoHide, 150.0f);
|
||||||
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
||||||
@ -916,6 +949,16 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGui::Text("Press e to hide");
|
ImGui::Text("Press e to hide");
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
} else {
|
||||||
|
ImGuiWindowClass topmost;
|
||||||
|
topmost.ClassId = ImHashStr("TopMost");
|
||||||
|
topmost.ViewportFlagsOverrideSet = ImGuiViewportFlags_TopMost;
|
||||||
|
ImGui::SetNextWindowClass(&topmost);
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(200, 50), ImGuiCond_FirstUseEver);
|
||||||
|
ImGui::Begin("EXIF", &SHOW_EXIF, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
|
ImGui::Text("No EXIF data available.");
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -941,8 +984,7 @@ int main(int argc, char* argv[]) {
|
|||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w,
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
clear_color.z * clear_color.w, clear_color.w);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
Reference in New Issue
Block a user