提交 8f84ad21 编写于 作者: M Marvin Häuser

OpenCanopy: Move selector to BootPickerContainer

上级 747be854
...@@ -113,7 +113,7 @@ BootPickerViewInitialize ( ...@@ -113,7 +113,7 @@ BootPickerViewInitialize (
VOID VOID
BootPickerViewLateInitialize ( BootPickerViewLateInitialize (
VOID IN UINT8 DefaultIndex
); );
EFI_STATUS EFI_STATUS
...@@ -121,8 +121,7 @@ BootPickerEntriesSet ( ...@@ -121,8 +121,7 @@ BootPickerEntriesSet (
IN OC_PICKER_CONTEXT *Context, IN OC_PICKER_CONTEXT *Context,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext, IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN OC_BOOT_ENTRY *Entry, IN OC_BOOT_ENTRY *Entry,
IN UINT8 EntryIndex, IN UINT8 EntryIndex
IN BOOLEAN Default
); );
VOID VOID
......
...@@ -122,8 +122,7 @@ OcShowMenuByOc ( ...@@ -122,8 +122,7 @@ OcShowMenuByOc (
BootContext->PickerContext, BootContext->PickerContext,
&mGuiContext, &mGuiContext,
BootEntries[Index], BootEntries[Index],
(UINT8) Index + 1, (UINT8) Index
Index == BootContext->DefaultEntry->EntryIndex - 1
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
OcShowMenuByOcLeave (); OcShowMenuByOcLeave ();
...@@ -131,7 +130,7 @@ OcShowMenuByOc ( ...@@ -131,7 +130,7 @@ OcShowMenuByOc (
} }
} }
BootPickerViewLateInitialize (); BootPickerViewLateInitialize ((UINT8) BootContext->DefaultEntry->EntryIndex - 1);
GuiRedrawAndFlushScreen (&mDrawContext); GuiRedrawAndFlushScreen (&mDrawContext);
......
...@@ -53,7 +53,6 @@ InternalGetVolumeEntry ( ...@@ -53,7 +53,6 @@ InternalGetVolumeEntry (
IN UINT32 Index IN UINT32 Index
) )
{ {
ASSERT (Index > 0);
ASSERT (Index < mBootPicker.Hdr.Obj.NumChildren); ASSERT (Index < mBootPicker.Hdr.Obj.NumChildren);
return (GUI_VOLUME_ENTRY *) ( return (GUI_VOLUME_ENTRY *) (
mBootPicker.Hdr.Obj.Children[Index] mBootPicker.Hdr.Obj.Children[Index]
...@@ -231,7 +230,6 @@ InternalBootPickerSelectEntry ( ...@@ -231,7 +230,6 @@ InternalBootPickerSelectEntry (
CONST GUI_VOLUME_ENTRY *NewEntry; CONST GUI_VOLUME_ENTRY *NewEntry;
ASSERT (This != NULL); ASSERT (This != NULL);
ASSERT (NewIndex > 0);
ASSERT (NewIndex < mBootPicker.Hdr.Obj.NumChildren); ASSERT (NewIndex < mBootPicker.Hdr.Obj.NumChildren);
This->SelectedIndex = NewIndex; This->SelectedIndex = NewIndex;
...@@ -240,7 +238,7 @@ InternalBootPickerSelectEntry ( ...@@ -240,7 +238,7 @@ InternalBootPickerSelectEntry (
ASSERT (mBootPickerSelector.Hdr.Obj.Width <= NewEntry->Hdr.Obj.Width); ASSERT (mBootPickerSelector.Hdr.Obj.Width <= NewEntry->Hdr.Obj.Width);
ASSERT_EQUALS (This->Hdr.Obj.Height, mBootPickerSelector.Hdr.Obj.OffsetY + mBootPickerSelector.Hdr.Obj.Height); ASSERT_EQUALS (This->Hdr.Obj.Height, mBootPickerSelector.Hdr.Obj.OffsetY + mBootPickerSelector.Hdr.Obj.Height);
mBootPickerSelector.Hdr.Obj.OffsetX = NewEntry->Hdr.Obj.OffsetX; mBootPickerSelector.Hdr.Obj.OffsetX = mBootPicker.Hdr.Obj.OffsetX + NewEntry->Hdr.Obj.OffsetX;
mBootPickerSelector.Hdr.Obj.OffsetX += (NewEntry->Hdr.Obj.Width - mBootPickerSelector.Hdr.Obj.Width) / 2; mBootPickerSelector.Hdr.Obj.OffsetX += (NewEntry->Hdr.Obj.Width - mBootPickerSelector.Hdr.Obj.Width) / 2;
if (DrawContext != NULL) { if (DrawContext != NULL) {
...@@ -345,7 +343,6 @@ InternalBootPickerChangeEntry ( ...@@ -345,7 +343,6 @@ InternalBootPickerChangeEntry (
ASSERT (This != NULL); ASSERT (This != NULL);
ASSERT (DrawContext != NULL); ASSERT (DrawContext != NULL);
ASSERT (NewIndex > 0);
ASSERT (NewIndex < This->Hdr.Obj.NumChildren); ASSERT (NewIndex < This->Hdr.Obj.NumChildren);
// //
// The caller must guarantee the entry is actually new for performance // The caller must guarantee the entry is actually new for performance
...@@ -429,7 +426,7 @@ InternalBootPickerKeyEvent ( ...@@ -429,7 +426,7 @@ InternalBootPickerKeyEvent (
); );
} }
} else if (Key == OC_INPUT_LEFT) { } else if (Key == OC_INPUT_LEFT) {
if (mBootPicker.SelectedIndex - 1 > 0) { if (mBootPicker.SelectedIndex > 0) {
// //
// Redraw the two now (un-)selected entries. // Redraw the two now (un-)selected entries.
// //
...@@ -442,7 +439,7 @@ InternalBootPickerKeyEvent ( ...@@ -442,7 +439,7 @@ InternalBootPickerKeyEvent (
); );
} }
} else if (Key == OC_INPUT_CONTINUE) { } else if (Key == OC_INPUT_CONTINUE) {
if (mBootPicker.Hdr.Obj.NumChildren > 1) { if (mBootPicker.Hdr.Obj.NumChildren > 0) {
SelectedEntry = InternalGetVolumeEntry (mBootPicker.SelectedIndex); SelectedEntry = InternalGetVolumeEntry (mBootPicker.SelectedIndex);
SelectedEntry->Context->SetDefault = Modifier; SelectedEntry->Context->SetDefault = Modifier;
GuiContext->ReadyToBoot = TRUE; GuiContext->ReadyToBoot = TRUE;
...@@ -939,7 +936,7 @@ InternalBootPickerLeftScrollPtrEvent ( ...@@ -939,7 +936,7 @@ InternalBootPickerLeftScrollPtrEvent (
// The internal design ensures a selected entry cannot be off-screen, // The internal design ensures a selected entry cannot be off-screen,
// scrolling offsets it by at most one spot. // scrolling offsets it by at most one spot.
// //
if (mBootPicker.SelectedIndex > 1) { if (mBootPicker.SelectedIndex > 0) {
InternalBootPickerSelectEntry ( InternalBootPickerSelectEntry (
&mBootPicker, &mBootPicker,
DrawContext, DrawContext,
...@@ -1240,12 +1237,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED GUI_OBJ_CLICKABLE mBootPickerSelector = { ...@@ -1240,12 +1237,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED GUI_OBJ_CLICKABLE mBootPickerSelector = {
0, 0,
NULL NULL
}, },
&mBootPicker.Hdr.Obj &mBootPickerContainer.Obj
}, },
NULL NULL
}; };
STATIC GUI_OBJ_CHILD *mBootPickerContainerChilds[] = { &mBootPicker.Hdr }; STATIC GUI_OBJ_CHILD *mBootPickerContainerChilds[] = {
&mBootPickerSelector.Hdr,
&mBootPicker.Hdr
};
GLOBAL_REMOVE_IF_UNREFERENCED GUI_OBJ_CHILD mBootPickerContainer = { GLOBAL_REMOVE_IF_UNREFERENCED GUI_OBJ_CHILD mBootPickerContainer = {
{ {
...@@ -1393,8 +1393,7 @@ BootPickerEntriesSet ( ...@@ -1393,8 +1393,7 @@ BootPickerEntriesSet (
IN OC_PICKER_CONTEXT *Context, IN OC_PICKER_CONTEXT *Context,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext, IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN OC_BOOT_ENTRY *Entry, IN OC_BOOT_ENTRY *Entry,
IN UINT8 EntryIndex, IN UINT8 EntryIndex
IN BOOLEAN Default
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
...@@ -1411,7 +1410,6 @@ BootPickerEntriesSet ( ...@@ -1411,7 +1410,6 @@ BootPickerEntriesSet (
ASSERT (GuiContext != NULL); ASSERT (GuiContext != NULL);
ASSERT (Entry != NULL); ASSERT (Entry != NULL);
ASSERT (EntryIndex > 0);
ASSERT (EntryIndex < mBootPicker.Hdr.Obj.NumChildren); ASSERT (EntryIndex < mBootPicker.Hdr.Obj.NumChildren);
DEBUG ((DEBUG_INFO, "OCUI: Console attributes: %d\n", Context->ConsoleAttributes)); DEBUG ((DEBUG_INFO, "OCUI: Console attributes: %d\n", Context->ConsoleAttributes));
...@@ -1601,10 +1599,8 @@ BootPickerEntriesSet ( ...@@ -1601,10 +1599,8 @@ BootPickerEntriesSet (
VolumeEntry->Hdr.Obj.PtrEvent = InternalBootPickerEntryPtrEvent; VolumeEntry->Hdr.Obj.PtrEvent = InternalBootPickerEntryPtrEvent;
VolumeEntry->Hdr.Obj.NumChildren = 0; VolumeEntry->Hdr.Obj.NumChildren = 0;
VolumeEntry->Hdr.Obj.Children = NULL; VolumeEntry->Hdr.Obj.Children = NULL;
//
// The first entry is always the selector. if (EntryIndex > 0) {
//
if (EntryIndex > 1) {
PrevEntry = InternalGetVolumeEntry (EntryIndex - 1); PrevEntry = InternalGetVolumeEntry (EntryIndex - 1);
VolumeEntry->Hdr.Obj.OffsetX = PrevEntry->Hdr.Obj.OffsetX + (BOOT_ENTRY_DIMENSION + BOOT_ENTRY_SPACE) * GuiContext->Scale; VolumeEntry->Hdr.Obj.OffsetX = PrevEntry->Hdr.Obj.OffsetX + (BOOT_ENTRY_DIMENSION + BOOT_ENTRY_SPACE) * GuiContext->Scale;
} }
...@@ -1614,11 +1610,6 @@ BootPickerEntriesSet ( ...@@ -1614,11 +1610,6 @@ BootPickerEntriesSet (
mBootPicker.Hdr.Obj.Width += (BOOT_ENTRY_WIDTH + BOOT_ENTRY_SPACE) * GuiContext->Scale; mBootPicker.Hdr.Obj.Width += (BOOT_ENTRY_WIDTH + BOOT_ENTRY_SPACE) * GuiContext->Scale;
mBootPicker.Hdr.Obj.OffsetX -= (BOOT_ENTRY_WIDTH + BOOT_ENTRY_SPACE) * GuiContext->Scale / 2; mBootPicker.Hdr.Obj.OffsetX -= (BOOT_ENTRY_WIDTH + BOOT_ENTRY_SPACE) * GuiContext->Scale / 2;
if (Default) {
InternalBootPickerSelectEntry (&mBootPicker, NULL, VolumeEntry->Index);
GuiContext->BootEntry = Entry;
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
...@@ -1858,14 +1849,13 @@ BootPickerViewInitialize ( ...@@ -1858,14 +1849,13 @@ BootPickerViewInitialize (
mBootPicker.Hdr.Obj.OffsetX = mBootPickerContainer.Obj.Width / 2 + (UINT32) (BOOT_ENTRY_SPACE * GuiContext->Scale) / 2; mBootPicker.Hdr.Obj.OffsetX = mBootPickerContainer.Obj.Width / 2 + (UINT32) (BOOT_ENTRY_SPACE * GuiContext->Scale) / 2;
mBootPicker.Hdr.Obj.OffsetY = 0; mBootPicker.Hdr.Obj.OffsetY = 0;
mBootPicker.SelectedIndex = 1; mBootPicker.SelectedIndex = 0;
mBootPicker.Hdr.Obj.Children = AllocateZeroPool ((NumBootEntries + 1) * sizeof (*mBootPicker.Hdr.Obj.Children)); mBootPicker.Hdr.Obj.Children = AllocateZeroPool (NumBootEntries * sizeof (*mBootPicker.Hdr.Obj.Children));
if (mBootPicker.Hdr.Obj.Children == NULL) { if (mBootPicker.Hdr.Obj.Children == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
mBootPicker.Hdr.Obj.Children[0] = &mBootPickerSelector.Hdr; mBootPicker.Hdr.Obj.NumChildren = NumBootEntries;
mBootPicker.Hdr.Obj.NumChildren = NumBootEntries + 1;
mBootPickerRestart.CurrentImage = &GuiContext->Icons[ICON_RESTART][ICON_TYPE_BASE]; mBootPickerRestart.CurrentImage = &GuiContext->Icons[ICON_RESTART][ICON_TYPE_BASE];
mBootPickerRestart.Hdr.Obj.Width = mBootPickerRestart.CurrentImage->Width; mBootPickerRestart.Hdr.Obj.Width = mBootPickerRestart.CurrentImage->Width;
...@@ -1916,7 +1906,7 @@ BootPickerViewInitialize ( ...@@ -1916,7 +1906,7 @@ BootPickerViewInitialize (
VOID VOID
BootPickerViewLateInitialize ( BootPickerViewLateInitialize (
VOID IN UINT8 DefaultIndex
) )
{ {
UINT32 Index; UINT32 Index;
...@@ -1932,9 +1922,8 @@ BootPickerViewLateInitialize ( ...@@ -1932,9 +1922,8 @@ BootPickerViewLateInitialize (
if (ScrollOffset == 0) { if (ScrollOffset == 0) {
// //
// Find the first entry that is fully visible. // Find the first entry that is fully visible.
// First entry is always the selector.
// //
for (Index = 1; Index < mBootPicker.Hdr.Obj.NumChildren; ++Index) { for (Index = 0; Index < mBootPicker.Hdr.Obj.NumChildren; ++Index) {
// //
// Move the first partially visible boot entry to the very left to prevent // Move the first partially visible boot entry to the very left to prevent
// cut-off entries. This only applies when entries overflow. // cut-off entries. This only applies when entries overflow.
...@@ -1953,6 +1942,7 @@ BootPickerViewLateInitialize ( ...@@ -1953,6 +1942,7 @@ BootPickerViewLateInitialize (
} }
mBootPicker.Hdr.Obj.OffsetX += ScrollOffset; mBootPicker.Hdr.Obj.OffsetX += ScrollOffset;
InternalBootPickerSelectEntry (&mBootPicker, NULL, DefaultIndex);
} }
VOID VOID
...@@ -1963,11 +1953,7 @@ BootPickerViewDeinitialize ( ...@@ -1963,11 +1953,7 @@ BootPickerViewDeinitialize (
{ {
UINT32 Index; UINT32 Index;
ASSERT (mBootPicker.Hdr.Obj.Children[0] == &mBootPickerSelector.Hdr); for (Index = 0; Index < mBootPicker.Hdr.Obj.NumChildren; ++Index) {
//
// Last entry is always the selector, which is special and cannot be freed.
//
for (Index = 1; Index < mBootPicker.Hdr.Obj.NumChildren; ++Index) {
InternalBootPickerEntryDestruct (InternalGetVolumeEntry (Index)); InternalBootPickerEntryDestruct (InternalGetVolumeEntry (Index));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册