Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on June 14, 2009, 06:49:25 pm

Title: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on June 14, 2009, 06:49:25 pm
Hi, I found an issue( In fact, I have reported in http://forums.codeblocks.org/index.php/topic,9873.msg69760.html#msg69760, but nobody give any response :(. This is really an annoying issue!)

When I double click on a tree item in the CodeCompletion's classbrowser, then the tree control will get refreshed, meanwhile the scroll bar will go down to the bottom of the window.

(http://sites.google.com/site/studycodeblocks/imagescb/cbreflash.png)

I found this behavior comes from these code:

Code
void ClassBrowser::OnTreeItemDoubleClick(wxTreeEvent& event)
{
    wxTreeCtrl* tree = (wxTreeCtrl*)event.GetEventObject();
wxTreeItemId id = event.GetItem();
CBTreeData* ctd = (CBTreeData*)tree->GetItemData(id);
    if (ctd && ctd->m_pToken)
    {
        if (wxGetKeyState(WXK_CONTROL) && wxGetKeyState(WXK_SHIFT))
        {
            CCDebugInfo info(tree, m_pParser, ctd->m_pToken);
            info.ShowModal();
            return;
        }

        cbProject* prj = Manager::Get()->GetProjectManager()->GetActiveProject();
        if (prj)
        {
bool toImp = false;
switch (ctd->m_pToken->m_TokenKind)
{
case tkConstructor:
            case tkDestructor:
            case tkFunction:
                if (ctd->m_pToken->m_ImplLine != 0 && !ctd->m_pToken->GetImplFilename().IsEmpty())
                    toImp = true;
break;
default:
break;
}

            wxString base = prj->GetBasePath();
            wxFileName fname;
            if (toImp)
                fname.Assign(ctd->m_pToken->GetImplFilename());
            else
                fname.Assign(ctd->m_pToken->GetFilename());

            NormalizePath(fname, base);
         cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetFullPath());
if (ed)
{
int line;
                if (toImp)
                    line = ctd->m_pToken->m_ImplLine - 1;
                else
                    line = ctd->m_pToken->m_Line - 1;
ed->GotoLine(line);
// // try to move the caret on the exact token
// int lineOffset = ed->GetControl()->GetCurLine().Find(ctd->m_pToken->m_Name);
// if (lineOffset != wxNOT_FOUND)
// {
//                    int pos = ed->GetControl()->PositionFromLine(line) + lineOffset;
//                    ed->GetControl()->GotoPos(pos);
//                    // select the token
//                    int posend = ed->GetControl()->WordEndPosition(pos, true);
//                    ed->GetControl()->SetSelection(pos, posend);
// }

wxFocusEvent ev(wxEVT_SET_FOCUS);
ev.SetWindow(this);
#if wxCHECK_VERSION(2, 9, 0)
ed->GetControl()->GetEventHandler()->AddPendingEvent(ev);
#else
ed->GetControl()->AddPendingEvent(ev);
#endif
}
        }
    }
}


Since after running this function, the whole panel will get refreshed, then UpdateView() will be called.

In UpdateView(), precisely in the function void ClassBrowser::BuildTree(), the "treeMembers" TreeCtrl will be rebuild from a ClassBrowserBuilderThread.

Then after the tree was reconstructed, the Scroll bar will slip down to the bottom of that window.

So, my suggestion is:

If I can forbid a refresh event after doubleclick, the "treemembers" TreeCtrl would keep its position.

Or, we can supply a separate handler, because currently, both treeAll and treemembers share this handler.

Code
	EVT_TREE_ITEM_ACTIVATED(XRCID("treeMembers"), ClassBrowser::OnTreeItemDoubleClick) 


EVT_TREE_ITEM_ACTIVATED(XRCID("treeAll"), ClassBrowser::OnTreeItemDoubleClick)        

Any comments?

Thanks.

Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: MortenMacFly on June 14, 2009, 08:46:03 pm
Or, we can supply a separate handler, because currently, both treeAll and treemembers share this handler.
Any comments?
This sounds most convenient to me. :-)
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: Jenna on June 14, 2009, 09:01:45 pm
This does only happen, if the view is "Current files's symbols".

And what's more, if I see it right, it does not happen in new CC, what's currently in testing phase.
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on June 15, 2009, 04:11:49 am
thanks for alll the replies!

This does only happen, if the view is "Current files's symbols".

Yes, seems it only affects the "current files's symbols"
Quote
And what's more, if I see it right, it does not happen in new CC, what's currently in testing phase.

I have just download and build the AUI_branch(windows MinGW), but I found this issue still happens there. :(





Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: Jenna on June 15, 2009, 06:42:36 am
I have just download and build the AUI_branch(windows MinGW), but I found this issue still happens there. :(

That's because the new CC-code is not (yet) in any branch.

By the way, the issue only appears (at least for me), if the double-clicked token is in another file (normally the header or source file with the same basename).
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on June 20, 2009, 03:27:39 pm
@Jens:

Where can I find the new CC code (patch)? I would like to test them :D

BTW:
Why the scrollingdialog patch were still not applied in trunk? I think it is quite useful? Thanks.
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: MortenMacFly on June 22, 2009, 06:57:37 am
Where can I find the new CC code (patch)? I would like to test them :D
I'll put it into SVN once the wxAUI merge is done.
I believe meanwhile I am the only one maintaining all the mods for CC.

Why the scrollingdialog patch were still not applied in trunk? I think it is quite useful? Thanks.
...which one? If you mean the huge one of Jens he explained in the thread why this most likely won't e applied. (Although I don't recall myself now...) :lol:
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on June 22, 2009, 08:15:01 am
Where can I find the new CC code (patch)? I would like to test them :D
I'll put it into SVN once the wxAUI merge is done.
I believe meanwhile I am the only one maintaining all the mods for CC.
I'm ready for testing :D, once it is in SVN.

Quote
...which one? If you mean the huge one of Jens he explained in the thread why this most likely won't e applied.
The one in this post:
http://forums.codeblocks.org/index.php/topic,10594.msg72683.html#msg72683

And the thread:
http://forums.codeblocks.org/index.php/topic,10124.0.html
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: MortenMacFly on June 22, 2009, 08:17:57 am
http://forums.codeblocks.org/index.php/topic,10124.0.html
This:
http://forums.codeblocks.org/index.php/topic,10124.msg70390.html#msg70390
was IMHO the reason not to apply this. But I believe Jens had another issue...?!
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on July 07, 2009, 02:26:29 pm
Where can I find the new CC code (patch)? I would like to test them :D
I'll put it into SVN once the wxAUI merge is done.
I believe meanwhile I am the only one maintaining all the mods for CC.

Why the scrollingdialog patch were still not applied in trunk? I think it is quite useful? Thanks.
...which one? If you mean the huge one of Jens he explained in the thread why this most likely won't e applied. (Although I don't recall myself now...) :lol:

I'm grad to see that the wxAUI branch is merged to trunk!

So, I'm grad that the new CC code will be added and tested!

Thanks to all the devs!!!
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: MortenMacFly on July 07, 2009, 04:18:16 pm
So, I'm grad that the new CC code will be added and tested!
This is already done in a new branch called "codecompletion_refactoring" -> feel free to try...
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on July 08, 2009, 08:01:30 am
So, I'm grad that the new CC code will be added and tested!
This is already done in a new branch called "codecompletion_refactoring" -> feel free to try...
@Macfly
Thanks
I checked out the new CC branch, but failed on compiling.
see the log in this post:
http://forums.codeblocks.org/index.php/topic,10813.0.html
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on July 08, 2009, 11:53:23 am
Let's continue my original topic.(I test in new CC branch)

It seems first time, I double click on the entry will still cause a scroll down move(as I stated in my original post).

After that, double click on the entry will keep the tree position. quite strange. :D

Edit:
I find more detailed information:

When I double click on an tree entry, if it will switch the "tab"( for example, from XXX.h to XXX.cpp) , then the tree will get refreshed, but that was by design. :D
Title: Re: how to forbid a refresh when a tree item get double clicked
Post by: ollydbg on December 23, 2009, 01:31:25 pm
This is a reminder, this problem is fixed in the rev 5945.