1111#include " MRUIStyle.h"
1212#include " MRRibbonFontHolder.h"
1313#include " MRImGuiMultiViewport.h"
14+ #include " MRImGuiMultiViewport.h"
1415#include < imgui_internal.h>
1516
1617namespace MR
@@ -341,15 +342,17 @@ bool RibbonMenuSearch::smallSearchButton_()
341342bool RibbonMenuSearch::searchInputText_ ( const char * label, std::string& str )
342343{
343344 ImGui::PushID ( " searchInputText" );
344- const ImVec2 cursorPos = ImGui::GetCursorPos ();
345+ const ImVec2 cursorPosWindow = ImGui::GetCursorPos ();
346+ const ImVec2 cursorPosScreen = ImGuiMV::Window2ScreenSpaceImVec2 ( cursorPosWindow );
347+
345348
346349 const auto & style = ImGui::GetStyle ();
347350
348351 const float inputHeight = ImGui::GetTextLineHeight () + style.FramePadding .y * 2 .f ;
349352 const auto drawList = ImGui::GetWindowDrawList ();
350- drawList->AddRectFilled ( cursorPos , ImVec2 ( cursorPos .x + cSearchSize * UI::scale (), cursorPos .y + inputHeight ),
353+ drawList->AddRectFilled ( cursorPosScreen , ImVec2 ( cursorPosScreen .x + cSearchSize * UI::scale (), cursorPosScreen .y + inputHeight ),
351354 ColorTheme::getRibbonColor ( ColorTheme::RibbonColorsType::TopPanelSearchBackground ).getUInt32 (), style.FrameRounding );
352- drawList->AddRect ( cursorPos , ImVec2 ( cursorPos .x + cSearchSize * UI::scale (), cursorPos .y + inputHeight ),
355+ drawList->AddRect ( cursorPosScreen , ImVec2 ( cursorPosScreen .x + cSearchSize * UI::scale (), cursorPosScreen .y + inputHeight ),
353356 ImGui::GetColorU32 ( ImGuiCol_Border ), style.FrameRounding );
354357
355358 int colorNum = 0 ;
@@ -360,7 +363,7 @@ bool RibbonMenuSearch::searchInputText_( const char* label, std::string& str )
360363 }
361364 RibbonFontHolder font ( RibbonFontManager::FontType::Icons, 0 .7f );
362365 const float inputWidth = cSearchSize * UI::scale () - style.FramePadding .x - style.ItemSpacing .x - ImGui::CalcTextSize ( " \xef\x80\x82 " ).x ;
363- ImGui::SetCursorPos ( ImVec2 ( cursorPos .x + inputWidth + style.ItemSpacing .x , cursorPos .y + style.FramePadding .y ) );
366+ ImGui::SetCursorPos ( ImVec2 ( cursorPosWindow .x + inputWidth + style.ItemSpacing .x , cursorPosWindow .y + style.FramePadding .y ) );
364367 ImGui::Text ( " %s" , " \xef\x80\x82 " );
365368 font.popFont ();
366369 if ( colorNum )
@@ -369,7 +372,7 @@ bool RibbonMenuSearch::searchInputText_( const char* label, std::string& str )
369372 if ( ImGui::IsItemClicked ( ImGuiMouseButton_Left ) )
370373 activate ();
371374
372- ImGui::SetCursorPos ( cursorPos );
375+ ImGui::SetCursorPos ( cursorPosWindow );
373376 ImGui::SetNextItemWidth ( inputWidth );
374377 ImGui::PushStyleColor ( ImGuiCol_FrameBg, Color::transparent ().getUInt32 () );
375378 ImGui::PushStyleColor ( ImGuiCol_Border, Color::transparent ().getUInt32 () );
0 commit comments