MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / LoadSavedWindowPos

Function LoadSavedWindowPos

source/MRViewer/ImGuiHelpers.cpp:574–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574std::pair<ImVec2, bool> LoadSavedWindowPos( const char* label, ImGuiWindow* window, float width, const ImVec2* position /*= nullptr*/ )
575{
576 bool haveSavedWindowPos = false;
577 ImVec2 initialWindowPos;
578
579 auto menu = ImGuiMenu::instance();
580 bool windowIsInactive = window && !window->WasActive;
581
582 if ( !window || windowIsInactive )
583 {
584 auto ribMenu = std::dynamic_pointer_cast< MR::RibbonMenu >( menu );
585 const auto shiftMV = ImGuiMV::GetMainViewportShift();
586 float xPos = GetIO().DisplaySize.x - width + shiftMV.x;
587 float yPos = shiftMV.y;
588 if ( position )
589 {
590 xPos = position->x;
591 yPos = position->y;
592 }
593 else if ( ribMenu )
594 yPos += ( ribMenu->getTopPanelOpenedHeight() - 1.0f ) * UI::scale();
595
596 auto& config = MR::Config::instance();
597 if ( menu->isSavedDialogPositionsEnabled() && config.hasJsonValue( "DialogPositions" ) )
598 {
599 auto json = config.getJsonValue( "DialogPositions" )[label];
600 if ( json.empty() )
601 {
602 initialWindowPos = ImVec2( xPos, yPos );
603 }
604 else
605 {
606 haveSavedWindowPos = true;
607 initialWindowPos = ImVec2( json["x"].asFloat(), json["y"].asFloat() );
608 }
609 }
610 else
611 {
612 initialWindowPos = ImVec2( xPos, yPos );
613 }
614 }
615 return { initialWindowPos, haveSavedWindowPos };
616}
617
618std::pair<ImVec2, bool> LoadSavedWindowPos( const char* label, float width, const ImVec2* position )
619{

Callers 3

drawTagInformation_Method · 0.85
BeginSavedWindowPosFunction · 0.85
BeginCustomStatePluginFunction · 0.85

Calls 7

instanceFunction · 0.85
GetMainViewportShiftFunction · 0.85
ImVec2Class · 0.85
hasJsonValueMethod · 0.80
getJsonValueMethod · 0.80
scaleFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected