asset browser: push test asset browser overlay

This commit is contained in:
sshumakov3
2020-11-16 17:54:07 +03:00
parent 4f0f17bc5a
commit c89a6e2c91
5 changed files with 216 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ void ModelViewer::initializeGL()
opengl::context::scoped_setter const _ (::gl, context());
gl.viewport(0.0f, 0.0f, width(), height());
gl.clearColor (0.5f, 0.5f, 0.5f, 1.0f);
emit resized();
}
void ModelViewer::paintGL()
@@ -57,6 +58,7 @@ void ModelViewer::resizeGL(int w, int h)
{
opengl::context::scoped_setter const _ (::gl, context());
gl.viewport(0.0f, 0.0f, w, h);
emit resized();
}
void ModelViewer::tick(float dt)

View File

@@ -35,6 +35,9 @@ namespace noggit
explicit ModelViewer(QWidget* parent = nullptr);
void setModel(std::string const& filename) override;
signals:
void resized();
private:
QTimer _update_every_event_loop;

View File

@@ -1,5 +1,6 @@
#include "AssetBrowser.hpp"
#include <ui_AssetBrowser.h>
#include <ui_AssetBrowserOverlay.h>
#include <noggit/MPQ.h>
#include <noggit/Log.h>
#include <noggit/ContextObject.hpp>
@@ -11,6 +12,7 @@
#include <QSettings>
#include <QPixmap>
#include <QIcon>
#include <QDialog>
using namespace noggit::Red::AssetBrowser::Ui;
@@ -18,7 +20,7 @@ AssetBrowserWidget::AssetBrowserWidget(QWidget *parent)
{
ui = new ::Ui::AssetBrowser;
ui->setupUi(this);
ui::setupFramelessWindow(ui->titlebar, this, minimumSize(), maximumSize(), false);
ui::setupFramelessWindow(ui->titlebar, this, minimumSize(), maximumSize(), true);
setWindowFlags(windowFlags() | Qt::Tool | Qt::WindowStaysOnTopHint);
_model = new QStandardItemModel(this);
@@ -27,6 +29,28 @@ AssetBrowserWidget::AssetBrowserWidget(QWidget *parent)
_sort_model->setFilterRole(Qt::UserRole);
_sort_model->setRecursiveFilteringEnabled(true);
// test
auto overlay = new QWidget(ui->viewport);
auto overlay_ui = ::Ui::AssetBrowserOverlay();
overlay_ui.setupUi(overlay);
overlay->setAttribute(Qt::WA_TranslucentBackground);
overlay->setMouseTracking(true);
overlay->setGeometry(0,0,ui->viewport->width(),ui->viewport->height());
connect(ui->viewport, &ModelViewer::resized
,[this, overlay]()
{
overlay->setGeometry(0,0,ui->viewport->width(),ui->viewport->height());
}
);
ui->viewport->installEventFilter(overlay);
overlay->show();
// drag'n'drop
ui->listfileTree->setDragEnabled(true);
ui->listfileTree->setDragDropMode(QAbstractItemView::DragOnly);
ui->listfileTree->setIconSize(QSize(90, 90));
_sort_model->setSourceModel(_model);

View File

@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AssetBrowserOverlay</class>
<widget class="QWidget" name="AssetBrowserOverlay">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>896</width>
<height>663</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>T</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDial" name="dial"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -27,6 +27,8 @@ QStandardItem* TreeManager::addItem(QString path)
child->setData(QVariant(path_remainder), Qt::UserRole);
child->setEditable(false);
child->setCheckable(false);
child->setDragEnabled(true);
child->setFlags(child->flags() | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
layered_items[path_remainder] = child;
}