MCPcopy Create free account
hub / github.com/Tom94/tev / ImageViewer

Method ImageViewer

src/ImageViewer.cpp:95–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93};
94
95ImageViewer::ImageViewer(
96 Vector2i size, const shared_ptr<BackgroundImagesLoader>& imagesLoader, weak_ptr<Ipc> ipc, bool maximize, bool showUi, bool floatBuffer
97) :
98 Screen{size, "tev", true, maximize, false, true, true, floatBuffer}, mImagesLoader{imagesLoader}, mIpc{ipc}, mMaximizedLaunch{maximize} {
99
100 m_theme->m_message_warning_icon = FA_EXCLAMATION_CIRCLE;
101
102 // At this point we no longer need the standalone console (if it exists).
103 toggleConsole();
104
105 // Get monitor configuration to figure out how large the tev window may maximally become. This will later get overwritten once
106 // glfwGetWindowCurrentMonitor() works (it does not while the window is still getting constructed).
107 {
108 int monitorCount;
109 auto** monitors = glfwGetMonitors(&monitorCount);
110 if (monitors && monitorCount > 0) {
111 Vector2i monitorMin{numeric_limits<int>::max(), numeric_limits<int>::max()},
112 monitorMax{numeric_limits<int>::min(), numeric_limits<int>::min()};
113
114 for (int i = 0; i < monitorCount; ++i) {
115 Vector2i monitorPos, monitorSize;
116 glfwGetMonitorWorkarea(monitors[i], &monitorPos.x(), &monitorPos.y(), &monitorSize.x(), &monitorSize.y());
117 monitorMin = min(monitorMin, monitorPos);
118 monitorMax = max(monitorMax, monitorPos + monitorSize);
119 }
120
121 const auto padding = framePadding(m_glfw_window);
122 monitorMin += padding.topLeft;
123 monitorMax -= padding.bottomRight;
124
125 mMinWindowPos = monitorMin;
126 mMaxWindowSize = min(mMaxWindowSize, Vector2f{max(monitorMax - monitorMin, Vector2i{1024, 800})});
127
128#if defined(_WIN32) || defined(__linux__) || defined(EMSCRIPTEN)
129 mMinWindowPos = mMinWindowPos / pixel_ratio();
130 mMaxWindowSize = mMaxWindowSize / pixel_ratio();
131#endif
132
133 tlog::debug("Initial monitor: pos={} size={}", mMinWindowPos, mMaxWindowSize);
134 }
135 }
136
137 // Try to get the current monitor size right away. Better to have it early. The function will get called again before every draw to
138 // handle monitor changes as well as the case where glfwGetWindowCurrentMonitor() did not work yet.
139 updateCurrentMonitorSize();
140
141 m_background = Color{0.23f, 1.0f};
142
143 mVerticalScreenSplit = new Widget{this};
144 mVerticalScreenSplit->set_layout(new BoxLayout{Orientation::Vertical, Alignment::Fill});
145
146 auto horizontalScreenSplit = new Widget(mVerticalScreenSplit);
147 horizontalScreenSplit->set_layout(new BoxLayout{Orientation::Horizontal, Alignment::Fill});
148
149 mSidebar = new VScrollPanel{horizontalScreenSplit};
150 mSidebar->set_fixed_width(SIDEBAR_MIN_WIDTH);
151 mSidebar->set_visible(showUi);
152

Callers

nothing calls this directly

Calls 15

toggleConsoleFunction · 0.85
maxFunction · 0.85
minFunction · 0.85
framePaddingFunction · 0.85
ETransferEnum · 0.85
chromaFunction · 0.85
setPixelRatioMethod · 0.80
setClipToLdrMethod · 0.80
valueMethod · 0.80
colorMethod · 0.80
sizeMethod · 0.45
inspectionChromaMethod · 0.45

Tested by

no test coverage detected