Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiSelect problem #37

Closed
Nitr0-G opened this issue Feb 26, 2024 · 4 comments
Closed

MultiSelect problem #37

Nitr0-G opened this issue Feb 26, 2024 · 4 comments

Comments

@Nitr0-G
Copy link

Nitr0-G commented Feb 26, 2024

Hi! Thank you so much for such a thing as ImGui and thank you so much for the large number of examples and various ready-made widgets/snippets!

Is multiselect of bytes support planned here? Something like this ocornut/imgui#1861

@ocornut
Copy link
Owner

ocornut commented Feb 26, 2024

Hello,
I never thought of it in the context of the memory-editor, AFAIK multi-select imply stuff like deleting a selection, which imply offsetting and resizing the buffer, at that point we are leading toward a more full-featured hex editor.

Which multi-select feature in particular were you thinking about?

@Nitr0-G
Copy link
Author

Nitr0-G commented Feb 27, 2024

Hello, I never thought of it in the context of the memory-editor, AFAIK multi-select imply stuff like deleting a selection, which imply offsetting and resizing the buffer, at that point we are leading toward a more full-featured hex editor.

Which multi-select feature in particular were you thinking about?

Hi, I was thinking about multi-selections in the form of copying bytes and selecting them to convert, for example, to a string.
For example, as here:
изображение

https://github.com/WerWolv/ImHex/blob/491e2dfe56aef9778317cc80f62705101acaaccd/plugins/ui/source/ui/hex_editor.cpp#L399

I apologize for the long answer.

@Nitr0-G
Copy link
Author

Nitr0-G commented Mar 4, 2024

I started doing multiselection and first I made a function to calculate if I am in a cell. If I'm in cell, then next I look at mouse click and dragging.

    bool IsMouseHoveringCurrentTableCell(float rowHeight)
    {
        ImVec2 cellMin = ImGui::GetCursorScreenPos();
        ImVec2 cellMax = ImVec2(cellMin.x + ImGui::GetColumnWidth(), cellMin.y + rowHeight);
        return ImGui::IsMouseHoveringRect(cellMin, cellMax);
    }
    
    static void HandleCellSelection() 
    {
        if (ImGui::IsMouseDragging(ImGuiMouseButton_Left))
        {

        }
        else if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
        {
            if (ImGui::GetIO().KeyShift)
            {

            }
            else
            {

            }
        }
    }
    
    void DrawContents(void* mem_data_void, size_t mem_size, size_t base_display_addr = 0x0000)
    {
    ... code
          if (IsMouseHoveringCurrentTableCell(17) && ImGui::IsWindowHovered())
          {
                   HandleCellSelection();
          }
    ... code                    
    }

Omar, I need your little help. How can I draw a rectangle on top of the cell? Since such an implementation seems to work, but it doesn't seem to, since the rectangle itself simply does not exist.


        auto drawList = ImGui::GetWindowDrawList();

        // Draw background color
        drawList->AddRectFilled(cellPos, { cellPos.x + cellSize.x, cellPos.y + cellSize.y }, backgroundColor);

        // Draw selection frame as a square
        ImU32 SelectionFrameColor = ImGui::GetColorU32(ImGuiCol_Text);
        drawList->AddRect(cellPos, { cellPos.x + cellSize.x, cellPos.y + cellSize.y }, SelectionFrameColor, 0, ImDrawFlags_RoundCornersAll, 1);

@Nitr0-G
Copy link
Author

Nitr0-G commented Mar 10, 2024

I made it
изображение
I also made a right-click menu and a lot of other things.

@Nitr0-G Nitr0-G closed this as completed Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants