Skip to content

Commit

Permalink
Works?
Browse files Browse the repository at this point in the history
  • Loading branch information
MKadaner committed Dec 27, 2023
1 parent 780766a commit 46e07f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions far/vmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ void VMenu::DrawMenu()
if (CheckFlags(VMENU_AUTOHIGHLIGHT))
AssignHighlights(CheckFlags(VMENU_REVERSEHIGHLIGHT));

const auto VisualTopPos{ AdjustTopPos(ClientRect.height()) };
const auto VisualTopPos{ AdjustTopPos(BoxType) };

if (ClientRect.width() <= 0)
return;
Expand Down Expand Up @@ -2289,12 +2289,14 @@ void VMenu::DrawTitles() const
}
}

int VMenu::AdjustTopPos(const int ClientHeight)
int VMenu::AdjustTopPos(const int BoxType)
{
// 2023-12-26 MZK: The magik here is beyond my comprehension

int VisualSelectPos = GetVisualPos(SelectPos);
int VisualTopPos = GetVisualPos(TopPos);

// 2023-07-09 MZK: What is it? Should it be ClientRect.height() instead of m_Where.height()?
// коррекция Top`а
if (VisualTopPos + GetShowItemCount() >= m_Where.height() - 1 && VisualSelectPos == GetShowItemCount() - 1)
{
VisualTopPos--;
Expand All @@ -2303,11 +2305,13 @@ int VMenu::AdjustTopPos(const int ClientHeight)
VisualTopPos = 0;
}

VisualTopPos = std::min(VisualTopPos, GetShowItemCount() - (ClientHeight - 4));
// 2023-12-26 MZK: (m_Where.height() - 2 - (BoxType == NO_BOX ? 2 : 0)) == (ClientRect.height() - (BoxType == NO_BOX ? 4 : 0))
VisualTopPos = std::min(VisualTopPos, GetShowItemCount() - (m_Where.height() - 2 - (BoxType == NO_BOX ? 2 : 0)));

if (VisualSelectPos > VisualTopPos + (ClientHeight - 1))
// 2023-12-26 MZK: (m_Where.height() - 1 - (BoxType == NO_BOX ? 0 : 2)) == (ClientRect.height() - 1)
if (VisualSelectPos > VisualTopPos + (m_Where.height() - 1 - (BoxType == NO_BOX ? 0 : 2)))
{
VisualTopPos = VisualSelectPos - (ClientHeight - 1);
VisualTopPos = VisualSelectPos - (m_Where.height() - 1 - (BoxType == NO_BOX ? 0 : 2));
}

if (VisualSelectPos < VisualTopPos)
Expand Down
2 changes: 1 addition & 1 deletion far/vmenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class VMenu final: public Modal
[[nodiscard]] int CalculateBoxType() const noexcept { return CalculateBoxType(VMFlags); }
rectangle GetClientRect(int BoxType) const noexcept;
void DrawTitles() const;
int AdjustTopPos(int ClientHeight); // Sets TopPos
int AdjustTopPos(int BoxType); // Sets TopPos
void DrawSeparator(size_t CurItemIndex, int BoxType, int Y) const;
void ConnectSeparator(size_t CurItemIndex, string& separator, int BoxType) const;
void ApplySeparatorName(const MenuItemEx& CurItem, string& separator) const;
Expand Down

0 comments on commit 46e07f8

Please sign in to comment.