News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

how to forbid a refresh when a tree item get double clicked

Started by ollydbg, June 14, 2009, 06:49:25 PM

Previous topic - Next topic

ollydbg

Hi, I found an issue( In fact, I have reported in http://forums.next.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.



I found this behavior comes from these 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.


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


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


Any comments?

Thanks.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Quote from: ollydbg on June 14, 2009, 06:49:25 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. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

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.

ollydbg

thanks for alll the replies!

Quote from: jens on June 14, 2009, 09:01:45 PM
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. :(





If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Jenna

Quote from: ollydbg on June 15, 2009, 04:11:49 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).

ollydbg

@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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Quote from: ollydbg on June 20, 2009, 03:27:39 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.

Quote from: ollydbg on June 20, 2009, 03:27:39 PM
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:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Quote from: MortenMacFly on June 22, 2009, 06:57:37 AM
Quote from: ollydbg on June 20, 2009, 03:27:39 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.
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.next.codeblocks.org/index.php/topic,10594.msg72683.html#msg72683

And the thread:
http://forums.next.codeblocks.org/index.php/topic,10124.0.html
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Quote from: MortenMacFly on June 22, 2009, 06:57:37 AM
Quote from: ollydbg on June 20, 2009, 03:27:39 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.

Quote from: ollydbg on June 20, 2009, 03:27:39 PM
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!!!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Quote from: ollydbg on July 07, 2009, 02:26:29 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Quote from: MortenMacFly on July 07, 2009, 04:18:16 PM
Quote from: ollydbg on July 07, 2009, 02:26:29 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...
@Macfly
Thanks
I checked out the new CC branch, but failed on compiling.
see the log in this post:
http://forums.next.codeblocks.org/index.php/topic,10813.0.html
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

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
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

This is a reminder, this problem is fixed in the rev 5945.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.