Re: [Kicad-developers] [PATCH] Friendlier warning for modifying power values

2015-03-23 Thread jp charras
Le 23/03/2015 05:20, Chris Pavlina a écrit :
 Currently, if you try to edit the value of a power component in
 eeschema, you get a ... is a power component and it's [sic] value
 cannot be modified! message.  That message isn't completely accurate,
 though. The edit box also allows you to change the *formatting*, which
 is perfectly valid to do for power texts. Unfortunately, that means that
 if you want to change formatting, you have to go through the
 whole-component edit dialog.
 
 This patch removes that error message. Instead, when editing a power
 component's value, the text field in the edit box is greyed out, and a
 message Power component value text cannot be modified! is displayed
 underneath it. All formatting options remain active.
 
 Chris
 

Good idea.
I committed you patch, with a very minor change (the warning message
uses the bold weight option).


-- 
Jean-Pierre CHARRAS

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


[Kicad-developers] [PATCH] Friendlier warning for modifying power values

2015-03-22 Thread Chris Pavlina
Currently, if you try to edit the value of a power component in 
eeschema, you get a ... is a power component and it's [sic] value 
cannot be modified! message.  That message isn't completely accurate, 
though. The edit box also allows you to change the *formatting*, which 
is perfectly valid to do for power texts. Unfortunately, that means that 
if you want to change formatting, you have to go through the 
whole-component edit dialog.


This patch removes that error message. Instead, when editing a power 
component's value, the text field in the edit box is greyed out, and a 
message Power component value text cannot be modified! is displayed 
underneath it. All formatting options remain active.


Chris
diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp
index 60ef3a6..13bd957 100644
--- a/eeschema/dialogs/dialog_edit_one_field.cpp
+++ b/eeschema/dialogs/dialog_edit_one_field.cpp
@@ -62,6 +62,7 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base()
 
 m_Invisible-SetValue( m_text_invisible );
 m_TextShapeOpt-SetSelection( m_textshape );
+SetPowerWarning( false );
 
 switch ( m_textHjustify )
 {
@@ -97,8 +98,15 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base()
 m_TextSizeText-SetLabel( msg );
 
 m_sdbSizerButtonsOK-SetDefault();
+
 }
 
+void DIALOG_EDIT_ONE_FIELD::SetPowerWarning( bool aWarn )
+{
+m_PowerComponentValues-Show( aWarn );
+m_TextValue-Enable( ! aWarn );
+Fit();
+}
 
 void DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick( wxCommandEvent aEvent )
 {
@@ -159,8 +167,11 @@ wxString DIALOG_LIB_EDIT_ONE_FIELD::GetTextField()
 }
 
 
-void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
+void DIALOG_EDIT_ONE_FIELD::TransfertDataToField( bool aIncludeText )
 {
+// This method doesn't transfer text anyway.
+(void) aIncludeText;
+
 m_textorient = m_Orient-GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
 wxString msg = m_TextSize-GetValue();
 m_textsize = ValueFromString( g_UserUnit, msg );
@@ -197,11 +208,12 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
 }
 
 
-void DIALOG_LIB_EDIT_ONE_FIELD::TransfertDataToField()
+void DIALOG_LIB_EDIT_ONE_FIELD::TransfertDataToField( bool aIncludeText )
 {
-DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
+DIALOG_EDIT_ONE_FIELD::TransfertDataToField( aIncludeText );
 
-m_field-SetText( GetTextField() );
+if( aIncludeText )
+m_field-SetText( GetTextField() );
 
 m_field-SetSize( wxSize( m_textsize, m_textsize ) );
 m_field-SetOrientation( m_textorient );
@@ -255,11 +267,12 @@ wxString DIALOG_SCH_EDIT_ONE_FIELD::GetTextField()
 };
 
 
-void DIALOG_SCH_EDIT_ONE_FIELD::TransfertDataToField()
+void DIALOG_SCH_EDIT_ONE_FIELD::TransfertDataToField( bool aIncludeText )
 {
-DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
+DIALOG_EDIT_ONE_FIELD::TransfertDataToField( aIncludeText );
 
-m_field-SetText( GetTextField() );
+if( aIncludeText )
+m_field-SetText( GetTextField() );
 
 m_field-SetSize( wxSize( m_textsize, m_textsize ) );
 m_field-SetOrientation( m_textorient );
diff --git a/eeschema/dialogs/dialog_edit_one_field.h b/eeschema/dialogs/dialog_edit_one_field.h
index 7edd99b..c52d4ef 100644
--- a/eeschema/dialogs/dialog_edit_one_field.h
+++ b/eeschema/dialogs/dialog_edit_one_field.h
@@ -74,14 +74,27 @@ public:
 /**
  * Function TransfertDataToField
  * Converts fields from dialog window to variables to be used by child classes
+ *
+ * @param aIncludeText Whether the valies transferred should include the actual
+ * item text. If this is false, formatting will be transferred, but text will
+ * not.
  */
-virtual void TransfertDataToField();
+virtual void TransfertDataToField( bool aIncludeText = true );
 
 void SetTextField( const wxString aText )
 {
  m_TextValue-SetValue( aText );
 }
 
+/**
+ * Function SetPowerWarning
+ * Disables the Text field and displays the Power component values cannot
+ * be modified! warning, if aWarn is true. Performs the inverse if aWarn
+ * is false (this, however, is the default).
+ *
+ * @param aWarn whether or not to produce the warning
+ */
+void SetPowerWarning( bool aWarn );
 
 protected:
 /**
@@ -143,7 +156,7 @@ public:
 
 ~DIALOG_LIB_EDIT_ONE_FIELD() {};
 
-void TransfertDataToField();
+void TransfertDataToField( bool aIncludeText = true );
 
 /**
  * Function GetTextField
@@ -186,7 +199,7 @@ public:
 
 // ~DIALOG_SCH_EDIT_ONE_FIELD() {};
 
-void TransfertDataToField();
+void TransfertDataToField( bool aIncludeText = true );
 
 /**
  * Function GetTextField
diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.cpp b/eeschema/dialogs/dialog_lib_edit_text_base.cpp
index 70324cc..5d3ca5a 100644
--- a/eeschema/dialogs/dialog_lib_edit_text_base.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_text_base.cpp
@@ -1,5 +1,5 @@