Commit Graph
316 Commits
Author SHA1 Message Date
X512 fb44a1cd72 BMenu: fix memory leak in scripting
Change-Id: Ia283594a622f758189cc8280683a4e068ae1f3af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2978
Reviewed-by: waddlesplash <[email protected]>
2020-07-02 19:26:49 +00:00
X512 8fbce87334 BMenu: implement scripting
Fixes #15540.

Change-Id: I965d04bcbb6db41cc7a744d18fa3c9ffab2a81f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2941
Reviewed-by: Adrien Destugues <[email protected]>
2020-06-24 14:08:16 +00:00
X512 9b33a309da Interface Kit: fix menu resizing when scrolling is enabled
BMenuWindow::Attach/DetachScrollers can be called when scrollers are
already attached/detached and it should handle this case properly.

Call BMenuWindow::DetachScrollers when scrolling is not needed anymore.

Fixes #8513.

Change-Id: I1f70b63d75106cf33ab1f72d34e221a54b45a75e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2310
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2020-03-07 17:33:25 +00:00
John Scipione 2e08685b99 BMenu: Rename FrameMoved and FrameResized variable names
No functional change. lowercase_with_underscore file names are not
in-line with Haiku's style guidelines.

Change-Id: I254c975ee60168963ca4039a61dc428c05e0e6ba
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2306
Reviewed-by: Adrien Destugues <[email protected]>
2020-03-03 10:56:05 +00:00
X512 fa60e7a684 BMenu: remove delay when opening submenu with mouse
Fixes #11703.

Change-Id: Iae01eeffee27ecde5bb333c85b8c3cb411f1bd00
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2274
Reviewed-by: Sergei Reznikov <[email protected]>
Reviewed-by: humdinger <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2020-02-27 00:51:48 +00:00
X512 17a91a9886 BMenu: fix menu navigation area
Change-Id: If9326ebc99978627d9dfb1eaff67912f0114f292
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2071
Reviewed-by: waddlesplash <[email protected]>
2020-02-25 04:41:22 +00:00
Ryan Leavengood e10de1ecf5 Visually align shortcuts in menus
In a menu, we use the right side both for submenu arrows and shortcuts.
As a result, when an entry has both a shortcut and a submenu, its
shortcut is not aligned with others, and this does not look so nice.

The spacing for the arrow appears only if there is a submenu in any of
the items in the parent menu.

Change-Id: If91fdcdad36abb0141fb05d1f59141f89540c1db
Reviewed-on: https://review.haiku-os.org/c/haiku/+/355
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Ryan Leavengood <[email protected]>
2020-02-04 23:06:54 +00:00
X512 f146f74b42 Fix BMenuBar width 2019-08-23 22:14:05 -04:00
Adrien Destugues 5f603da01a Better shape for submenu arrow
Just use BControLook where appropriate. It already provides a nice arrow
drawing function (also used in DeskBar expander and in scrollbar
buttons).

Fix second part of #8900

Changes by John Scipione:

Update menu mark and submenu arrow color with menu text color

Use text color for checkmark and submenu arrow colors, tint less black.
This means that colored bg/white text menu item will also draw a white
checkmark and submenu arrow.

Break out BMenuItem::Draw functionality into private methods _IsActive,
_LowColor() and _HighColor() methods and use them to set the mark colors.

Scale submenu arrow and checkmark with item height (which scales with
font size.)

does not align shortcuts with submenu arrows... but if you were to do
that you'd add item->Bounds().Height() / 2.

Signed-off-by: John Scipione <[email protected]>

Change-Id: I8299094ef88bf227510b116eb1b84c261dc94723
Reviewed-on: https://review.haiku-os.org/c/341
Reviewed-by: Stefano Ceccherini <[email protected]>
Reviewed-by: Axel Dörfler <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2019-01-14 15:59:57 +00:00
Augustin Cavalier 0a973154a8 BMenu: Look for ASCII characters < 128, not < 255.
Otherwise we will include ISO 8859-15 (é, à, etc.)
Thanks to PulkoMandy for pointing this out!
2019-01-08 19:50:52 -05:00
Augustin Cavalier 52a022f201 BMenu: Accept any alphanumeric ASCII character on the first trigger pass.
Since we use sentence-cased menus, there is probably only one capital
letter in the line, so looking for only capitals won't be very useful.
Instead, accept any ASCII character (< 255) which is alphanumeric,
as these are more likely to be command-able in any given keymap.

(IsAlNum returns true for accented Latin characters also, which may
be un-command-able if they require dead keys to type.)
2018-12-22 00:36:30 -05:00
Adrien Destugues 588a0c9f67 BMenu: Use BUnicodeChar for unicode char manipulation.
It is not allowed to use isspace, tolower, etc, on character outside of
the char type range (and EOF). Use BUnicodeChar instead to avoid out of
bound accesses.

Fixes the second crash in #14753.

Signed-off-by: Augustin Cavalier <[email protected]>
Some changes by me to make "index" a byte instead of character index
as it needs to be.
2018-12-22 00:25:10 -05:00
David Murphy 9ece492008 BMenu: BMenuBar submenus at screen edge moved onscreen instead of scrolling
Fixes #9093
Change-Id: I1322c0cd8ba4bbfddace037ed8a8ef666ebe7fe3
2018-07-17 21:21:40 +00:00
David Murphy e3f7fe948d BMenu: Submenu opening direction follows parent opening direction
Fixes #4859
Change-Id: I8e89afc3ad982d899428e3038fed354a78d04981
2018-07-17 04:12:21 +00:00
David Murphy e4433ad0fa BMenu: Fix crash and keyboard navigation on 'recent items' menus
* Prevents crash mentioned in Trac, but also enables keyboard navigation
  to 'recent items' menus such as "Open files..." in MediaPlayer and DiskProbe
* Check selected menu and submenu exist in menu tracking thread before accessing
* Update BMenu::AttachedToWindow to pass in keydown param to _AddDynamicItems

Fixes #9251
Change-Id: I3031b8e9c1b9dd4ef1187c5a6b8ab7925e3496d2
2018-07-13 00:16:58 +00:00
Humdinger 346d149694 Properly terminate property_info lists
BListView's property_info list lacked termination, resulting in
garbage output at the and of 'hey getsuites'.

Use { 0 } everywhere for sake of consistency.

Thanks to waddlesplash for spotting the bug an providing the easy fix.
2017-11-05 18:43:21 +01:00
Augustin Cavalier bfbb965580 Interface Kit: Remove more non-BControlLook code. 2017-09-10 14:58:35 -04:00
John Scipione ca766a50fe BMenu: Offset the menu field's menu window left 8px
...so that the text when the menu is closed lines up with the text
when the menu is open.

The checkmark is draw to the left of left edge of the closed menufield.
2016-07-31 19:42:39 -07:00
John Scipione b75a2e9d22 BMenu: Add default padding to ctor 2016-07-31 19:42:39 -07:00
John Scipione dcecaf60ad BMenu: Remove _ from protected method _DrawItems 2016-07-31 19:42:39 -07:00
John Scipione 61dfdec415 BMenu and friends: style fixes
BMenuBar: style fix: msg => message

MenuPrivate: style fixes

MenuItem: 80 char limit style fix

MenuBar: tiny style fix

Menu: tiny style fix, indentation

Menu: Small refactor

Implement _SetIgnoreHidden() in header
Change on to ignoreHidden
Change on in _SetStickyMode to sticky

_BMCItem_: tiny whitespace style fix

Menu: style fixes, rename msgr => messenger

BMenu: style fix, pointer != NULL

BMenu::Archive rename ret to status

Also check pointer against NULL explicitly

BMenuItem style fixes: rename abbreviation, pointer style
2016-07-31 19:42:39 -07:00
looncraz 7a96554cb3 kits/interface: Convert to using Set*UIColor.
Signed-off-by: Augustin Cavalier <[email protected]>
Patches 0003-0017 from looncraz, unmodified.
2016-01-04 07:04:45 -05:00
Axel Dörfler ac9ec47d27 BMenu: made left side padding font size relative.
* Also changed BMenuItem to make better use of that size.
2015-09-09 21:06:19 +02:00
Augustin Cavalier fb4ea396e3 BMenu: Check return value of LockLooper().
CIDs 602450-602452.
2015-08-04 10:59:00 -04:00
Adrien Destugues c4793b242c fix adding or removing items to an open BMenu
The menu would try to relayout itself, but fail to get the supermenu
bounds as the looper for it was not locked in that case.

This fixes the crash with two downsides:
* The menu width isn't adjusted to match the parent menu (mostly visible
in BMenuFields)
* There is some flickering as the menu is updated

Fixes #9863 (Network prefs part).
2014-12-17 10:23:40 +01:00
Adrien Destugues 0eb5978482 BMenu: don't invalidate layout when changing marked item
* The layout does not need to change. The label may change in
SetLabelFromMarked mode, but this only affects the layout of the parent
menu.
* This would crash when programatically changing the menu marked item
while the menu is open.
2014-10-18 22:28:08 +02:00
John Scipione ca6cc0aa50 BMenu: Replace min_c and max_c
... with std:min and std:max
2014-04-24 15:31:13 -04:00
John Scipione b7096fd76b BMenu: remove useless default case 2014-04-24 15:31:13 -04:00
John Scipione cb30cf1423 BMenu: style fixes 2014-04-24 15:31:12 -04:00
Julian Harnath eb539d59e7 Don't try to open another menu window if there already is one.
* Fixes crash when using Gobe Productive toolbar.
2013-11-22 11:38:30 +01:00
John Scipione 9a9ebda459 BMenu: Some style fixes related to docs
Mostly just making the variable names match between the
header and source.

No functional change intended.
2013-11-06 12:21:58 -05:00
Ingo Weinhold 40082f768a BMenu: Update comment 2013-10-31 22:46:57 +01:00
Ingo Weinhold 0b4c2d3210 BMenu: Use shift modifier for page-wise wheel scrolling
Fixes part of #9907.
2013-10-31 21:50:25 +01:00
Stefano Ceccherini c29f2d22a9 Close the menu on keypress.
After _InvokeItem(), call QuitTracking() to close the menu.
Incidentally this also seems to fix #9863.
2013-10-25 21:40:13 +02:00
John Scipione 4385f73996 Revert "Menu: check numBytes == 1 on KeyDown"
This reverts commit 44dc533861.
2013-08-25 19:40:00 -04:00
John Scipione 60a7f11599 Menu: Handle Keyboard input better.
When you push an arrow key obscure the cursor so that it doesn't get in the
way of the menu items. BeOS R5 also did this.

When you select an item with Enter or Space, or cancel with Escape, set the
super menu to close in _QuitTracking() if you've specified onlyThis == false.
Also, show the cursor here in case you haven't moved the mouse since it was
obscured.

This fixes a problem where when you select an item in a menu via the keyboard
while your mouse is over the parent menu item or menu field it would pop the
menu back up again even though you've made your selection or cancelled.
2013-08-25 00:17:41 -04:00
John Scipione 44dc533861 Menu: check numBytes == 1 on KeyDown 2013-08-25 00:08:44 -04:00
John Scipione cccc4076db Menu and friends: Style fixes, no functional
... changes intended.

* 80 char limit fixes
* Indentation fixes
* Braces style fixes
* Use ternary operator where appropriate
* Rename menuItem to just item and declare it once outside
  the loop
* Omit 3rd param of GetMouse() because it is default
* Rename variables eg state => focused and menu => submenu
* Indent comments below line they apply to
* Reword some comments
* Add some #pragmas
2013-08-25 00:05:02 -04:00
John Scipione f5bb831108 Menu: Silly code optimization
Always set releasedOnce to true here instead of setting it true in the
case that it is false. It's almost certainly faster and clearer to always do
the assignment than to incur the cost of the conditional and branch.
2013-08-24 01:58:12 -04:00
John Scipione d5de9547c7 Menu: some helpful comments 2013-08-21 19:46:39 -04:00
John Scipione 408c0ee4cd MenuField: enable/disable the menu field when...
the child menu bar or the child menu bar's menu is enabled/disabled.

This means that there is just one status we have to check, the menu
fields, and the child menus agree. This change takes practical form
in the Backgrounds preflet which disables the placement menu when
the image is set to "None", but, only the menu got disabled and not the
parent menu field so the label was erroneously still drawn as enabled.
2013-08-20 18:15:13 -04:00
John Scipione 83ea4af492 BMenu: Don't hit test separator items
Fixes #4147 while not causing the regression described in #6610
like hrev35248 did.
2013-08-20 13:34:14 -04:00
John Scipione 77850e8dba Revert "BMenu return only enabled items"
Patch by "stimut"

This reverts commit abc26ba8ad.

Reverting this patch fixes #6610
2013-08-20 13:30:31 -04:00
John Scipione 6da3c1c788 if menu _BMCMenuBar_ subtract the popup indicator width
... when calculating the width of items in _ComputeLayout. This prevents
that menu field from growing on selection fixing #9796 and #2413.

Also a few style fixes.
2013-05-30 00:05:16 -04:00
John Scipione d5c51ba676 Update header comments 2013-05-06 17:15:18 -04:00
John Scipione d97b434060 Style fixes to BMenu and related classes. 2013-05-06 17:15:17 -04:00
John Scipione 5041cdf4d9 Fix a few minor BMenu issues, follup on hrev45610
Only AttachScrollers() and scroll if B_ITEMS_IN_COLUMN because if not we don't
support scrolling anyway. Also, rename superpoint variable to superPoint.
2013-05-03 16:27:05 -04:00
Jessica Hamilton 4898c615d6 BMenu: scroll marked item into view when menu has scrollers attached.
Signed-off-by: Axel Dörfler <[email protected]>
2013-05-03 21:10:51 +02:00
Stefano Ceccherini 501201761b In case the BMenu is inside a BMenuField, override the items width to
span over the BMenuField's width. Note that if the BMenu is already
wider, we don't shrink it, at least for now.
Fixes #5015.
2013-04-13 10:31:20 +02:00
Stefano Ceccherini 3ef837fd40 If a submenu was opened, the parent menu tracking loop would continue calling
_HitTestItems() even if the user didn't move the mouse.
2013-04-12 23:07:47 +02:00