Skip to content

Commit

Permalink
拖动候选框时自动识别被翻转的候选框
Browse files Browse the repository at this point in the history
  • Loading branch information
Techince committed Nov 24, 2023
1 parent 86245ec commit c35ce0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
34 changes: 22 additions & 12 deletions WeaselUI/WeaselPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,21 @@ LRESULT WeaselPanel::OnLeftClicked(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL

LRESULT WeaselPanel::OnLeftReleased(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (!m_following)
if (!m_following && m_holder)
{
RECT rcWindow;
GetWindowRect(&rcWindow);
if (m_reversed)
{
rcWindow.top = rcWindow.bottom;
}
else
{
rcWindow.bottom = rcWindow.top;
}
rcWindow.right = rcWindow.left;
_SetRectCallback(rcWindow);

m_holder = false;
ReleaseCapture();
}
Expand Down Expand Up @@ -432,16 +445,13 @@ LRESULT WeaselPanel::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
{
CPoint ptTemp{ point - ptPreview };
CRect rc{};

GetWindowRect(&rc);
CPoint pt{ 0, -rc.Height() };
rc.OffsetRect(ptTemp);
MoveWindow(&rc);
rc.OffsetRect(pt);
_SetRectCallback(rc);
//#ifdef TEST
// LOG(INFO) << std::format("Form WeaselPanel::OnMoveMouse. m_move = {}, rect.bottom = {}, pt = ({}, {}), point.y = {}", m_movePixels, rect.bottom, rc.left, rc.top, point.y);
//#endif // TEST

#ifdef TEST
LOG(INFO) << std::format("Form WeaselPanel::OnMoveMouse. pt = ({}, {}), point.y = {},", rc.left, rc.top, point.y);
#endif // TEST
return 0;
}
ptPreview = point;
Expand Down Expand Up @@ -1089,7 +1099,7 @@ void WeaselPanel::_RepositionWindow(bool adj)
rcWorkArea.right -= width;
rcWorkArea.bottom -= height;
static int saved_bottom{ rcWorkArea.bottom };
static bool reversed{ false };
m_reversed = false;
int x = m_inputPos.left;
int y = m_inputPos.bottom;
if (m_style.shadow_radius > 0)
Expand Down Expand Up @@ -1117,10 +1127,10 @@ void WeaselPanel::_RepositionWindow(bool adj)
#ifdef TEST
LOG(INFO) << std::format("From WeaselPanel::_RepositionWindow. First: x = {}, y = {}, height = {}, rcWorkArea.bottom = {}, saved_bottom = {}, adj = {}", x, y, height, rcWorkArea.bottom, saved_bottom, adj);
#endif // TEST
if (reversed)
if (m_reversed)
{
y -= saved_bottom - rcWorkArea.bottom;
reversed = false;
m_reversed = false;
}
saved_bottom = rcWorkArea.bottom;

Expand All @@ -1129,7 +1139,7 @@ void WeaselPanel::_RepositionWindow(bool adj)
if (m_style.layout_type == UIStyle::LAYOUT_VERTICAL || m_style.layout_type == UIStyle::LAYOUT_VERTICAL_TEXT)
m_sticky = true;
y = m_inputPos.top - height; // over workarea bottom
reversed = true;
m_reversed = true;

m_istorepos = (m_style.vertical_auto_reverse && m_style.layout_type == UIStyle::LAYOUT_VERTICAL);
if (m_style.shadow_radius > 0)
Expand Down
1 change: 1 addition & 0 deletions WeaselUI/WeaselPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ class WeaselPanel :
bool m_following{ true };
bool m_holder{};
bool m_sticky{};
bool m_reversed{};
};

0 comments on commit c35ce0f

Please sign in to comment.