Asset Browser Search View Column Resizing (#4087)
* Added resizing Signed-off-by: igarri <igarri@amazon.com> * Added Signals and Slots for resizing columns Signed-off-by: igarri <igarri@amazon.com> * Cleaned up code Signed-off-by: igarri <igarri@amazon.com> * Fixed Column Resize when docking Signed-off-by: igarri <igarri@amazon.com> * Added constants Signed-off-by: igarri <igarri@amazon.com> * Applied Code review feedback Signed-off-by: igarri <igarri@amazon.com> * aplied more feedback Signed-off-by: igarri <igarri@amazon.com> * Addressed Code Review Comments Signed-off-by: igarri <igarri@amazon.com> * Fixing bad merge Signed-off-by: igarri <igarri@amazon.com> * Added fix in initialization Signed-off-by: igarri <igarri@amazon.com> * Changed header setup sequence Signed-off-by: igarri <igarri@amazon.com>
This commit is contained in:
@@ -141,6 +141,10 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent)
|
||||
m_ui->m_assetBrowserTreeViewWidget, &AzAssetBrowser::AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget,
|
||||
&AzAssetBrowser::SearchWidget::ClearTypeFilter);
|
||||
|
||||
connect(
|
||||
this, &AzAssetBrowserWindow::SizeChangedSignal, m_ui->m_assetBrowserTableViewWidget,
|
||||
&AzAssetBrowser::AssetBrowserTableView::UpdateSizeSlot);
|
||||
|
||||
m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main");
|
||||
}
|
||||
|
||||
@@ -164,6 +168,25 @@ QObject* AzAssetBrowserWindow::createListenerForShowAssetEditorEvent(QObject* pa
|
||||
return listener;
|
||||
}
|
||||
|
||||
void AzAssetBrowserWindow::resizeEvent(QResizeEvent* resizeEvent)
|
||||
{
|
||||
// leftLayout is the parent of the tableView
|
||||
// rightLayout is the parent of the preview window.
|
||||
// Workaround: When docking windows this event keeps holding the old size of the widgets instead of the new one
|
||||
// but the resizeEvent holds the new size of the whole widget
|
||||
// So we have to save the proportions somehow
|
||||
const QWidget* leftLayout = m_ui->m_leftLayout;
|
||||
const QVBoxLayout* rightLayout = m_ui->m_rightLayout;
|
||||
|
||||
const float oldLeftLayoutWidth = aznumeric_cast<float>(leftLayout->geometry().width());
|
||||
const float oldWidth = aznumeric_cast<float>(leftLayout->geometry().width() + rightLayout->geometry().width());
|
||||
|
||||
const float newWidth = oldLeftLayoutWidth * aznumeric_cast<float>(resizeEvent->size().width()) / oldWidth;
|
||||
|
||||
emit SizeChangedSignal(aznumeric_cast<int>(newWidth));
|
||||
QWidget::resizeEvent(resizeEvent);
|
||||
}
|
||||
|
||||
void AzAssetBrowserWindow::OnInitViewToggleButton()
|
||||
{
|
||||
CreateSwitchViewMenu();
|
||||
|
||||
@@ -53,9 +53,17 @@ public:
|
||||
|
||||
static QObject* createListenerForShowAssetEditorEvent(QObject* parent);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void SizeChangedSignal(int newWidth);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* resizeEvent) override;
|
||||
|
||||
private:
|
||||
void OnInitViewToggleButton();
|
||||
void UpdateDisplayInfo();
|
||||
|
||||
protected slots:
|
||||
void CreateSwitchViewMenu();
|
||||
void SetExpandedAssetBrowserMode();
|
||||
|
||||
+10
@@ -151,6 +151,10 @@ namespace AzToolsFramework
|
||||
m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget,
|
||||
&SearchWidget::ClearTypeFilter);
|
||||
|
||||
connect(
|
||||
this, &AssetPickerDialog::SizeChangedSignal, m_ui->m_assetBrowserTableViewWidget,
|
||||
&AssetBrowserTableView::UpdateSizeSlot);
|
||||
|
||||
m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main");
|
||||
m_tableModel->UpdateTableModelMaps();
|
||||
}
|
||||
@@ -206,6 +210,12 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void AssetPickerDialog::resizeEvent(QResizeEvent* resizeEvent)
|
||||
{
|
||||
emit SizeChangedSignal(m_ui->verticalLayout_4->geometry().width());
|
||||
QDialog::resizeEvent(resizeEvent);
|
||||
}
|
||||
|
||||
void AssetPickerDialog::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
// Until search widget is revised, Return key should not close the dialog,
|
||||
|
||||
+4
@@ -46,6 +46,9 @@ namespace AzToolsFramework
|
||||
explicit AssetPickerDialog(AssetSelectionModel& selection, QWidget* parent = nullptr);
|
||||
virtual ~AssetPickerDialog();
|
||||
|
||||
Q_SIGNALS:
|
||||
void SizeChangedSignal(int newWidth);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// QDialog
|
||||
@@ -53,6 +56,7 @@ namespace AzToolsFramework
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
void keyPressEvent(QKeyEvent* e) override;
|
||||
void resizeEvent(QResizeEvent* resizeEvent) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void DoubleClickedSlot(const QModelIndex& index);
|
||||
|
||||
+3
-3
@@ -117,6 +117,9 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="AzToolsFramework::AssetBrowser::AssetBrowserTableView" name="m_assetBrowserTableViewWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AzToolsFramework::AssetBrowser::AssetBrowserTreeView" name="m_assetBrowserTreeViewWidget">
|
||||
<property name="sizePolicy">
|
||||
@@ -142,9 +145,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AzToolsFramework::AssetBrowser::AssetBrowserTableView" name="m_assetBrowserTableViewWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
|
||||
+18
-3
@@ -20,13 +20,17 @@ AZ_PUSH_DISABLE_WARNING(
|
||||
#include <QCoreApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QTimer>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
const float MinHeaderResizeProportion = .25f;
|
||||
const float MaxHeaderResizeProportion = .75f;
|
||||
const float DefaultHeaderResizeProportion = .5f;
|
||||
|
||||
AssetBrowserTableView::AssetBrowserTableView(QWidget* parent)
|
||||
: AzQtComponents::TableView(parent)
|
||||
, m_delegate(new SearchEntryDelegate(this))
|
||||
@@ -65,8 +69,10 @@ namespace AzToolsFramework
|
||||
AzQtComponents::TableView::setModel(model);
|
||||
connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot);
|
||||
|
||||
header()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
|
||||
header()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
|
||||
header()->setStretchLastSection(true);
|
||||
header()->setSectionResizeMode(0, QHeaderView::ResizeMode::Interactive);
|
||||
header()->setSectionResizeMode(1, QHeaderView::ResizeMode::Interactive);
|
||||
UpdateSizeSlot(parentWidget()->width());
|
||||
header()->setSortIndicatorShown(false);
|
||||
header()->setSectionsClickable(false);
|
||||
}
|
||||
@@ -148,8 +154,17 @@ namespace AzToolsFramework
|
||||
|
||||
void AssetBrowserTableView::OnAssetBrowserComponentReady()
|
||||
{
|
||||
UpdateSizeSlot(parentWidget()->width());
|
||||
}
|
||||
|
||||
void AssetBrowserTableView::UpdateSizeSlot(int newWidth)
|
||||
{
|
||||
setColumnWidth(0, aznumeric_cast<int>(newWidth * DefaultHeaderResizeProportion));
|
||||
header()->setMinimumSectionSize(aznumeric_cast<int>(newWidth * MinHeaderResizeProportion));
|
||||
header()->setMaximumSectionSize(aznumeric_cast<int>(newWidth * MaxHeaderResizeProportion));
|
||||
}
|
||||
|
||||
|
||||
void AssetBrowserTableView::OnContextMenu([[maybe_unused]] const QPoint& point)
|
||||
{
|
||||
const auto& selectedAssets = GetSelectedAssets();
|
||||
|
||||
+3
-1
@@ -59,12 +59,14 @@ namespace AzToolsFramework
|
||||
void ClearStringFilter();
|
||||
void ClearTypeFilter();
|
||||
|
||||
public Q_SLOTS:
|
||||
void UpdateSizeSlot(int newWidth);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
|
||||
void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
|
||||
void layoutChangedSlot(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(),
|
||||
QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QPointer<AssetBrowserTableModel> m_tableModel;
|
||||
|
||||
Reference in New Issue
Block a user