Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Jan 7, 2024
1 parent 3e84385 commit 8132c04
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/WinWebDiffLib/DiffLocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DiffLocation
rect.scrollTop = value[L"scrollTop"].GetFloat();
rect.scrollWidth = value[L"scrollWidth"].GetFloat();
rect.scrollHeight = value[L"scrollHeight"].GetFloat();
rect.clientWidth = value[L"clientWidth"].GetFloat();
rect.clientHeight = value[L"clientHeight"].GetFloat();
containerRects.push_back(rect);
}
m_diffRects[pane].insert_or_assign(window, diffRects);
Expand Down Expand Up @@ -103,6 +105,8 @@ class DiffLocation
rect.scrollTop = containerRect.scrollTop;
rect.scrollWidth = containerRect.scrollWidth;
rect.scrollHeight = containerRect.scrollHeight;
rect.clientWidth = containerRect.clientWidth;
rect.clientHeight = containerRect.clientHeight;
m_containerRectsSerialized[pane].push_back(rect);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/WinWebDiffLib/WebDiffWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class CWebDiffWindow : public IWebDiffWindow
{
if (m_bSynchronizeEvents && GetSyncEventFlag(EVENT_SCROLL))
syncEvent(ev.pane, msg);
for (int pane = 0; pane < m_nPanes; ++pane)
m_webWindow[pane].PostWebMessageAsJsonInAllFrames(L"{\"event\": \"diffRects\"}");
}
else if (event == L"click")
{
Expand Down
35 changes: 31 additions & 4 deletions src/WinWebDiffLib/WebToolWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
case ID_WEB_COMPARE_RESOURCETREES:
m_pWebDiffWindow->RaiseEvent({ WebDiffEvent::CompareResourceTreesSelected, -1 });
break;
case IDC_DIFFMAP:
if (codeNotify == STN_CLICKED)
{
POINT pt;
GetCursorPos(&pt);
ScreenToClient(hwndCtl, &pt);
RECT rc;
GetClientRect(hwndCtl, &rc);
/*
m_pWebDiffWindow->ScrollTo(
pt.x * pImgMergeWindow->GetDiffImageWidth() / rc.right,
pt.y * pImgMergeWindow->GetDiffImageHeight() / rc.bottom,
true);
*/
}
break;
}
}

Expand Down Expand Up @@ -414,16 +430,16 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
}
}
const int margin = 2;
double ratiox = static_cast<double>(width - margin * paneCount) / (maxPaneWidth * paneCount);
double ratioy = static_cast<double>(height) / maxPaneHeight;
double ratiox = static_cast<double>(width - margin * (paneCount * 2)) / (maxPaneWidth * paneCount);
double ratioy = static_cast<double>(height - margin * 2) / maxPaneHeight;
auto getContainerRect = [&](int pane, int i) -> RECT {
RECT rc;
if (i == 0)
{
rc.left = left + margin + width * pane / paneCount;
rc.top = top + margin;
rc.right = rc.left - margin + static_cast<int>(containerRects[pane][i].scrollWidth * ratiox);
rc.bottom = rc.top - margin + static_cast<int>(containerRects[pane][i].scrollHeight * ratioy);
rc.right = rc.left + static_cast<int>(containerRects[pane][i].scrollWidth * ratiox);
rc.bottom = rc.top + static_cast<int>(containerRects[pane][i].scrollHeight * ratioy);
}
else
{
Expand Down Expand Up @@ -453,6 +469,17 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
const RECT rcContainer = getContainerRect(pane, i);
Rectangle(pDrawItem->hDC, rcContainer.left, rcContainer.top, rcContainer.right, rcContainer.bottom);
}

if (containerCounts[pane] > 0)
{
RECT rcContainer = getContainerRect(pane, 0);
rcContainer.left += static_cast<int>(containerRects[pane][0].scrollLeft * ratiox);
rcContainer.right = static_cast<int>(rcContainer.left + containerRects[pane][0].clientWidth * ratiox);
rcContainer.top += static_cast<int>(containerRects[pane][0].scrollTop * ratioy);
rcContainer.bottom = static_cast<int>(rcContainer.top + containerRects[pane][0].clientHeight * ratioy);
Rectangle(pDrawItem->hDC, rcContainer.left, rcContainer.top, rcContainer.right, rcContainer.bottom);
}

SelectBrush(pDrawItem->hDC, hOldBrush);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/WinWebDiffLib/WinWebDiffLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct IWebDiffWindow
float scrollTop;
float scrollWidth;
float scrollHeight;
float clientWidth;
float clientHeight;
};
struct DiffRect : public Rect
{
Expand Down
Binary file modified src/WinWebDiffLib/WinWebDiffLib.js
Binary file not shown.

0 comments on commit 8132c04

Please sign in to comment.