Author Topic: Some UI refactoring/tidy up  (Read 47007 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Some UI refactoring/tidy up
« Reply #45 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.)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #46 on: September 04, 2012, 07:29:14 pm »
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
« Last Edit: September 04, 2012, 07:31:56 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #47 on: September 04, 2012, 08:00:52 pm »
try this:

Code
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()
 };

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Some UI refactoring/tidy up
« Reply #48 on: September 05, 2012, 01:01:17 am »
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.
try this:
The page disappears correctly, but you may run into trouble with lines like:
Code
bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}
and
Code
    //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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #49 on: September 05, 2012, 02:40:45 am »
The page disappears correctly, but you may run into trouble with lines like:
Code
bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}
and
Code
    //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.

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Some UI refactoring/tidy up
« Reply #50 on: September 06, 2012, 04:29:02 pm »
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?! :-)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Some UI refactoring/tidy up
« Reply #51 on: September 06, 2012, 04:59: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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #52 on: September 06, 2012, 05:03: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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Some UI refactoring/tidy up
« Reply #53 on: September 06, 2012, 05:20:07 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #54 on: September 06, 2012, 05:23:27 pm »
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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Some UI refactoring/tidy up
« Reply #55 on: September 06, 2012, 06:02:29 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #56 on: September 06, 2012, 06:15:13 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Some UI refactoring/tidy up
« Reply #57 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.

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Some UI refactoring/tidy up
« Reply #58 on: September 07, 2012, 08:53:49 am »
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!!

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Some UI refactoring/tidy up
« Reply #59 on: September 08, 2012, 02:27:29 am »
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:
Code
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()