mirror of https://github.com/buggins/dlangui.git
implement #441 - menu separators
This commit is contained in:
parent
46a8f1029a
commit
80c0da2768
src/dlangui/widgets
views
|
@ -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,8 +404,13 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
id="menuitem";
|
id="menuitem";
|
||||||
_mainMenu = mainMenu;
|
_mainMenu = mainMenu;
|
||||||
_item = item;
|
_item = item;
|
||||||
styleId = STYLE_MENU_ITEM;
|
|
||||||
updateState();
|
updateState();
|
||||||
|
if (_item.type == MenuItemType.Separator) {
|
||||||
|
styleId = "MENU_SEPARATOR";
|
||||||
|
trackHover = false;
|
||||||
|
clickable = false;
|
||||||
|
} else {
|
||||||
|
styleId = STYLE_MENU_ITEM;
|
||||||
string iconId = _item.action !is null ? _item.action.iconId : "";
|
string iconId = _item.action !is null ? _item.action.iconId : "";
|
||||||
if (_item.type == MenuItemType.Check)
|
if (_item.type == MenuItemType.Check)
|
||||||
iconId = "btn_check";
|
iconId = "btn_check";
|
||||||
|
@ -438,6 +452,14 @@ class MenuItemWidget : WidgetGroupDefaultDrawing {
|
||||||
clickable = true;
|
clickable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SeparatorMenuItemWidget : MenuItemWidget {
|
||||||
|
this(MenuItem item, bool mainMenu) {
|
||||||
|
super(item, mainMenu);
|
||||||
|
id="menuseparator";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// base class for menus
|
/// base class for menus
|
||||||
class MenuWidgetBase : ListWidget {
|
class MenuWidgetBase : ListWidget {
|
||||||
|
|
Binary file not shown.
After ![]() (image error) Size: 237 B |
Binary file not shown.
After ![]() (image error) 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