MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / ShowInfoPane

Method ShowInfoPane

src/openboardview/BoardView.cpp:188–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186
187
188void BoardView::ShowInfoPane(void) {
189 ImGuiIO &io = ImGui::GetIO();
190 ImVec2 ds = io.DisplaySize;
191
192 if (!config.showInfoPanel) return;
193
194 if (m_info_surface.x < DPIF(100)) {
195 // fprintf(stderr,"Too small (%f), set to (%f)\n", width, DPIF(100));
196 m_info_surface.x = DPIF(100) + 1;
197 m_board_surface.x = ds.x - m_info_surface.x;
198 }
199
200 m_info_surface.y = m_board_surface.y;
201
202 /*
203 * Originally the dialog was to follow the cursor but it proved to be an overkill
204 * to try adjust things to keep it within the bounds of the window so as to not
205 * lose the buttons.
206 *
207 * Now it's kept at a fixed point.
208 */
209 ImGui::SetNextWindowPos(ImVec2(ds.x - m_info_surface.x, m_menu_height));
210 ImGui::SetNextWindowSize(m_info_surface);
211 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
212 ImGui::Begin("Info Panel",
213 NULL,
214 ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
215 ImGuiWindowFlags_NoSavedSettings);
216
217 if ((m_dragging_token == 0) && (io.MousePos.x > m_board_surface.x) && (io.MousePos.x < (m_board_surface.x + DPIF(12.0f)))) {
218 ImDrawList *draw = ImGui::GetWindowDrawList();
219 draw->AddRectFilled(ImVec2(m_board_surface.x, m_menu_height),
220 ImVec2(m_board_surface.x + DPIF(12.0f), m_board_surface.y + m_menu_height),
221 ImColor(0x88888888));
222 // DrawHex( draw, io.MousePos, DPIF(10.0f), ImColor(0xFF0000FF) );
223 }
224
225 if (ImGui::IsMouseDragging(0)) {
226 if ((m_dragging_token == 0) && (io.MouseClickedPos[0].x > m_board_surface.x) &&
227 (io.MouseClickedPos[0].x < (m_board_surface.x + DPIF(20.0f))))
228 m_dragging_token = 2; // own it.
229 if (m_dragging_token == 2) {
230 ImVec2 delta = ImGui::GetMouseDragDelta();
231 if ((abs(delta.x) > 500) || (abs(delta.y) > 500)) {
232 delta.x = 0;
233 delta.y = 0;
234 } // If the delta values are crazy just drop them (happens when panning
235 // off screen). 500 arbritary chosen
236 ImGui::ResetMouseDragDelta();
237 m_board_surface.x += delta.x;
238 m_info_surface.x = ds.x - m_board_surface.x;
239 if (m_board_surface.x < ds.x * 0.66) {
240 m_board_surface.x = ds.x * 0.66;
241 m_info_surface.x = ds.x - m_board_surface.x;
242 }
243 if (delta.x > 0) m_needsRedraw = true;
244 }
245 } else {

Callers

nothing calls this directly

Calls 5

DPIFFunction · 0.85
IDPIFFunction · 0.85
WriteIntMethod · 0.80
WriteBoolMethod · 0.80
DocumentSearchMethod · 0.45

Tested by

no test coverage detected