aboutsummaryrefslogtreecommitdiff
path: root/c/layout.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-09-02 20:16:04 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-09-02 20:16:18 +0200
commitbc4cef92d8efbf97a9215122abc2d7247c287f12 (patch)
treea5ca307281c4f143b5f172428c9fd2b629d6b426 /c/layout.cpp
parent5c1c2ce2bdbf9735ad8a4d162609a8c22a4f0954 (diff)
downloadEpisodeBrowser-bc4cef92d8efbf97a9215122abc2d7247c287f12.tar.gz
Improve Window object.
Diffstat (limited to 'c/layout.cpp')
-rw-r--r--c/layout.cpp129
1 files changed, 0 insertions, 129 deletions
diff --git a/c/layout.cpp b/c/layout.cpp
deleted file mode 100644
index e817b23..0000000
--- a/c/layout.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-#include <windows.h>
-
-#include "episodelistview.h"
-#include "datalistview.h"
-#include "layout.h"
-#include "main.h"
-#include "win.h"
-
-extern Window* g_window;
-extern HWND g_hWndStatus;
-
-void UpdateLayout(int w, int h)
-{
- if (!g_hWndStatus) return;
-
- RECT rc, rrStatus;
- if (w && h) rc = {0, 0, w, h};
- else Require(GetClientRect(g_window->hWnd, &rc));
- Require(GetRelativeRect(g_hWndStatus, &rrStatus));
-
- SendMessageW(g_window->hWnd, WM_SETREDRAW, FALSE, 0);
-
- /* Resize list views. */
- const long pad = EBIsThemeActive()? Dpi(6): 0; /* Add padding in modern themes. */
- const long cyDlv = rrStatus.top-g_window->dlv.Height()-pad;
- Require(SetWindowRect(g_window->dlv.hWnd, pad, cyDlv, rc.right-pad, rrStatus.top-pad));
- Require(SetWindowRect(g_window->elv.hWnd, pad, pad, rc.right-pad, cyDlv-pad));
- g_window->dlv.ResizeColumns(rc.right-pad-pad);
- g_window->elv.ResizeColumns(rc.right-pad-pad);
-
- /* Resize status bar parts. */
- const int aParts[] = {rc.right-Dpi(55), rc.right};
- SendMessageW(g_hWndStatus, SB_SETPARTS,
- sizeof(aParts), reinterpret_cast<LPARAM>(aParts));
-
- SendMessageW(g_window->hWnd, WM_SETREDRAW, TRUE, 0);
- RedrawWindow(g_window->hWnd, nullptr, nullptr,
- RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN);
-}
-
-bool Dragger::IsDouble(const long time, const POINT& pt)
-{
- const bool dbl = time-m_time0 <= static_cast<long>(GetDoubleClickTime())
- && abs(pt.x-m_pt0.x) <= Metric<SM_CXDOUBLECLK>
- && abs(pt.y-m_pt0.y) <= Metric<SM_CYDOUBLECLK>;
- m_time0 = time;
- m_pt0 = std::move(pt);
- return dbl;
-}
-
-bool Dragger::IsDown() const
-{
- return GetKeyState(VK_LBUTTON) & 0x8000;
-}
-
-bool Dragger::HandleLButtonDown()
-{
- POINT pt;
- Require(GetRelativeCursorPos(parent.hWnd, &pt));
- if (!InDragArea(pt.x, pt.y)) return false;
-
- if (IsDouble(GetMessageTime(), pt)) {
- m_bActive = false;
- Reset();
- } else
- m_bActive = true;
-
- return m_bActive;
-}
-
-bool Dragger::HandleSetCursor()
-{
- POINT pt;
- Require(GetRelativeCursorPos(parent.hWnd, &pt));
-
- extern HCURSOR g_hcSizeNs;
- bool r = true;
- if (InDragArea(pt.x, pt.y))
- SetCursor(g_hcSizeNs);
- else
- r = false;
- if (!m_bActive)
- return r;
- Drag(pt.x, pt.y);
- if (!IsDown()) {
- m_bActive = false;
- Done();
- }
- return r;
-}
-
-bool DlvDragger::InDragArea(const int x, const int y) const
-{
- RECT rrDlv;
- Require(GetRelativeRect(g_window->dlv.hWnd, &rrDlv));
-
- const int pad = EBIsThemeActive()? Dpi(6): 0;
- const int extra = EBIsThemeActive()? 0: Dpi(2);
- if (x < rrDlv.left || x > rrDlv.right) return false;
- if (y < rrDlv.top-pad*2-extra*3 || y > rrDlv.top+extra) return false;
- return true;
-}
-
-void DlvDragger::Drag(const int, const int y) const
-{
- RECT rrDlv;
- Require(GetRelativeRect(g_window->dlv.hWnd, &rrDlv));
-
- if (y < Dpi(50) || y > rrDlv.bottom-Dpi(20)) return;
-
- int h;
- h = rrDlv.bottom-y;
- g_window->dlv.SetHeight(h);
- UpdateLayout();
- RedrawWindow(g_window->hWnd, nullptr, nullptr,
- RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);
-}
-
-void DlvDragger::Reset() const
-{
- g_window->dlv.SetHeight(0);
- g_window->cfg.heightDlv = 0;
- UpdateLayout();
-}
-
-void DlvDragger::Done() const
-{
- g_window->cfg.heightDlv = g_window->dlv.Height();
-}