BColorMenuItem: add custom color menufield
http://insightfactory.tumblr.com/image/142366356207 * Make the color box a rectangle with proportions of golden ratio. * Override GetContentSize() to make menu item area larger. * Label should never truncate since I make sure there is enough room. * Draw the label using BMenuItem parent class * Carefully adjust the spacing so that there is an attractive amount of padding between the checkmark and color box and the color box and label. Add _AddMenu method to BMenuField that adds BColorMenuItem as its base menu item. This shows the BColorMenuItem in the closed state. Create BPrivate::MenuItemPrivate Add a SetSubmenu() method to MenuItemPrivate that gives you the ability to add a submenu after creating the object. This method should be public Skip disabled items Color gets updated even if you select an item in a submenu
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2015, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2006-2016 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _MENU_FIELD_H
|
||||
@@ -135,6 +135,7 @@ private:
|
||||
void _InitMenuBar(BMenu* menu,
|
||||
BRect frame, bool fixedSize);
|
||||
void _InitMenuBar(const BMessage* archive);
|
||||
void _AddMenu(BMenu* menu);
|
||||
|
||||
void _ValidateLayoutData();
|
||||
float _MenuBarOffset() const;
|
||||
@@ -159,4 +160,5 @@ private:
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
|
||||
#endif // _MENU_FIELD_H
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
class BMessage;
|
||||
class BWindow;
|
||||
|
||||
namespace BPrivate {
|
||||
class MenuItemPrivate;
|
||||
}
|
||||
|
||||
class BMenuItem : public BArchivable, public BInvoker {
|
||||
public:
|
||||
BMenuItem(const char* label, BMessage* message,
|
||||
@@ -57,6 +61,7 @@ private:
|
||||
friend class BMenu;
|
||||
friend class BPopUpMenu;
|
||||
friend class BMenuBar;
|
||||
friend class BPrivate::MenuItemPrivate;
|
||||
|
||||
virtual void _ReservedMenuItem1();
|
||||
virtual void _ReservedMenuItem2();
|
||||
@@ -77,6 +82,7 @@ private:
|
||||
BMenuItem(const BMenuItem& other);
|
||||
BMenuItem& operator=(const BMenuItem& other);
|
||||
|
||||
private:
|
||||
void _InitData();
|
||||
void _InitMenuData(BMenu* menu);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user