News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Some UI refactoring/tidy up

Started by dmoore, August 11, 2012, 05:07:31 AM

Previous topic - Next topic

Alpha

The page is still visible after your resequencing.

RemovePage() does work, however, that would take much more effort to work properly (and may introduce a memory leak).  (DeletePage() may be the best choice, but a quick test crashed Code::Blocks - methods try to access the deleted objects.)

dmoore

#46
Quote from: Alpha on September 03, 2012, 07:13:17 AM
The page is still visible after your resequencing.

RemovePage() does work, however, that would take much more effort to work properly (and may introduce a memory leak).  (DeletePage() may be the best choice, but a quick test crashed Code::Blocks - methods try to access the deleted objects.)

So I gather this issue predates my recent changes and was actually introduced here
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

try this:


Index: src/sdk/findreplacedlg.cpp
===================================================================
--- src/sdk/findreplacedlg.cpp (revision 8351)
+++ src/sdk/findreplacedlg.cpp (working copy)
@@ -194,11 +194,13 @@
         XRCCTRL(*this, "chkFixEOLs2",   wxCheckBox)->Hide();
     }

+    m_findPage=0;
     if (findReplaceInFilesOnly)
     {
-        // NOTE (jens#1#): Do not delete, just hide the page, to avoid asserts in debug-mode
+        //Remove, but don't destroy the Find/Replace page until this dialog is destroyed.
         XRCCTRL(*this, "nbReplace", wxNotebook)->SetSelection(1);
-        (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Hide(); // no active editor, so only replace-in-files
+        m_findPage=(XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0)); // no active editor, so only replace-in-files
+        (XRCCTRL(*this, "nbReplace", wxNotebook)->RemovePage(0)); // no active editor, so only replace-in-files
         XRCCTRL(*this, "cmbFind2", wxComboBox)->SetFocus();
     }
     else if (m_findReplaceInFilesActive)
@@ -270,6 +272,11 @@
     cfg->Write(CONF_GROUP _T("/regex2"),      XRCCTRL(*this, "chkRegEx2",     wxCheckBox)->GetValue());
     cfg->Write(CONF_GROUP _T("/scope2"),      XRCCTRL(*this, "rbScope2",      wxRadioBox)->GetSelection());

+    if(m_findPage!=0)
+    {
+        m_findPage->Destroy();
+    }
+
     Disconnect(XRCID("nbReplace"), wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(FindReplaceDlg::OnReplaceChange));
}

Index: src/include/findreplacedlg.h
===================================================================
--- src/include/findreplacedlg.h (revision 8351)
+++ src/include/findreplacedlg.h (working copy)
@@ -62,6 +62,7 @@
         void SaveComboValues(wxComboBox* combo, const wxString& configKey);
         bool m_findReplaceInFilesActive;
         bool m_findMode;
+        wxWindow *m_findPage;

         DECLARE_EVENT_TABLE()
};
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Alpha

Quote from: dmoore on September 04, 2012, 07:29:14 PM
So I gather this issue predates my recent changes and was actually introduced here
Sorry; I am not sure why I never noticed this before.
Quote from: dmoore on September 04, 2012, 08:00:52 PM
try this:
The page disappears correctly, but you may run into trouble with lines like:

bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}

and

    //After hiding/showing panels, redo the layout in the notebook pages
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Layout();
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(1))->Layout();

because (from what I can tell in the documentation) there now would only exist a single page (GetSelection() would always == 0).


In the find menu, enable regular expressions and search something.  Now open find in files, switch to the find tab, and disable regular expressions.  The direction boxes (incorrectly) remain disabled.

dmoore

Quote from: Alpha on September 05, 2012, 01:01:17 AM
The page disappears correctly, but you may run into trouble with lines like:

bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}

and

    //After hiding/showing panels, redo the layout in the notebook pages
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Layout();
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(1))->Layout();

because (from what I can tell in the documentation) there now would only exist a single page (GetSelection() would always == 0).

In the find menu, enable regular expressions and search something.  Now open find in files, switch to the find tab, and disable regular expressions.  The direction boxes (incorrectly) remain disabled.

OK, there were only a few instances of that so I made the needed changes and committed them.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

daniloz

I really like the new Find/Replace windows. Nice work!

I just notice a bug (svn r8362, gcc 4.6.1, win7 64bit):
-> if I press Ctrl-F, which brings up the Find dialog, and start typing (without clinking on "Text to search for" text entry) I don't see what I'm typing, however it get entered somehow.

-> So, if I type "foo", then click on the text entry box and type "bar", I got the message "Not found: foo".

-> On the other hand, if I bring up the dialog again and first click on the text entry box and type "bar", I got the message: "Can't look for an empty search criterion!"

Is it only me?! :-)

MortenMacFly

Quote from: daniloz on September 06, 2012, 04:29:02 PM
Is it only me?! :-)
No, confirmed here. It seems the wrong text boxes are toggled on initialisation. You are actually typing either in the replace, or in the multi-line find box.
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]

dmoore

Quote from: MortenMacFly on September 06, 2012, 04:59:02 PM
Quote from: daniloz on September 06, 2012, 04:29:02 PM
Is it only me?! :-)
No, confirmed here. It seems the wrong text boxes are toggled on initialisation. You are actually typing either in the replace, or in the multi-line find box.

Well this is strange, because I don't have the issue here(!?). Also using win7.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: dmoore on September 06, 2012, 05:03:02 PM
Well this is strange, because I don't have the issue here(!?). Also using win7.
I'll do a full re-compile. Maybe its an old resource or alike...
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]

dmoore

Sorry! I didn't realize I was so many revs behind. I just updated and now confirm. Seems to be a problem after the XRC rename, morten?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: dmoore on September 06, 2012, 05:23:27 PM
Seems to be a problem after the XRC rename, morten?
I doubt... Why would that cause such a strange issue?
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]

dmoore

Quote from: MortenMacFly on September 06, 2012, 06:02:29 PM
Quote from: dmoore on September 06, 2012, 05:23:27 PM
Seems to be a problem after the XRC rename, morten?
I doubt... Why would that cause such a strange issue?

You're right! nevermind, I found the (stupid) bug and will commit a fix.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

Ok, I fixed the bug, tested carefully (but only on windows) and committed the fix in rev 8369. Let me know if there are any other issues.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

daniloz

Quote from: dmoore on September 06, 2012, 06:37:15 PM
Ok, I fixed the bug, tested carefully (but only on windows) and committed the fix in rev 8369. Let me know if there are any other issues.
Fix confirmed here as well (win7).

Thanks!!

Alpha

Focus does not shift correctly when switching tabs in wxgtk (due to tab events being generated on mouse down instead of mouse up); the following can address this:

Index: src/sdk/findreplacedlg.cpp
===================================================================
--- src/sdk/findreplacedlg.cpp (revision 8376)
+++ src/sdk/findreplacedlg.cpp (working copy)
@@ -34,6 +34,9 @@
BEGIN_EVENT_TABLE(FindReplaceDlg, wxScrollingDialog)
     EVT_ACTIVATE(                        FindReplaceDlg::OnActivate)
     EVT_CHECKBOX(XRCID("chkRegEx1"),     FindReplaceDlg::OnRegEx)
+#ifdef __WXGTK__
+    EVT_IDLE(                            FindReplaceDlg::OnIdle)
+#endif

     // Special events for Replace
     EVT_CHECKBOX(XRCID("chkMultiLine1"), FindReplaceDlg::OnMultiChange)
@@ -50,6 +53,9 @@
     : FindReplaceBase(parent, initial, hasSelection),
     m_findReplaceInFilesActive(findReplaceInFilesActive),
     m_findMode(findMode)
+#ifdef __WXGTK__
+    ,m_setFocus(false)
+#endif
{
     wxXmlResource::Get()->LoadObject(this, parent, _T("dlgFindReplace"),_T("wxScrollingDialog"));
     ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));
@@ -552,7 +558,9 @@
             m_findReplaceInFilesActive = true;
         }
     }
-
+#ifdef __WXGTK__
+    m_setFocus = true;
+#endif
     Refresh();
     event.Skip();
}
@@ -672,3 +680,26 @@
     values.Insert(find, 0);
     Manager::Get()->GetConfigManager(_T("editor"))->Write(configKey, values);
}
+
+#ifdef __WXGTK__
+void FindReplaceDlg::OnIdle(wxIdleEvent& event)
+{
+    if (m_setFocus && !wxGetMouseState().LeftIsDown())
+    {
+        m_setFocus = false;
+        if ( IsMultiLine() )
+        {
+            wxTextCtrl* tcp = ( IsFindInFiles() ? XRCCTRL(*this, "txtMultiLineFind2", wxTextCtrl)
+                                                : XRCCTRL(*this, "txtMultiLineFind1", wxTextCtrl) );
+            if (tcp) tcp->SetFocus();
+        }
+        else
+        {
+            wxComboBox* cbp =  ( IsFindInFiles() ? XRCCTRL(*this, "cmbFind2", wxComboBox)
+                                                 : XRCCTRL(*this, "cmbFind1", wxComboBox) );
+            if (cbp) cbp->SetFocus();
+        }
+    }
+    event.Skip();
+}
+#endif
Index: src/include/findreplacedlg.h
===================================================================
--- src/include/findreplacedlg.h (revision 8376)
+++ src/include/findreplacedlg.h (working copy)
@@ -62,6 +62,10 @@
         void SaveComboValues(wxComboBox* combo, const wxString& configKey);
         bool m_findReplaceInFilesActive;
         bool m_findMode;
+#ifdef __WXGTK__
+        void OnIdle(wxIdleEvent& event);
+        bool m_setFocus;
+#endif
         wxWindow *m_findPage;

         DECLARE_EVENT_TABLE()