Skip to content

Commit

Permalink
Set listview position/size using UpdateLayout() when creating new tab
Browse files Browse the repository at this point in the history
Previously, the listview position and size were set using a custom
function that positioned only the listview. Doing that in a separate
function doesn't make much sense, however, as the implementation could
very easily diverge from the implementation contained within
UpdateLayout().

Therefore, UpdateLayout() is now used to position and size the listview
associated with a new tab.
  • Loading branch information
derceg committed Dec 25, 2024
1 parent 5c337f8 commit 7fe0398
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 95 deletions.
2 changes: 0 additions & 2 deletions Explorer++/Explorer++/CoreInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ class CoreInterface
virtual void ShowTabBar() = 0;
virtual void HideTabBar() = 0;

virtual void SetListViewInitialPosition(HWND hListView) = 0;

virtual void FocusChanged() = 0;

virtual boost::signals2::connection AddTabsInitializedObserver(
Expand Down
1 change: 0 additions & 1 deletion Explorer++/Explorer++/Explorer++.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ class Explorerplusplus :

/* Window state update. */
void UpdateWindowStates(const Tab &tab);
void SetListViewInitialPosition(HWND hListView) override;
void ToggleFolders();
void OnTreeViewHolderResized(int newWidth);
void ToggleDualPane();
Expand Down
2 changes: 1 addition & 1 deletion Explorer++/Explorer++/ShellBrowser/ShellBrowserImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ HWND ShellBrowserImpl::CreateListView(HWND parent)
// return NULL. The actual view mode set here doesn't matter, since it will be updated when
// navigating to a folder.
return ::CreateListView(parent,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_REPORT | LVS_EDITLABELS
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_REPORT | LVS_EDITLABELS
| LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | WS_TABSTOP
| LVS_ALIGNTOP);
}
Expand Down
7 changes: 0 additions & 7 deletions Explorer++/Explorer++/TabContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,6 @@ Tab &TabContainer::SetUpNewTab(Tab &tab, NavigateParams &navigateParams,
the folder). */
index = InsertNewTab(index, tab.GetId(), navigateParams.pidl, tabSettings.name);

// Note that for the listview window to be shown, it has to have a non-zero
// size. If the size is zero at the point it's shown, it will instead remain
// hidden, even if it's later resized. Currently, if the tab is selected,
// the listview is shown during the OnTabSelected() call below. Therefore,
// the listview needs to have a non-zero size before that point.
m_coreInterface->SetListViewInitialPosition(tab.GetShellBrowserImpl()->GetListView());

bool selected = false;

if (tabSettings.selected)
Expand Down
4 changes: 4 additions & 0 deletions Explorer++/Explorer++/TabHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void Explorerplusplus::OnTabCreated(int tabId, BOOL switchToNewTab)
/* TODO: This subclass needs to be removed. */
SetWindowSubclass(tab.GetShellBrowserImpl()->GetListView(), ListViewProcStub, 0,
reinterpret_cast<DWORD_PTR>(this));

// A tab has been created, so this call is needed in order to set the size and position of the
// tab's listview control.
UpdateLayout();
}

boost::signals2::connection Explorerplusplus::AddTabsInitializedObserver(
Expand Down
84 changes: 0 additions & 84 deletions Explorer++/Explorer++/WindowHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,10 @@

#include "stdafx.h"
#include "Explorer++.h"
#include "App.h"
#include "Config.h"
#include "HolderWindow.h"
#include "IconResourceLoader.h"
#include "MainRebarView.h"
#include "MainToolbar.h"
#include "MainToolbarButtons.h"
#include "Runtime.h"
#include "ShellTreeView/ShellTreeView.h"
#include "TabContainer.h"
#include "../Helper/Controls.h"
#include "../Helper/DpiCompatibility.h"
#include "../Helper/WindowHelper.h"

/* TODO: This should be linked to OnSize(). */
void Explorerplusplus::SetListViewInitialPosition(HWND hListView)
{
RECT rc;
int mainWindowWidth;
int mainWindowHeight;
int indentBottom = 0;
int indentTop = 0;
int indentLeft = 0;
int indentRight = 0;
int indentRebar = 0;

GetClientRect(m_hContainer, &rc);

mainWindowWidth = GetRectWidth(&rc);
mainWindowHeight = GetRectHeight(&rc);

if (m_mainRebarView)
{
GetWindowRect(m_mainRebarView->GetHWND(), &rc);
indentRebar += GetRectHeight(&rc);
}

if (m_config->showStatusBar)
{
GetWindowRect(m_hStatusBar, &rc);
indentBottom += GetRectHeight(&rc);
}

if (m_config->showDisplayWindow.get())
{
if (m_config->displayWindowVertical)
{
indentRight += m_displayWindowWidth;
}
else
{
indentBottom += m_displayWindowHeight;
}
}

if (m_config->showFolders.get())
{
GetClientRect(m_treeViewHolder->GetHWND(), &rc);
indentLeft = GetRectWidth(&rc);
}

indentTop = indentRebar;

RECT tabWindowRect;
GetClientRect(GetActivePane()->GetTabContainer()->GetHWND(), &tabWindowRect);

int tabWindowHeight = GetRectHeight(&tabWindowRect);

if (m_bShowTabBar)
{
if (!m_config->showTabBarAtBottom.get())
{
indentTop += tabWindowHeight;
}
}

int width = mainWindowWidth - indentLeft - indentRight;
int height = mainWindowHeight - indentTop - indentBottom;

if (m_config->showTabBarAtBottom.get())
{
height -= tabWindowHeight;
}

SetWindowPos(hListView, nullptr, indentLeft, indentTop, width, height,
SWP_HIDEWINDOW | SWP_NOZORDER);
}

void Explorerplusplus::ToggleFolders()
{
m_config->showFolders = !m_config->showFolders.get();
Expand Down

0 comments on commit 7fe0398

Please sign in to comment.