From 46e07f8838c77387de727383cbc8f43be7c8da55 Mon Sep 17 00:00:00 2001 From: "Michael Z. Kadaner" Date: Tue, 26 Dec 2023 20:48:55 -0800 Subject: [PATCH] Works? --- far/vmenu.cpp | 16 ++++++++++------ far/vmenu.hpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/far/vmenu.cpp b/far/vmenu.cpp index da36d787cb..d52294595a 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -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; @@ -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--; @@ -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) diff --git a/far/vmenu.hpp b/far/vmenu.hpp index 4d7de0cb9b..9b8829a190 100644 --- a/far/vmenu.hpp +++ b/far/vmenu.hpp @@ -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;