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

I can not drag a panel to an empty wxAuiNotebook from another wxAuiNotebook #24111

Open
asmwarrior opened this issue Dec 2, 2023 · 8 comments
Labels
AUI Related to wxAUI library.

Comments

@asmwarrior
Copy link
Contributor

I'm using wxWidgets 3.2.4 and Windows 10 64bit, running the wxAui sample project.

If I have two wxAuiNotebook, and both of them are not empty, I can drag the panel between those wxAuiNotebooks if the style option: wxAUI_NB_TAB_EXTERNAL_MOVE is enabled.

See below image shot:
image

Now, if the target wxAuiNotebook get empty. I mean there is NO tabs in the target wxAuiNotebook, now I can not drag a panel to this empty wxAuiNotebook, is this by design?

See below image:
image

Any ideas? Thanks.

@asmwarrior
Copy link
Contributor Author

Another question is that when the drag happens between two wxAuiNotebooks, how do I know where is the source of the wxAuiNotebook, and where is the destination of the target wxAuiNotebook? I mean currently, I don't see the wxAuiNotebookEvent class brings such information. Any ideas? Thanks.

I add three functions in the wxAui sample code

    EVT_AUINOTEBOOK_BEGIN_DRAG(wxID_ANY, MyFrame::OnNotebookBeginDrag)
    EVT_AUINOTEBOOK_END_DRAG(wxID_ANY, MyFrame::OnNotebookEndDrag)
    EVT_AUINOTEBOOK_DRAG_DONE(wxID_ANY, MyFrame::OnNotebookDragDone)

I can catch an event when the cross wxAuiNotebook drag done in the MyFrame::OnNotebookDragDone, but I see that

void MyFrame::OnNotebookDragDone(wxAuiNotebookEvent &event)
{
    wxAuiNotebook* dragSource = event.GetDragSource(); 

    int dropTarget = event.GetSelection(); 

    event.Skip();
}

The dragSource is always 0x0 in my test case.

BTW: I can not catch the other events(EVT_AUINOTEBOOK_BEGIN_DRAG and EVT_AUINOTEBOOK_END_DRAG) in my test case. I can only catch a EVT_AUINOTEBOOK_DRAG_DONE event.

@asmwarrior
Copy link
Contributor Author

OK, I just debugged a while(I'm debugging with release version of wx from msys2, so when building the aui demo sample, I have to add the option -femit-class-debug-always), and I found that the wxAuiNotebookEvent event brings a pointer to the source wxAuiNotebook, see below image shot:

image

So, there is only source wxAuiNotebook pointer, I event can't figure out which panel is dragged from the source notbook to the target notebook.

@trogmaniac
Copy link

Did you check how the internal code does it?

wxWindow* tab_ctrl = ::wxFindWindowAtPoint(mouse_screen_pt);

@asmwarrior
Copy link
Contributor Author

Did you check how the internal code does it?

wxWindow* tab_ctrl = ::wxFindWindowAtPoint(mouse_screen_pt);

Hi, thanks for the reply.

It looks like if there is NO tabs in the wxAuiNotebook control, the drag will do nothing?

wxWidgets/src/aui/auibook.cpp

Lines 2732 to 2748 in 6f62907

m_curPage = src_tabs->GetActivePage();
// check for an external move
if (m_flags & wxAUI_NB_TAB_EXTERNAL_MOVE)
{
wxWindow* tab_ctrl = ::wxFindWindowAtPoint(mouse_screen_pt);
while (tab_ctrl)
{
if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl))
break;
tab_ctrl = tab_ctrl->GetParent();
}
if (tab_ctrl)
{
wxAuiNotebook* nb = (wxAuiNotebook*)tab_ctrl->GetParent();

Here, the tab_ctrl will be nullptr?

@trogmaniac
Copy link

Did you check how the internal code does it?

wxWindow* tab_ctrl = ::wxFindWindowAtPoint(mouse_screen_pt);

Hi, thanks for the reply.

It looks like if there is NO tabs in the wxAuiNotebook control, the drag will do nothing?

wxWidgets/src/aui/auibook.cpp

Lines 2732 to 2748 in 6f62907

m_curPage = src_tabs->GetActivePage();
// check for an external move
if (m_flags & wxAUI_NB_TAB_EXTERNAL_MOVE)
{
wxWindow* tab_ctrl = ::wxFindWindowAtPoint(mouse_screen_pt);
while (tab_ctrl)
{
if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl))
break;
tab_ctrl = tab_ctrl->GetParent();
}
if (tab_ctrl)
{
wxAuiNotebook* nb = (wxAuiNotebook*)tab_ctrl->GetParent();

Here, the tab_ctrl will be nullptr?

That pointer is for the whole tab control, if none is found at the mouse position, nothing will happen (as expected).

@asmwarrior
Copy link
Contributor Author

The problem here is that I would like to drag an one panel from one notebook to another notebook. But the target notebook is empty, so I do not how how to do it. Maybe wx library should handle such situation?

@trogmaniac
Copy link

I would agree that this is supposed to work. If dragging into a non-empty notebook works, dragging into an empty one should work, too.

Technically the problem is that the wxTabFrame gets destroyed when the last panel is removed.

void wxAuiNotebook::RemoveEmptyTabFrames()

I don't know why this is done, maybe you could just try to comment this out, and see what happens. Or the code that checks for a dropped notebook page has to create a new wxTabFrame when there is none.

@vadz vadz added the AUI Related to wxAUI library. label Dec 24, 2023
@vadz
Copy link
Contributor

vadz commented Dec 25, 2023

This looks like something that just hasn't been implemented. OTOH it seems pretty weird to have an empty notebook in the first place, I think a better UI would be to avoid this somehow (e.g. by destroying it entirely -- and then providing some way to recreate it later if needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AUI Related to wxAUI library.
Projects
None yet
Development

No branches or pull requests

3 participants