Repository: wolfpld/tracy
File: server/TracyView_FindZone.cpp (C++)

Code before:
                            {
                                zonePos = round( ( zoneTime - tmin ) / float( tmax - tmin ) * numBins );
                            }
                            const auto c = uint32_t( ( sin( s_time * 10 ) * 0.25 + 0.75 ) * 255 );
                            const auto color = 0xFF000000 | ( c << 16 ) | ( c << 8 ) | c;
                            DrawLine( draw, ImVec2( dpos.x + zonePos, dpos.y ), ImVec2( dpos.x + zonePos, dpos.y+Height-2 ), color );
                            m_wasActive = true;
                        }
                    }
                }
            }

            ImGui::TreePop();
        }

        ImGui::Separator();
        SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames );
        ImGui::Separator();

        ImGui::AlignTextToFramePadding();
        TextDisabledUnformatted( "Filter user text:" );
        ImGui::SameLine();
        bool filterChanged = m_userTextFilter.Draw( ICON_FA_FILTER "###resultFilter", 200 );

        ImGui::SameLine();
        if( ImGui::Button( ICON_FA_DELETE_LEFT " Clear" ) )
        {
            m_userTextFilter.Clear();
            filterChanged = true;
        }
        ImGui::Separator();
        if( filterChanged )
        {
            m_findZone.ResetGroups();
        }

        ImGui::TextUnformatted( "Found zones:" );
        ImGui::SameLine();
        DrawHelpMarker( "Left click to highlight entry." );
        if( m_findZone.selGroup != m_findZone.Unselected )
        {
            ImGui::SameLine();
            if( ImGui::SmallButton( ICON_FA_DELETE_LEFT " Clear" ) )
            {
                m_findZone.selGroup = m_findZone.Unselected;
                m_findZone.ResetSelection();
            }
        }

        bool groupChanged = false;
        ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );

Review comment (suggestion):
This button ID clashes with one that is already present. Can be fixed by appending e.g. `##userText` after the button text.

Code after:
                            {
                                const auto ltmin = log10( tmin );
                                const auto ltmax = log10( tmax );
                                zonePos = round( ( log10( zoneTime ) - ltmin ) / float( ltmax - ltmin ) * numBins );
                            }
                            else
                            {
                                zonePos = round( ( zoneTime - tmin ) / float( tmax - tmin ) * numBins );
                            }
                            const auto c = uint32_t( ( sin( s_time * 10 ) * 0.25 + 0.75 ) * 255 );
                            const auto color = 0xFF000000 | ( c << 16 ) | ( c << 8 ) | c;
                            DrawLine( draw, ImVec2( dpos.x + zonePos, dpos.y ), ImVec2( dpos.x + zonePos, dpos.y+Height-2 ), color );
                            m_wasActive = true;
                        }
                    }
                }
            }

            ImGui::TreePop();
        }

        ImGui::Separator();
        SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames );
        ImGui::Separator();

        ImGui::AlignTextToFramePadding();
        TextDisabledUnformatted( "Filter user text:" );
        ImGui::SameLine();
        bool filterChanged = m_userTextFilter.Draw( ICON_FA_FILTER "###resultFilter", 200 );

        ImGui::SameLine();
        if( ImGui::Button( ICON_FA_DELETE_LEFT " Clear###userText" ) )
        {
            m_userTextFilter.Clear();
            filterChanged = true;
        }
        ImGui::Separator();
        if( filterChanged )
        {
            m_filteredZones.clear();
            m_findZone.ResetGroups();
        }

        ImGui::TextUnformatted( "Found zones:" );
        ImGui::SameLine();
        DrawHelpMarker( "Left click to highlight entry." );
        if( m_findZone.selGroup != m_findZone.Unselected )
        {
            ImGui::SameLine();
            if( ImGui::SmallButton( ICON_FA_DELETE_LEFT " Clear" ) )
            {