From 7a3dc578dcc9e301154bc4ff416f63624d6c7e74 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Fri, 21 Oct 2016 01:02:45 -0200 Subject: [PATCH] Add separators to menus. Also: - Fix the bug the didn't allow controls placed in frames to be selectable when they had been created before the frame. - Add "\#" automatically to ProgressBar's caption, so Show Percentage will work. --- InForm.ui | 11 +++++++++++ UiEditor.frm | 16 ++++++++-------- xp.uitheme | 13 ++++++++++++- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/InForm.ui b/InForm.ui index 3eb6abd..c500130 100644 --- a/InForm.ui +++ b/InForm.ui @@ -408,6 +408,12 @@ SUB __UI_ProcessInput __UI_HoveringID = TempHover + IF __UI_Controls(__UI_HoveringID).Type = __UI_Type_Frame AND __UI_Controls(__UI_BelowHoveringID).ParentID = __UI_Controls(__UI_HoveringID).ID THEN + 'If a control was created before its container, the following line + 'will allow it to be properly hovered/focused/selected. + SWAP __UI_HoveringID, __UI_BelowHoveringID + END IF + 'Design mode specific hover: IF __UI_DesignMode AND __UI_IsResizing = __UI_False AND __UI_IsDragging = __UI_False THEN __UI_ResizeHandleHover = 0 @@ -2362,6 +2368,7 @@ FUNCTION __UI_NewControl (ControlType AS INTEGER, ControlName AS STRING, NewWidt IF ControlType = __UI_Type_ProgressBar THEN __UI_Controls(NextSlot).Max = 100 + __UI_Captions(NextSlot) = "\#" END IF IF ControlType = __UI_Type_TrackBar THEN @@ -3001,6 +3008,10 @@ SUB __UI_ActivateMenu (This AS __UI_ControlTYPE, SelectFirstItem AS _BYTE) 'Grow the panel: __UI_Controls(__UI_ActiveMenu).Height = __UI_Controls(__UI_ActiveMenu).Height + ItemHeight + + IF RIGHT$(__UI_Captions(i), 1) = "-" THEN 'Separator + __UI_Controls(__UI_ActiveMenu).Height = __UI_Controls(__UI_ActiveMenu).Height + ItemHeight / 2 + END IF END IF NEXT diff --git a/UiEditor.frm b/UiEditor.frm index 75655e5..fc02460 100644 --- a/UiEditor.frm +++ b/UiEditor.frm @@ -11,24 +11,20 @@ SUB __UI_LoadForm __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "FileMenu", 56, 18, 14, 0, 0) __UI_SetCaption "FileMenu", "&File" - __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "ViewMenu", 56, 18, 14, 0, 0) - __UI_SetCaption "ViewMenu", "&View" - - __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 56, 18, 527, 0, 0) - __UI_SetCaption "HelpMenu", "&Help" - __UI_Controls(__UI_NewID).Align = __UI_Right - __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuLoad", 140, 18, 0, 4, __UI_GetID("FileMenu")) __UI_SetCaption "FileMenuLoad", "&Load form.frmbin" __UI_Controls(__UI_NewID).Disabled = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSave", 91, 18, 0, 22, __UI_GetID("FileMenu")) - __UI_SetCaption "FileMenuSave", "&Save form" + __UI_SetCaption "FileMenuSave", "&Save form-" __UI_Controls(__UI_NewID).Disabled = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuExit", 56, 18, 0, 40, __UI_GetID("FileMenu")) __UI_SetCaption "FileMenuExit", "E&xit" + __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "ViewMenu", 56, 18, 14, 0, 0) + __UI_SetCaption "ViewMenu", "&View" + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuPreview", 56, 18, 0, 40, __UI_GetID("ViewMenu")) __UI_SetCaption "ViewMenuPreview", "Open &preview window" @@ -38,6 +34,10 @@ SUB __UI_LoadForm __UI_SetCaption "ViewMenuPreviewDetach", "&Keep preview window attached" $END IF + __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 56, 18, 527, 0, 0) + __UI_SetCaption "HelpMenu", "&Help" + __UI_Controls(__UI_NewID).Align = __UI_Right + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "HelpMenuHelp", 0, 0, 0, 0, __UI_GetID("HelpMenu")) __UI_SetCaption "HelpMenuHelp", "&What's all this?" diff --git a/xp.uitheme b/xp.uitheme index 4018ebd..e6a160e 100644 --- a/xp.uitheme +++ b/xp.uitheme @@ -1231,11 +1231,18 @@ SUB __UI_DrawMenuPanel (This AS __UI_ControlTYPE, ControlState AS _BYTE) __UI_ShadowBox 0, 0, This.Width - 1, This.Height - 1, _RGB32(255, 255, 255), 40, 5 LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B - DIM i AS LONG, c AS _UNSIGNED LONG + DIM i AS LONG, c AS _UNSIGNED LONG, HasSeparator as _BYTE FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).Type = __UI_Type_MenuItem AND NOT __UI_Controls(i).Hidden AND __UI_Controls(i).ParentID = __UI_ParentMenu THEN TempCaption$ = __UI_Captions(i) + IF RIGHT$(TempCaption$, 1) = "-" THEN + HasSeparator = __UI_True + TempCaption$ = LEFT$(TempCaption$, LEN(TempCaption$) - 1) + ELSE + HasSeparator = __UI_False + END IF + IF __UI_Focus = i OR (__UI_HoveringID = i AND __UI_Focus = i) THEN LINE (3, __UI_Controls(i).Top)-STEP(This.Width - 7, __UI_Controls(i).Height - 1), This.SelectedBackColor, BF c = This.SelectedForeColor @@ -1263,6 +1270,10 @@ SUB __UI_DrawMenuPanel (This AS __UI_ControlTYPE, ControlState AS _BYTE) 'Checked menu item _PUTIMAGE (ItemOffset \ 2 - CheckMarkWidth \ 2, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 - CheckMarkHeight \ 2), ControlImage, , (0, CheckMarkIndex * CheckMarkHeight - CheckMarkHeight)-STEP(6, 6) END IF + + IF HasSeparator THEN + LINE (4, __UI_Controls(i).Top + __UI_Controls(i).Height + __UI_Controls(i).Height / 4)-STEP(This.Width - 9, 0), This.BorderColor + END IF END IF NEXT '---