mirror of https://github.com/buggins/dlangui.git
implement #441 - menu separators
This commit is contained in:
parent
46a8f1029a
commit
80c0da2768
|
@ -2806,7 +2806,9 @@ class EditBox : EditWidgetBase {
|
||||||
|
|
||||||
/// calculate full content size in pixels
|
/// calculate full content size in pixels
|
||||||
override Point fullContentSize() {
|
override Point fullContentSize() {
|
||||||
Point textSz = measureVisibleText();
|
Point textSz;
|
||||||
|
textSz.y = _lineHeight * _content.length;
|
||||||
|
textSz.x = _maxLineWidth;
|
||||||
//int maxy = _lineHeight * 5; // limit measured height
|
//int maxy = _lineHeight * 5; // limit measured height
|
||||||
//if (textSz.y > maxy)
|
//if (textSz.y > maxy)
|
||||||
// textSz.y = maxy;
|
// textSz.y = maxy;
|
||||||
|
|
|
@ -307,6 +307,8 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
_accelWidth = maxAccelWidth;
|
_accelWidth = maxAccelWidth;
|
||||||
}
|
}
|
||||||
void measureSubitems(ref int maxLabelWidth, ref int maxHeight, ref int maxIconWidth, ref int maxAccelWidth) {
|
void measureSubitems(ref int maxLabelWidth, ref int maxHeight, ref int maxIconWidth, ref int maxAccelWidth) {
|
||||||
|
if (_item.type == MenuItemType.Separator)
|
||||||
|
return;
|
||||||
_label.measure(SIZE_UNSPECIFIED, SIZE_UNSPECIFIED);
|
_label.measure(SIZE_UNSPECIFIED, SIZE_UNSPECIFIED);
|
||||||
if (maxLabelWidth < _label.measuredWidth)
|
if (maxLabelWidth < _label.measuredWidth)
|
||||||
maxLabelWidth = _label.measuredWidth;
|
maxLabelWidth = _label.measuredWidth;
|
||||||
|
@ -332,6 +334,10 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
updateState();
|
updateState();
|
||||||
Rect m = margins;
|
Rect m = margins;
|
||||||
Rect p = padding;
|
Rect p = padding;
|
||||||
|
if (_item.type == MenuItemType.Separator) {
|
||||||
|
measuredContent(parentWidth, parentHeight, 1, 1); // for vertical (popup menu)
|
||||||
|
return;
|
||||||
|
}
|
||||||
// calc size constraints for children
|
// calc size constraints for children
|
||||||
int pwidth = parentWidth;
|
int pwidth = parentWidth;
|
||||||
int pheight = parentHeight;
|
int pheight = parentHeight;
|
||||||
|
@ -354,6 +360,9 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_pos = rc;
|
_pos = rc;
|
||||||
|
if (_item.type == MenuItemType.Separator)
|
||||||
|
return;
|
||||||
|
|
||||||
applyMargins(rc);
|
applyMargins(rc);
|
||||||
applyPadding(rc);
|
applyPadding(rc);
|
||||||
Rect labelRc = rc;
|
Rect labelRc = rc;
|
||||||
|
@ -395,47 +404,60 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
id="menuitem";
|
id="menuitem";
|
||||||
_mainMenu = mainMenu;
|
_mainMenu = mainMenu;
|
||||||
_item = item;
|
_item = item;
|
||||||
styleId = STYLE_MENU_ITEM;
|
|
||||||
updateState();
|
updateState();
|
||||||
string iconId = _item.action !is null ? _item.action.iconId : "";
|
if (_item.type == MenuItemType.Separator) {
|
||||||
if (_item.type == MenuItemType.Check)
|
styleId = "MENU_SEPARATOR";
|
||||||
iconId = "btn_check";
|
trackHover = false;
|
||||||
else if (_item.type == MenuItemType.Radio)
|
clickable = false;
|
||||||
iconId = "btn_radio";
|
} else {
|
||||||
// icon
|
styleId = STYLE_MENU_ITEM;
|
||||||
if (_item.action && iconId.length) {
|
string iconId = _item.action !is null ? _item.action.iconId : "";
|
||||||
_icon = new ImageWidget("MENU_ICON", iconId);
|
if (_item.type == MenuItemType.Check)
|
||||||
_icon.styleId = STYLE_MENU_ICON;
|
iconId = "btn_check";
|
||||||
_icon.state = State.Parent;
|
else if (_item.type == MenuItemType.Radio)
|
||||||
addChild(_icon);
|
iconId = "btn_radio";
|
||||||
}
|
// icon
|
||||||
// label
|
if (_item.action && iconId.length) {
|
||||||
_label = new TextWidget("MENU_LABEL");
|
_icon = new ImageWidget("MENU_ICON", iconId);
|
||||||
_label.text = _item.label;
|
_icon.styleId = STYLE_MENU_ICON;
|
||||||
_label.styleId = _mainMenu ? "MAIN_MENU_LABEL" : "MENU_LABEL";
|
_icon.state = State.Parent;
|
||||||
_label.state = State.Parent;
|
addChild(_icon);
|
||||||
addChild(_label);
|
|
||||||
// accelerator
|
|
||||||
dstring acc = _item.acceleratorText;
|
|
||||||
if (_item.isSubmenu && !mainMenu) {
|
|
||||||
version (Windows) {
|
|
||||||
acc = ">"d;
|
|
||||||
//acc = "►"d;
|
|
||||||
} else {
|
|
||||||
acc = "‣"d;
|
|
||||||
}
|
}
|
||||||
|
// label
|
||||||
|
_label = new TextWidget("MENU_LABEL");
|
||||||
|
_label.text = _item.label;
|
||||||
|
_label.styleId = _mainMenu ? "MAIN_MENU_LABEL" : "MENU_LABEL";
|
||||||
|
_label.state = State.Parent;
|
||||||
|
addChild(_label);
|
||||||
|
// accelerator
|
||||||
|
dstring acc = _item.acceleratorText;
|
||||||
|
if (_item.isSubmenu && !mainMenu) {
|
||||||
|
version (Windows) {
|
||||||
|
acc = ">"d;
|
||||||
|
//acc = "►"d;
|
||||||
|
} else {
|
||||||
|
acc = "‣"d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (acc !is null) {
|
||||||
|
_accel = new TextWidget("MENU_ACCEL");
|
||||||
|
_accel.styleId = STYLE_MENU_ACCEL;
|
||||||
|
_accel.text = acc;
|
||||||
|
_accel.state = State.Parent;
|
||||||
|
if (_item.isSubmenu && !mainMenu)
|
||||||
|
_accel.alignment = Align.Right | Align.VCenter;
|
||||||
|
addChild(_accel);
|
||||||
|
}
|
||||||
|
trackHover = true;
|
||||||
|
clickable = true;
|
||||||
}
|
}
|
||||||
if (acc !is null) {
|
}
|
||||||
_accel = new TextWidget("MENU_ACCEL");
|
}
|
||||||
_accel.styleId = STYLE_MENU_ACCEL;
|
|
||||||
_accel.text = acc;
|
class SeparatorMenuItemWidget : MenuItemWidget {
|
||||||
_accel.state = State.Parent;
|
this(MenuItem item, bool mainMenu) {
|
||||||
if (_item.isSubmenu && !mainMenu)
|
super(item, mainMenu);
|
||||||
_accel.alignment = Align.Right | Align.VCenter;
|
id="menuseparator";
|
||||||
addChild(_accel);
|
|
||||||
}
|
|
||||||
trackHover = true;
|
|
||||||
clickable = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 237 B |
Binary file not shown.
After Width: | Height: | Size: 250 B |
|
@ -174,6 +174,10 @@
|
||||||
backgroundImageId="menu_item_background_dark"
|
backgroundImageId="menu_item_background_dark"
|
||||||
>
|
>
|
||||||
</style>
|
</style>
|
||||||
|
<style id="MENU_SEPARATOR"
|
||||||
|
backgroundImageId="menu_separator_dark"
|
||||||
|
>
|
||||||
|
</style>
|
||||||
<style id="MENU_ICON"
|
<style id="MENU_ICON"
|
||||||
>
|
>
|
||||||
<state state_enabled="false" alpha="160"/>
|
<state state_enabled="false" alpha="160"/>
|
||||||
|
|
|
@ -238,7 +238,12 @@
|
||||||
/>
|
/>
|
||||||
<style id="MENU_ITEM"
|
<style id="MENU_ITEM"
|
||||||
backgroundImageId="menu_item_background"
|
backgroundImageId="menu_item_background"
|
||||||
padding="4,2,4,2"
|
padding="4pt,2pt,4pt,2pt"
|
||||||
|
>
|
||||||
|
</style>
|
||||||
|
<style id="MENU_SEPARATOR"
|
||||||
|
backgroundImageId="menu_separator"
|
||||||
|
padding="4pt,2pt,4pt,2pt"
|
||||||
>
|
>
|
||||||
</style>
|
</style>
|
||||||
<style id="MENU_ICON"
|
<style id="MENU_ICON"
|
||||||
|
|
|
@ -208,6 +208,8 @@ res/mdpi/list_item_hovered_dark.9.png
|
||||||
res/mdpi/list_item_selected.9.png
|
res/mdpi/list_item_selected.9.png
|
||||||
res/mdpi/list_item_selected_dark.9.png
|
res/mdpi/list_item_selected_dark.9.png
|
||||||
res/mdpi/media-flash-sd-mmc.png
|
res/mdpi/media-flash-sd-mmc.png
|
||||||
|
res/mdpi/menu_separator.9.png
|
||||||
|
res/mdpi/menu_separator_dark.9.png
|
||||||
res/mdpi/popup_window_background.9.png
|
res/mdpi/popup_window_background.9.png
|
||||||
res/mdpi/popup_window_background_dark.9.png
|
res/mdpi/popup_window_background_dark.9.png
|
||||||
res/mdpi/switch_off.png
|
res/mdpi/switch_off.png
|
||||||
|
|
Loading…
Reference in New Issue