← Back to team overview

kicad-developers team mailing list archive

Re: wxWidgets Event Tables or Bind and lambdas

 

Hi,

My layout would be

m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
        [this]( wxMouseEvent& ) 
        { 
            this->PopupMenu( this->m_footprintContextMenu ); 
        } );

Rationale:

 - it follows the "indent twice for round parentheses" rule
 - the lambda begins on the first character in the line
 - it keeps the lambda on the same indentation level
 - it leaves enough space for the lambda without too many extra breaks
 - the closing parenthesis follows the last argument on the same line

The "wxEVT_RIGHT_DOWN" would technically be on the same level as the lambda, so

m_footprintListBox->Bind(
        wxEVT_RIGHT_DOWN,
        [this]( wxMouseEvent& ) 
        { 
            this->PopupMenu( this->m_footprintContextMenu ); 
        } );

would be equivalent. We have both

function( arg1, arg2, arg3, arg4, arg5,
         arg6, arg7 );

and

function(
        arg1,
        arg2,
        arg3,
        arg4,
        arg5,
        arg6,
        arg7 );

in the codebase, as well as several instances where some arguments are
grouped tighter than others, e.g.

function( something.x, something.y,
         something.w, something.h );

instead of

function( something.x, something.y, something.w,
         something.h );

I think the usual rule applies: the compiler doesn't care, so the highest
priority is that it should be human readable.

   Simon


Follow ups

References