| 1279 | } |
| 1280 | |
| 1281 | float ImGuiMenu::drawSelectionInformation_() |
| 1282 | { |
| 1283 | const auto& selectedObjs = SceneCache::getAllObjects<Object, ObjectSelectivityType::Selected>(); |
| 1284 | |
| 1285 | auto& style = ImGui::GetStyle(); |
| 1286 | |
| 1287 | float baseCursorScreenPos = ImGui::GetCursorScreenPos().y; |
| 1288 | auto resultingHeight = [&] |
| 1289 | { |
| 1290 | return ImGui::GetCursorScreenPos().y - baseCursorScreenPos; |
| 1291 | }; |
| 1292 | |
| 1293 | if ( !drawCollapsingHeader_( _tr( "Information" ), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_AllowOverlap ) || selectedObjs.empty() ) |
| 1294 | return resultingHeight(); |
| 1295 | |
| 1296 | // draw World/Local toggles |
| 1297 | { |
| 1298 | auto pos = ImGui::GetCursorPos(); |
| 1299 | pos.x += ImGui::GetContentRegionAvail().x + style.WindowPadding.x * 0.5f - style.FramePadding.x; |
| 1300 | pos.y -= ImGui::GetFrameHeightWithSpacing(); |
| 1301 | const auto frameHeight = ImGui::GetFrameHeight(); |
| 1302 | |
| 1303 | ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, { 8.f * UI::scale(), 3.f * UI::scale() } ); |
| 1304 | ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, style.ItemInnerSpacing ); |
| 1305 | RibbonFontHolder iconsFont( RibbonFontManager::FontType::SemiBold, 0.75f ); |
| 1306 | const auto worldText = s_tr( "WORLD" ); |
| 1307 | const auto localText = s_tr( "LOCAL" ); |
| 1308 | const auto worldTextSize = ImGui::CalcTextSize( worldText.c_str() ); |
| 1309 | const auto localTextSize = ImGui::CalcTextSize( localText.c_str() ); |
| 1310 | const ImVec2 layoutSize { |
| 1311 | worldTextSize.x + localTextSize.x + style.ItemSpacing.x + style.FramePadding.x * 4, |
| 1312 | std::max( worldTextSize.y, localTextSize.y ) + style.FramePadding.y * 2, |
| 1313 | }; |
| 1314 | |
| 1315 | // draw invisible button to prevent misclicking the header |
| 1316 | ImGui::SetCursorPos( { pos.x - layoutSize.x - style.ItemSpacing.x, pos.y } ); |
| 1317 | ImGui::SetNextItemAllowOverlap(); |
| 1318 | ImGui::InvisibleButton( "##CoordToggleBackground", { layoutSize.x + style.ItemSpacing.x * 2, frameHeight } ); |
| 1319 | |
| 1320 | pos.x -= layoutSize.x; |
| 1321 | pos.y += ( frameHeight - layoutSize.y ) / 2; |
| 1322 | ImGui::SetCursorPos( pos ); |
| 1323 | |
| 1324 | auto showToggleButton = [&] ( const char* label, CoordType coordType ) |
| 1325 | { |
| 1326 | const auto enabled = coordType_ == coordType; |
| 1327 | if ( enabled ) |
| 1328 | { |
| 1329 | ImGui::PushStyleColor( ImGuiCol_Text, Color::white() ); |
| 1330 | ImGui::PushStyleColor( ImGuiCol_Button, style.Colors[ImGuiCol_ButtonActive] ); |
| 1331 | } |
| 1332 | else |
| 1333 | { |
| 1334 | if ( ColorTheme::getPreset() == ColorTheme::Preset::Dark ) |
| 1335 | { |
| 1336 | ImGui::PushStyleColor( ImGuiCol_Button, Color::black() * .20f ); |
| 1337 | ImGui::PushStyleColor( ImGuiCol_ButtonHovered, Color::black() * .30f ); |
| 1338 | ImGui::PushStyleColor( ImGuiCol_ButtonActive, Color::black() * .30f ); |
nothing calls this directly
no test coverage detected