Skip to content

Commit

Permalink
BootPickers: Swap positions of Shutdown and Restart buttons
Browse files Browse the repository at this point in the history
to better match newer macOS.
Add OC_ATTR_USE_REVERSED_UI bit to use old layout.
  • Loading branch information
mikebeaton committed Jan 1, 2024
1 parent b585ba8 commit 2b66a70
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ OpenCore Changelog
#### v0.9.8
- Updated OpenDuet to allow loading unsigned, unaligned legacy Apple images such as HfsPlusLegacy.efi
- Fixed CPU frequency calculation on AMD 10h family
- Swapped the position of Shutdown and Restart buttons to better match recent macOS
- Added `OC_ATTR_USE_REVERSED_UI` to allow access to previous default Shutdown and Restart button arrangement

#### v0.9.7
- Updated recovery_urls.txt
Expand Down
4 changes: 4 additions & 0 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3693,6 +3693,10 @@ \subsection{Boot Properties}\label{miscbootprops}
\item A list of recommended flavours is provided in \texttt{Docs/Flavours.md}.
\end{itemize}
\medskip
\item \texttt{0x0100} --- \texttt{OC\_ATTR\_USE\_REVERSED\_UI}, reverse position of Shutdown and
Restart buttons, affects OpenCanopy and builtin picker. The reversed setting matches older macOS,
and since it was the previous default in OpenCore it may better match some custom backgrounds.
Only applicable when \texttt{OC\_ATTR\_USE\_MINIMAL\_UI} is not set.
\end{itemize}

\item
Expand Down
4 changes: 3 additions & 1 deletion Include/Acidanthera/Library/OcBootManagementLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ typedef struct OC_HOTKEY_CONTEXT_ OC_HOTKEY_CONTEXT;
#define OC_ATTR_SHOW_DEBUG_DISPLAY BIT5
#define OC_ATTR_USE_MINIMAL_UI BIT6
#define OC_ATTR_USE_FLAVOUR_ICON BIT7
#define OC_ATTR_USE_REVERSED_UI BIT8
#define OC_ATTR_ALL_BITS (\
OC_ATTR_USE_VOLUME_ICON | OC_ATTR_USE_DISK_LABEL_FILE | \
OC_ATTR_USE_GENERIC_LABEL_IMAGE | OC_ATTR_HIDE_THEMED_ICONS | \
OC_ATTR_USE_POINTER_CONTROL | OC_ATTR_SHOW_DEBUG_DISPLAY | \
OC_ATTR_USE_MINIMAL_UI | OC_ATTR_USE_FLAVOUR_ICON )
OC_ATTR_USE_MINIMAL_UI | OC_ATTR_USE_FLAVOUR_ICON | \
OC_ATTR_USE_REVERSED_UI )

/**
Default timeout for IDLE timeout during menu picker navigation
Expand Down
33 changes: 27 additions & 6 deletions Library/OcBootManagementLib/BuiltinPicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ typedef enum {
typedef _TAB_FOCUS TAB_FOCUS;

STATIC TAB_FOCUS mFocusList[] = {
TAB_PICKER,
TAB_SHUTDOWN,
TAB_RESTART,
#if defined (BUILTIN_DEMONSTRATE_TYPING)
TAB_TYPING_DEMO
#endif
};

STATIC TAB_FOCUS mFocusListReversed[] = {
TAB_PICKER,
TAB_RESTART,
TAB_SHUTDOWN,
Expand Down Expand Up @@ -376,7 +385,10 @@ OcShowSimpleBootMenu (

FocusState = 0;
if ((BootContext->PickerContext->PickerAttributes & OC_ATTR_USE_MINIMAL_UI) == 0) {
FocusList = mFocusList;
STATIC_ASSERT (ARRAY_SIZE (mFocusList) == ARRAY_SIZE (mFocusListReversed), "Mismatched focus list sizes");
FocusList = ((BootContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0)
? mFocusList
: mFocusListReversed;
NumFocusList = ARRAY_SIZE (mFocusList);
} else {
FocusList = mFocusListMinimal;
Expand Down Expand Up @@ -557,11 +569,20 @@ OcShowSimpleBootMenu (

ShutdownRestartRow = gST->ConOut->Mode->CursorRow;
gST->ConOut->OutputString (gST->ConOut, L" ");
RestartColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Restart|");
gST->ConOut->OutputString (gST->ConOut, L" ");
ShutdownColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Shutdown|");

if ((BootContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0) {
ShutdownColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Shutdown|");
gST->ConOut->OutputString (gST->ConOut, L" ");
RestartColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Restart|");
} else {
RestartColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Restart|");
gST->ConOut->OutputString (gST->ConOut, L" ");
ShutdownColumn = gST->ConOut->Mode->CursorColumn;
gST->ConOut->OutputString (gST->ConOut, L"|Shutdown|");
}

gST->ConOut->OutputString (gST->ConOut, L"\r\n");
} else {
Expand Down
23 changes: 22 additions & 1 deletion Platform/OpenCanopy/Views/BootPicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ extern INT64 mBackgroundImageOffsetY;
STATIC UINT32 mBootPickerLabelScrollHoldTime = 0;

STATIC GUI_OBJ *mBootPickerFocusList[] = {
&mBootPicker.Hdr.Obj,
&mCommonShutDown.Hdr.Obj,
&mCommonRestart.Hdr.Obj
};

STATIC GUI_OBJ *mBootPickerFocusListReversed[] = {
&mBootPicker.Hdr.Obj,
&mCommonRestart.Hdr.Obj,
&mCommonShutDown.Hdr.Obj
Expand Down Expand Up @@ -1318,6 +1324,18 @@ GLOBAL_REMOVE_IF_UNREFERENCED GUI_VIEW_CONTEXT mBootPickerViewContext = {
ARRAY_SIZE (mBootPickerFocusList)
};

GLOBAL_REMOVE_IF_UNREFERENCED GUI_VIEW_CONTEXT mBootPickerViewContextReversed = {
InternalCommonViewDraw,
InternalCommonViewPtrEvent,
ARRAY_SIZE (mBootPickerViewChildren),
mBootPickerViewChildren,
InternalBootPickerViewKeyEvent,
InternalGetCursorImage,
InternalBootPickerExitLoop,
mBootPickerFocusListReversed,
ARRAY_SIZE (mBootPickerFocusListReversed)
};

GLOBAL_REMOVE_IF_UNREFERENCED GUI_VIEW_CONTEXT mBootPickerViewContextMinimal = {
InternalCommonViewDraw,
InternalCommonViewPtrEvent,
Expand Down Expand Up @@ -1870,7 +1888,10 @@ BootPickerViewInitialize (
DrawContext,
GuiContext,
(GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_MINIMAL_UI) == 0
? &mBootPickerViewContext
? ((GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0
? &mBootPickerViewContext
: &mBootPickerViewContextReversed
)
: &mBootPickerViewContextMinimal
);

Expand Down
14 changes: 12 additions & 2 deletions Platform/OpenCanopy/Views/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,24 @@ CommonViewInitialize (
ShutDownWidth = MAX (ShutDownImage->Width, FocusImage->Width);
ShutDownHeight = MAX (ShutDownImage->Height, FocusImage->Height);

mCommonRestart.Hdr.Obj.OffsetX = (RestartWidth - RestartImage->Width) / 2;
if ((GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0) {
mCommonRestart.Hdr.Obj.OffsetX = ShutDownWidth + BOOT_ACTION_BUTTON_SPACE * GuiContext->Scale + (RestartWidth - RestartImage->Width) / 2;
} else {
mCommonRestart.Hdr.Obj.OffsetX = (RestartWidth - RestartImage->Width) / 2;
}

mCommonRestart.Hdr.Obj.OffsetY = (RestartHeight - RestartImage->Height) / 2;
mCommonRestart.Hdr.Obj.Width = RestartImage->Width;
mCommonRestart.Hdr.Obj.Height = RestartImage->Height;
mCommonRestart.ImageId = ICON_RESTART;
mCommonRestart.ImageState = ICON_TYPE_BASE;

mCommonShutDown.Hdr.Obj.OffsetX = RestartWidth + BOOT_ACTION_BUTTON_SPACE * GuiContext->Scale + (ShutDownWidth - ShutDownImage->Width) / 2;
if ((GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0) {
mCommonShutDown.Hdr.Obj.OffsetX = (ShutDownWidth - ShutDownImage->Width) / 2;
} else {
mCommonShutDown.Hdr.Obj.OffsetX = RestartWidth + BOOT_ACTION_BUTTON_SPACE * GuiContext->Scale + (ShutDownWidth - ShutDownImage->Width) / 2;
}

mCommonShutDown.Hdr.Obj.OffsetY = (ShutDownHeight - ShutDownImage->Height) / 2;
mCommonShutDown.Hdr.Obj.Width = ShutDownImage->Width;
mCommonShutDown.Hdr.Obj.Height = ShutDownImage->Height;
Expand Down
23 changes: 22 additions & 1 deletion Platform/OpenCanopy/Views/Password.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ STATIC GUI_INTERPOLATION mPasswordIncorrectInterpol = {
};

STATIC GUI_OBJ *mPasswordFocusList[] = {
&mPasswordBoxContainer.Obj,
&mCommonShutDown.Hdr.Obj,
&mCommonRestart.Hdr.Obj
};

STATIC GUI_OBJ *mPasswordFocusListReversed[] = {
&mPasswordBoxContainer.Obj,
&mCommonRestart.Hdr.Obj,
&mCommonShutDown.Hdr.Obj
Expand Down Expand Up @@ -608,6 +614,18 @@ STATIC GUI_VIEW_CONTEXT mPasswordViewContext = {
ARRAY_SIZE (mPasswordFocusList)
};

STATIC GUI_VIEW_CONTEXT mPasswordViewContextReversed = {
InternalCommonViewDraw,
InternalPasswordViewPtrEvent,
ARRAY_SIZE (mPasswordViewChildren),
mPasswordViewChildren,
InternalPasswordViewKeyEvent,
InternalGetCursorImage,
InternalPasswordExitLoop,
mPasswordFocusListReversed,
ARRAY_SIZE (mPasswordFocusListReversed)
};

STATIC GUI_VIEW_CONTEXT mPasswordViewContextMinimal = {
InternalCommonViewDraw,
InternalPasswordViewPtrEvent,
Expand Down Expand Up @@ -753,7 +771,10 @@ PasswordViewInitialize (
DrawContext,
GuiContext,
(GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_MINIMAL_UI) == 0
? &mPasswordViewContext
? ((GuiContext->PickerContext->PickerAttributes & OC_ATTR_USE_REVERSED_UI) == 0
? &mPasswordViewContext
: &mPasswordViewContextReversed
)
: &mPasswordViewContextMinimal
);

Expand Down

0 comments on commit 2b66a70

Please sign in to comment.