Re: [Kicad-developers] [RFC]: Make hotkey editor polished
FYI, latest code is sitting in merge proposal https://code.launchpad.net/~mark-roszko/kicad/hotkey/+merge/238225 ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
Ok, I purged the wxGrid implementation and moved to a wxListCtrl which is superior. Now all the special keys are properly caught. The right click menu has been eliminated because wxListCtrl gets all the onCharEvents that wxGrid did not pass. The key conflict logic now checks between other sections properly as needed: i.e. Common with all other sections and A section with only common depending on what you are editing the hotkey in. I would appreciate if someone tests to verify on OSX and Windows that the special keys get captured (Tab, Enter, Arrows, Space) :D Otherwise I just have some things to cleanup (rename some hotkey commands to be complete english instead of abbreviations) and doxygen comment blocks to add. === modified file 'common/CMakeLists.txt' --- common/CMakeLists.txt 2014-09-07 19:01:26 + +++ common/CMakeLists.txt 2014-10-12 17:33:30 + @@ -179,7 +179,6 @@ grid_tricks.cpp gr_basic.cpp hotkeys_basic.cpp -hotkey_grid_table.cpp html_messagebox.cpp kiface_i.cpp kiway.cpp === modified file 'common/dialogs/dialog_hotkeys_editor.cpp' --- common/dialogs/dialog_hotkeys_editor.cpp2014-04-07 16:00:13 + +++ common/dialogs/dialog_hotkeys_editor.cpp2014-10-12 17:33:30 + @@ -30,59 +30,250 @@ #include fctsys.h #include pgm_base.h #include common.h +#include confirm.h #include dialog_hotkeys_editor.h -void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys ) -{ -HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys ); +HOTKEY_LIST_CTRL::HOTKEY_LIST_CTRL( wxWindow *aParent, struct EDA_HOTKEY_CONFIG* aSection ) : +wxListCtrl( aParent, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VIRTUAL ) +{ +m_sectionTag = aSection-m_SectionTag; +m_curEditingRow = -1; + +InsertColumn( 0, _(Command) ); +InsertColumn( 1, _(Hotkey) ); + +SetColumnWidth( 0, wxLIST_AUTOSIZE ); +SetColumnWidth( 1, wxLIST_AUTOSIZE_USEHEADER ); + +// Add a dummy hotkey_spec which is a header before each hotkey list +EDA_HOTKEY** hotkey_descr_list; + +// Add a copy of hotkeys to our list +for( hotkey_descr_list = aSection-m_HK_InfoList; *hotkey_descr_list; + hotkey_descr_list++ ) +{ +EDA_HOTKEY* hotkey_descr = *hotkey_descr_list; +m_hotkeys.push_back( new EDA_HOTKEY( hotkey_descr ) ); +} + +// Set item count to hotkey size, this gets it to autoload the entries +SetItemCount( m_hotkeys.size() ); + + Bind( wxEVT_CHAR, HOTKEY_LIST_CTRL::OnChar, this ); +Bind( wxEVT_LIST_ITEM_SELECTED, HOTKEY_LIST_CTRL::OnListItemSelected, this ); + Bind( wxEVT_SIZE, HOTKEY_LIST_CTRL::OnSize, this ); +} + + +/** + * Function OnSize + * Expands the second column to take up the full width. + * + * @param aEvent is the event from resizing, this is not used + */ +void HOTKEY_LIST_CTRL::OnSize( wxSizeEvent aEvent ) +{ +float totalWidth = 0; +float scale = 0; +int numCols = 2; + +SetColumnWidth( 0, wxLIST_AUTOSIZE ); +SetColumnWidth( 1, wxLIST_AUTOSIZE_USEHEADER ); + +for ( int i = 0; i numCols; ++i ) +{ +totalWidth += GetColumnWidth( i ); +} + + +if( GetClientSize().x totalWidth ) +{ +return; +} + +scale = (float) GetClientSize().x / totalWidth; + +SetColumnWidth( 0, int( GetColumnWidth( 0 )*scale ) - 2 ); +SetColumnWidth( 1, int( GetColumnWidth( 1 )*scale ) ); + +aEvent.Skip(); +} + + +void HOTKEY_LIST_CTRL::OnListItemSelected( wxListEvent aEvent ) +{ +m_curEditingRow = aEvent.GetIndex(); +} + + +void HOTKEY_LIST_CTRL::DeselectRow( int aRow ) +{ +SetItemState( aRow, 0, wxLIST_STATE_SELECTED ); +} + + +wxString HOTKEY_LIST_CTRL::OnGetItemText( long aRow, long aColumn ) const +{ +EDA_HOTKEY* hotkey_descr = m_hotkeys[aRow]; + +if( aColumn == 0 ) +{ +return hotkey_descr-m_InfoMsg; +} +else +{ +return KeyNameFromKeyCode( hotkey_descr-m_KeyCode ); +} +} + + +void HOTKEY_LIST_CTRL::OnChar( wxKeyEvent aEvent ) +{ +if( m_curEditingRow != -1 ) +{ +long key = aEvent.GetKeyCode(); + +switch( key ) +{ +case WXK_ESCAPE: +// Remove selection +DeselectRow( m_curEditingRow ); +m_curEditingRow = -1; +break; + +default: +if( aEvent.ControlDown() ) +key |= GR_KB_CTRL; + +if( aEvent.AltDown() ) +key |= GR_KB_ALT; + +if( aEvent.ShiftDown() (key 256) ) +key |= GR_KB_SHIFT; + +// Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL) +// to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z' +if( (key GR_KB_CTRL) (key = GR_KB_CTRL+26) ) +key += ('A' - 1); + +if( key = 'a' key = 'z' ) // convert to uppercase +key = key + ('A' - 'a'); + +// See if this key
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
I don't see why I can't try at disabling the original wxGrid behavior at using the arrow keys (and home/end and other keys). I don't see a point in retaining them in a hotkey editor. On Tue, Oct 7, 2014 at 10:11 AM, Mike Crawford m...@tuxnami.org wrote: Question on your new hotkey editor. Will there be a way to use the arrow keys as hot keys with it? With the current one all that happens when I try to use them is the focus is shifted from the field. I'm eventually looking to add hotkeys for panning, and I'd love to use the arrows for that. On Tue Oct 07 2014 at 4:52:48 AM Mark Roszko mark.ros...@gmail.com wrote: New changes pushed to branch (https://code.launchpad.net/~mark-roszko/kicad/kicad), the interface has been revised a bit more heavily. Sections are now split into tabs!. This helps immensely bringing attention to different set of keys easily rather than a large list. The selection logic has been tweaked to use the native wxwidget selection cursor instead of bolding. Also no more bolding of sections titles. Your dream come true Wayne! :P Preview of UI: http://i.imgur.com/cfgq5mU.png TODO: 1. Fix overwrite detection between common tab and other section tabs. Right now overwrite detection is constrained to the keys in the same list/tab. 2. Add better names for the tabs, not 100% sure how to do this cleanly, the EDA_HOTKEY_CONFIG has the tag member and comment member. The tag member gets used in the config file but the comment field looks silly and could just be changed to be a pretty name. Alternatively I just add a pretty name member to the struct. ___ 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 -- Mark ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
On 10/6/2014 11:52 PM, Mark Roszko wrote: New changes pushed to branch (https://code.launchpad.net/~mark-roszko/kicad/kicad), the interface has been revised a bit more heavily. Sections are now split into tabs!. This helps immensely bringing attention to different set of keys easily rather than a large list. The selection logic has been tweaked to use the native wxwidget selection cursor instead of bolding. Also no more bolding of sections titles. Your dream come true Wayne! :P Trust me when I tell you my dreams are much bigger than that! :). I wonder why the original implementation used bolding for emphasis when the highlighting seems much more obvious. Your changes look good. I would drop the [] around the tab names, use capitalization for the tab names, and change libedit to Library Editor (or something other than an abbreviation). If you find more of these abbreviations, please fix them to something sensible. I've been trying to get rid of them because a user is going think What's a libedit?. It's a bit like playing whac-a-mole. You fix one, and three more pop up. Preview of UI: http://i.imgur.com/cfgq5mU.png TODO: 1. Fix overwrite detection between common tab and other section tabs. Right now overwrite detection is constrained to the keys in the same list/tab. I would like to see this one implemented before the patch is committed. I think it's a good idea to prevent users from inadvertently setting duplicate hot keys. These kinds of fixes cut down on bug reports. 2. Add better names for the tabs, not 100% sure how to do this cleanly, the EDA_HOTKEY_CONFIG has the tag member and comment member. The tag member gets used in the config file but the comment field looks silly and could just be changed to be a pretty name. Alternatively I just add a pretty name member to the struct. ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
would drop the [] around the tab names, use capitalization for the tab names, and change libedit to Library Editor (or something other than an abbreviation). If you find more of these abbreviations, please fix them to something sensible. Fixed that in the latest branch commit. I would like to see this one implemented before the patch is committed. I think it's a good idea to prevent users from inadvertently setting duplicate hot keys. These kinds of fixes cut down on bug reports. Yep, I plan to finish that in the next day or two. I also may try and fix special key detection before submitting a merge request. ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
New changes pushed to branch (https://code.launchpad.net/~mark-roszko/kicad/kicad), the interface has been revised a bit more heavily. Sections are now split into tabs!. This helps immensely bringing attention to different set of keys easily rather than a large list. The selection logic has been tweaked to use the native wxwidget selection cursor instead of bolding. Also no more bolding of sections titles. Your dream come true Wayne! :P Preview of UI: http://i.imgur.com/cfgq5mU.png TODO: 1. Fix overwrite detection between common tab and other section tabs. Right now overwrite detection is constrained to the keys in the same list/tab. 2. Add better names for the tabs, not 100% sure how to do this cleanly, the EDA_HOTKEY_CONFIG has the tag member and comment member. The tag member gets used in the config file but the comment field looks silly and could just be changed to be a pretty name. Alternatively I just add a pretty name member to the struct. ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
On 5 October 2014 18:52, Mark Roszko mark.ros...@gmail.com wrote: Hi, I've been poking with KiCAD for awhile and decided to contribute. Using Bazaar was the first hurdle, thankfully I gave up and used the git bridge. I otherwise have no idea how development goes. I've always thought the hotkey editor was a bit unpolished so I'm submitting patches to make it pretty. Of course that is subjective but I recommend applying the patches to see the difference. Compiles and works fine for me (Arch Linux, wxwidgets 3.0.1). Looks nice too. Changes. 1. No longer open fixed at max screen height. You need to visually scan through the list of items to find what you want regardless, making it max height doesn't necessarily make this any easier than scrolling. Put action buttons at the bottom. Increase base width and height of window to compensate. Logic added to expand column headers automatically to match width of window. 2. Add logic to fix bug #706361. It will now ask if you want to reuse the key. The old assignment gets set to 0 which currently causes unknown to display but does disable the action. I don't see the harm in a hotkey action not being binded to anything since it's a users choice anyway. Works well, but the grammar needs fixing: change it's assignment should be change its assignment. I'm also wondering if the angle brackets around the action are needed (I have no problem with them around the key). 3. Section headers are bolded to stand out 4. Selection cell, cursor hidery. This was annoying because wxGrid itself is annoying and lacking in options. So I disguised things properly that these unused features are never seen. 5. Add descriptive text to at least mention that right click gives you more options. Got to be a little newb friendly here as that isn't obvious to everyone. press your keyboard keys sounds a bit clunky. Maybe press a new key combination? I've pushed my changes to https://code.launchpad.net/~mark-roszko/kicad/kicad If anybody wants a diff, you can get it from http://bazaar.launchpad.net/~mark-roszko/kicad/kicad/revision/5166?remember=5162compare_revid=5162 NB it applied to 5163 with no trouble. This might be a slight hijack of the thread, but could be a good time for a design decision: could we put all the stuff in the hotkey menu into the one dialog? The hotkey editor is at least as usable (arguably nicer looking now) for listing keys as the 'list current hotkeys' dialog, and the import/export could be triggered from buttons on the hotkey editor. Maybe rename it to 'Hotkey manager' or something? IMO this would be a cleaner interface -- thoughts? Cheers, Blair ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
Le 05/10/2014 07:52, Mark Roszko a écrit : Hi, I've been poking with KiCAD for awhile and decided to contribute. Using Bazaar was the first hurdle, thankfully I gave up and used the git bridge. I otherwise have no idea how development goes. I've always thought the hotkey editor was a bit unpolished so I'm submitting patches to make it pretty. Of course that is subjective but I recommend applying the patches to see the difference. Changes. 1. No longer open fixed at max screen height. You need to visually scan through the list of items to find what you want regardless, making it max height doesn't necessarily make this any easier than scrolling. Put action buttons at the bottom. Increase base width and height of window to compensate. Logic added to expand column headers automatically to match width of window. 2. Add logic to fix bug #706361. It will now ask if you want to reuse the key. The old assignment gets set to 0 which currently causes unknown to display but does disable the action. I don't see the harm in a hotkey action not being binded to anything since it's a users choice anyway. 3. Section headers are bolded to stand out 4. Selection cell, cursor hidery. This was annoying because wxGrid itself is annoying and lacking in options. So I disguised things properly that these unused features are never seen. 5. Add descriptive text to at least mention that right click gives you more options. Got to be a little newb friendly here as that isn't obvious to everyone. I've pushed my changes to https://code.launchpad.net/~mark-roszko/kicad/kicad First, thanks to your contribution. Your hotkey editor is better than the current one. After playing witj it, I noticed some issues in duplicate keys detection: Duplicate keys are not detected for keys given by a select from the right mouse button popup menu. Duplicate keys are improperly detected when you are selecting the same key in a command: for instance in the rotate command has the R key selected, selected again the R key gives a duplicate key warning (which is not the case). Duplicate keys are improperly detected between schematic editor and component editor They are different editors, therefore keys can be duplicated. A minor issue: After undo, title cells print in Bold ([common], [eeschema] ...) are no more using bold font. -- 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
press your keyboard keys sounds a bit clunky. Maybe press a new key combination? Yea it was awkward. Changed to your suggestion. Duplicate keys are not detected for keys given by a select from the right mouse button popup menu. Ah, I completely forgot about the right click. Duplicate keys are improperly detected when you are selecting the same key in a command: for instance in the rotate command has the R key selected, selected again the R key gives a duplicate key warning (which is not the case). Also fixed in patch, somehow I never thought to this test. Now it just doesn't attempt to do anything. A minor issue: After undo, title cells print in Bold ([common], [eeschema] ...) are no more using bold font. Fixed. Duplicate keys are improperly detected between schematic editor and component editor They are different editors, therefore keys can be duplicated. Wow, I completely overlooked this. I didn't realize that. It's a little awkward the way its implemented. I can do duplicate check the keys within a section rather than the entire list. The only problem then the is the common section overlapping with the eeschema and libedit section. I would have to add a flag to the section to say this is the common section or just check on name. Pushed patch to my branch to fix everything but the section logic noted above ^ pending some more comments ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
On 10/5/2014 7:44 AM, jp charras wrote: Le 05/10/2014 07:52, Mark Roszko a écrit : Hi, I've been poking with KiCAD for awhile and decided to contribute. Using Bazaar was the first hurdle, thankfully I gave up and used the git bridge. I otherwise have no idea how development goes. I've always thought the hotkey editor was a bit unpolished so I'm submitting patches to make it pretty. Of course that is subjective but I recommend applying the patches to see the difference. Changes. 1. No longer open fixed at max screen height. You need to visually scan through the list of items to find what you want regardless, making it max height doesn't necessarily make this any easier than scrolling. Put action buttons at the bottom. Increase base width and height of window to compensate. Logic added to expand column headers automatically to match width of window. 2. Add logic to fix bug #706361. It will now ask if you want to reuse the key. The old assignment gets set to 0 which currently causes unknown to display but does disable the action. I don't see the harm in a hotkey action not being binded to anything since it's a users choice anyway. 3. Section headers are bolded to stand out 4. Selection cell, cursor hidery. This was annoying because wxGrid itself is annoying and lacking in options. So I disguised things properly that these unused features are never seen. 5. Add descriptive text to at least mention that right click gives you more options. Got to be a little newb friendly here as that isn't obvious to everyone. I've pushed my changes to https://code.launchpad.net/~mark-roszko/kicad/kicad First, thanks to your contribution. Your hotkey editor is better than the current one. After playing witj it, I noticed some issues in duplicate keys detection: Duplicate keys are not detected for keys given by a select from the right mouse button popup menu. Duplicate keys are improperly detected when you are selecting the same key in a command: for instance in the rotate command has the R key selected, selected again the R key gives a duplicate key warning (which is not the case). Duplicate keys are improperly detected between schematic editor and component editor They are different editors, therefore keys can be duplicated. A minor issue: After undo, title cells print in Bold ([common], [eeschema] ...) are no more using bold font. Please respect the users system font choices for controls bold or otherwise. I know there are lots of UI folks who would disagree with me but when I set my system fonts, I do it for because that's the way I like them and I don't want them changed. Otherwise I would make them bold, italicized, etc. myself. ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
Please respect the users system font choices for controls bold or otherwise. I know there are lots of UI folks who would disagree with me but when I set my system fonts, I do it for because that's the way I like them and I don't want them changed. Otherwise I would make them bold, italicized, etc. myself. Is this about bolding the section items or selected items(original behavior)? ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
Woops, just noticed the quotation. I wanted to bold the section to make them stand out because they aren't hotkeys and they do split the list. A separate consideration was I was pondering splitting the single grid into a tabbed interface with grids per section. This way the sections are more immediately found, especially because the library editor hotkeys are buried three miles deep after the eeschema hotkeys. ___ 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
Re: [Kicad-developers] [RFC]: Make hotkey editor polished
On 10/5/2014 1:37 PM, Mark Roszko wrote: Please respect the users system font choices for controls bold or otherwise. I know there are lots of UI folks who would disagree with me but when I set my system fonts, I do it for because that's the way I like them and I don't want them changed. Otherwise I would make them bold, italicized, etc. myself. Is this about bolding the section items or selected items(original behavior)? Section items. Making a selection bold for emphasis is fine unless there is some other emphasis mechanism in play such as highlighting. I realize there are places in KiCad that still manipulate the user's preferred font settings. Most of this is legacy code. If you happen to find them while you are UI polishing, please fix them. I'm not a big fan for the reason that I've already stated. Keep in mind there are places where bold text is used such as inside of HTML controls which is fine. I know one of the worst offenders is the layer control in Pcbnew. This was done to get more information displayed on the screen but I'm still not 100% convinced it was the correct solution. When in doubt, always respect the user's font choice. ___ 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] [RFC]: Make hotkey editor polished
Hi, I've been poking with KiCAD for awhile and decided to contribute. Using Bazaar was the first hurdle, thankfully I gave up and used the git bridge. I otherwise have no idea how development goes. I've always thought the hotkey editor was a bit unpolished so I'm submitting patches to make it pretty. Of course that is subjective but I recommend applying the patches to see the difference. Changes. 1. No longer open fixed at max screen height. You need to visually scan through the list of items to find what you want regardless, making it max height doesn't necessarily make this any easier than scrolling. Put action buttons at the bottom. Increase base width and height of window to compensate. Logic added to expand column headers automatically to match width of window. 2. Add logic to fix bug #706361. It will now ask if you want to reuse the key. The old assignment gets set to 0 which currently causes unknown to display but does disable the action. I don't see the harm in a hotkey action not being binded to anything since it's a users choice anyway. 3. Section headers are bolded to stand out 4. Selection cell, cursor hidery. This was annoying because wxGrid itself is annoying and lacking in options. So I disguised things properly that these unused features are never seen. 5. Add descriptive text to at least mention that right click gives you more options. Got to be a little newb friendly here as that isn't obvious to everyone. I've pushed my changes to https://code.launchpad.net/~mark-roszko/kicad/kicad -- Mark ___ 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