← Back to team overview

kicad-developers team mailing list archive

Re: eeschema modular kicad work

 

> I don't know if it is technically possible to change this behaviour, but 
> I think it could be a great improvement.
> 
:
> yann
>

Hopefully QuasiModal is not a monster.

For significant dialogs (ones which tend to be open for a while) using the QuasiModal
support in DIALOG_SHIM might be a solution to this.  It disables the window which invokes
the dialog, but nothing more.

Without the QuasiModal support, the behaviour is platform specific.  On linux, I *CAN*
open the schematic editor while viewing footprint properties and scroll, but I cannot
close the schematic window.  So that behaviour is arguably worse, since it looks like a
bug.  (It is not a bug that I would respond to.  Let's register it as folklore.)

Remember if you cannot close a major KIWAY_PLAYER using system window decorations, this
might be because you have a dialog window opened elsewhere on linux.

Please see if this patch fixes the sample issue for you.  The QuasiModal support was
something I came up with using only the wxWindows API, not a platform specific approach.
I don't know that its been tested enough across all platforms.  Bad news is that there may
not be anything I can do except for Linux to fix it, should it not work wonderfully on all
platforms.

If this patch works wonderfully, then someone wanting to contribute more of the same style
is welcome to.  Simply consider ShowModal() and EndModal() to be a matched set.  Replace
them with ShowQuasiModal() and EndQuasiModal() respectively.  Do not mix, keep the set
matched.

For me, not all dialogs are likely to be as *prominent* as others, i.e. their lifetimes.
In some cases we've used modeless dialogs.  That makes sense where we've used it, but it
requires an entirely different coding style from modal and quasimodal.  So injecting this
kind of quasimodal patch is easier than going full modal.

It might be prudent to introduce a couple of macros

#define ENDQUASIMODAL	EndQuasiModal
#define SHOWQUASIMODAL	ShowQuasiModal

So this can be turned off globally and revert to true modal if something bad gets
discovered down the line.  Then after enough testing we can do global search and replace
and jump off the macros.


Dick

=== modified file 'pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp'
--- pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp	2014-08-13 20:28:54 +0000
+++ pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp	2014-08-14 14:00:59 +0000
@@ -182,7 +182,7 @@
 
 void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& event )
 {
-    EndModal( -1 );
+    EndQuasiModal( -1 );
 }
 
 
@@ -194,7 +194,7 @@
         m_Parent->OnModify();
     }
 
-    EndModal( 2 );
+    EndQuasiModal( 2 );
 }
 
 
@@ -204,7 +204,7 @@
 
     // Warning: m_CurrentModule was deleted by exchange module
     m_Parent->SetCurItem( NULL );
-    EndModal( 0 );
+    EndQuasiModal( 0 );
 }
 
 
@@ -675,7 +675,7 @@
 
     m_Parent->OnModify();
 
-    EndModal( 1 );
+    EndQuasiModal( 1 );
 
     if( m_DC )
     {

=== modified file 'pcbnew/editmod.cpp'
--- pcbnew/editmod.cpp	2014-05-18 15:16:59 +0000
+++ pcbnew/editmod.cpp	2014-08-14 13:59:27 +0000
@@ -59,12 +59,12 @@
     DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, NULL );
 #endif
 
-    int retvalue = dialog->ShowModal(); /* retvalue =
-                                         *  -1 if abort,
-                                         *  0 if exchange module,
-                                         *  1 for normal edition
-                                         *  and 2 for a goto editor command
-                                         */
+    int retvalue = dialog->ShowQuasiModal();    /* retvalue =
+                                                 *  -1 if abort,
+                                                 *  0 if exchange module,
+                                                 *  1 for normal edition
+                                                 *  and 2 for a goto editor command
+                                                 */
     dialog->Destroy();
 
 #ifdef __WXMAC__


Follow ups

References