Changed: #1409 Adding zoom functionality to views, trying to fix icon size problem.
This commit is contained in:
parent
e56f07bfc5
commit
9481a6cdd5
6 changed files with 77 additions and 32 deletions
|
@ -139,7 +139,7 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
|
||||||
m_zoomSignalMapper->setMapping(m_ui->actionZoom100, 1);
|
m_zoomSignalMapper->setMapping(m_ui->actionZoom100, 1);
|
||||||
connect(m_ui->actionZoom200, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map()));
|
connect(m_ui->actionZoom200, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map()));
|
||||||
m_zoomSignalMapper->setMapping(m_ui->actionZoom200, 2);
|
m_zoomSignalMapper->setMapping(m_ui->actionZoom200, 2);
|
||||||
connect(m_zoomSignalMapper, SIGNAL(mapped(int)), m_model, SLOT(onZoomFactor(int)));
|
connect(m_zoomSignalMapper, SIGNAL(mapped(int)), this, SLOT(onZoomFactor(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEditorMainWindow::~TileEditorMainWindow()
|
TileEditorMainWindow::~TileEditorMainWindow()
|
||||||
|
@ -158,6 +158,53 @@ TileEditorMainWindow::~TileEditorMainWindow()
|
||||||
delete m_zoomSignalMapper;
|
delete m_zoomSignalMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileEditorMainWindow::onZoomFactor(int level)
|
||||||
|
{
|
||||||
|
int tile128Scaled=TileModel::TILE_128_BASE_SIZE;
|
||||||
|
int tile256Scaled=TileModel::TILE_256_BASE_SIZE;
|
||||||
|
int tileTransScaled=TileModel::TILE_TRANSITION_BASE_SIZE;
|
||||||
|
int tileDispScaled=TileModel::TILE_DISPLACE_BASE_SIZE;
|
||||||
|
switch(level)
|
||||||
|
{
|
||||||
|
// Zoom Level 50%
|
||||||
|
case 0:
|
||||||
|
nlinfo("zooming to 50%");
|
||||||
|
TileModel::CurrentZoomFactor = TileModel::TileZoom50;
|
||||||
|
tile128Scaled /= 2;
|
||||||
|
tile256Scaled /= 2;
|
||||||
|
tileTransScaled /= 2;
|
||||||
|
tileDispScaled /= 2;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
nlinfo("zooming to 100%");
|
||||||
|
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
nlinfo("zooming to 200%");
|
||||||
|
TileModel::CurrentZoomFactor = TileModel::TileZoom200;
|
||||||
|
tile128Scaled *= 2;
|
||||||
|
tile256Scaled *= 2;
|
||||||
|
tileTransScaled *= 2;
|
||||||
|
tileDispScaled *= 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nlwarning("Invalid Time Zoom Factor passed.");
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
nlinfo("resizing transition view. base size: %d factor %d to: %d", TileModel::TILE_TRANSITION_BASE_SIZE, level, tileTransScaled);
|
||||||
|
|
||||||
|
m_ui->listView128->setIconSize(QSize(tile128Scaled, tile128Scaled));
|
||||||
|
m_ui->listView128->setCurrentIndex(m_ui->listView128->model()->index(0, 0, m_ui->listView128->rootIndex()));
|
||||||
|
m_ui->listView256->setIconSize(QSize(tile256Scaled, tile256Scaled));
|
||||||
|
m_ui->listView256->setCurrentIndex(m_ui->listView256->model()->index(0, 0, m_ui->listView256->rootIndex()));
|
||||||
|
m_ui->listViewTransition->setIconSize(QSize(tileTransScaled, tileTransScaled));
|
||||||
|
m_ui->listViewTransition->setCurrentIndex(m_ui->listViewTransition->model()->index(0, 0, m_ui->listViewTransition->rootIndex()));
|
||||||
|
m_ui->listViewDisplacement->setIconSize(QSize(tileDispScaled, tileDispScaled));
|
||||||
|
m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex()));
|
||||||
|
m_ui->listViewTransition->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
void TileEditorMainWindow::onActionAddTile(bool triggered)
|
void TileEditorMainWindow::onActionAddTile(bool triggered)
|
||||||
{
|
{
|
||||||
onActionAddTile(m_ui->tileViewTabWidget->currentIndex());
|
onActionAddTile(m_ui->tileViewTabWidget->currentIndex());
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
explicit TileEditorMainWindow(QWidget *parent = 0);
|
explicit TileEditorMainWindow(QWidget *parent = 0);
|
||||||
~TileEditorMainWindow();
|
~TileEditorMainWindow();
|
||||||
|
|
||||||
QUndoStack *getUndoStack() { return m_undoStack; }
|
QUndoStack *getUndoStack() { return m_undoStack; }
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onActionAddTile(bool triggered);
|
void onActionAddTile(bool triggered);
|
||||||
|
@ -48,7 +48,8 @@ public Q_SLOTS:
|
||||||
void onActionReplaceImage(bool triggered);
|
void onActionReplaceImage(bool triggered);
|
||||||
void onActionDeleteImage(bool triggered);
|
void onActionDeleteImage(bool triggered);
|
||||||
void onTileSetAdd();
|
void onTileSetAdd();
|
||||||
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
||||||
|
void onZoomFactor(int level);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onActionAddTile(int tabId);
|
void onActionAddTile(int tabId);
|
||||||
|
|
|
@ -155,6 +155,9 @@
|
||||||
<height>64</height>
|
<height>64</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="movement">
|
||||||
|
<enum>QListView::Static</enum>
|
||||||
|
</property>
|
||||||
<property name="flow">
|
<property name="flow">
|
||||||
<enum>QListView::LeftToRight</enum>
|
<enum>QListView::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -226,6 +229,9 @@
|
||||||
<height>32</height>
|
<height>32</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="movement">
|
||||||
|
<enum>QListView::Static</enum>
|
||||||
|
</property>
|
||||||
<property name="flow">
|
<property name="flow">
|
||||||
<enum>QListView::LeftToRight</enum>
|
<enum>QListView::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -223,7 +223,7 @@ TileItemNode::TileItemNode(int tileId, TileModel::TTileChannel channel, QString
|
||||||
{
|
{
|
||||||
m_tileFilename[channel] = filename;
|
m_tileFilename[channel] = filename;
|
||||||
m_parentItem = parent;
|
m_parentItem = parent;
|
||||||
nlinfo("dispalying tile %d - %s", m_tileId, m_tileFilename[TileModel::TileDiffuse].toStdString().c_str());
|
//nlinfo("dispalying tile %d - %s", m_tileId, m_tileFilename[TileModel::TileDiffuse].toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TileItemNode::~TileItemNode()
|
TileItemNode::~TileItemNode()
|
||||||
|
@ -257,7 +257,12 @@ QVariant TileItemNode::data(int column, int role) const
|
||||||
if(!pixmap.load(tileFilename))
|
if(!pixmap.load(tileFilename))
|
||||||
nlinfo("failed to load %s", tileFilename.toStdString().c_str());
|
nlinfo("failed to load %s", tileFilename.toStdString().c_str());
|
||||||
|
|
||||||
//pixmap.scaled(tileSize*100, tileSize*100);
|
if(TileModel::CurrentZoomFactor == TileModel::TileZoom200)
|
||||||
|
tileSize *= 2;
|
||||||
|
else if(TileModel::CurrentZoomFactor == TileModel::TileZoom50)
|
||||||
|
tileSize /= 2;
|
||||||
|
|
||||||
|
pixmap.scaled(tileSize, tileSize);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Initialize the static members
|
||||||
|
TileModel::TTileZoomFactor TileModel::CurrentZoomFactor;
|
||||||
|
|
||||||
TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent)
|
TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
QVector<QVariant> rootData;
|
QVector<QVariant> rootData;
|
||||||
|
@ -29,7 +32,7 @@ TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractIte
|
||||||
|
|
||||||
rootItem = new Node(rootData);
|
rootItem = new Node(rootData);
|
||||||
|
|
||||||
m_tileZoomFactor = TileZoom100;
|
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
|
||||||
m_indexDisplay = true;
|
m_indexDisplay = true;
|
||||||
m_fileDisplay = true;
|
m_fileDisplay = true;
|
||||||
}
|
}
|
||||||
|
@ -224,27 +227,4 @@ void TileModel::selectFilenameDisplay(bool selected)
|
||||||
void TileModel::selectIndexDisplay(bool selected)
|
void TileModel::selectIndexDisplay(bool selected)
|
||||||
{
|
{
|
||||||
m_indexDisplay = selected;
|
m_indexDisplay = selected;
|
||||||
}
|
|
||||||
|
|
||||||
void TileModel::onZoomFactor(int level)
|
|
||||||
{
|
|
||||||
switch(level)
|
|
||||||
{
|
|
||||||
// Zoom Level 50%
|
|
||||||
case 0:
|
|
||||||
nlinfo("zooming to 50%");
|
|
||||||
m_tileZoomFactor = TileZoom50;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
nlinfo("zooming to 100%");
|
|
||||||
m_tileZoomFactor = TileZoom100;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
nlinfo("zooming to 200%");
|
|
||||||
m_tileZoomFactor = TileZoom200;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
nlwarning("Invalid Time Zoom Factor passed.");
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
}
|
|
@ -59,6 +59,11 @@ public:
|
||||||
TileZoom200 = 2
|
TileZoom200 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int TILE_DISPLACE_BASE_SIZE = 32;
|
||||||
|
static const int TILE_TRANSITION_BASE_SIZE = 64;
|
||||||
|
static const int TILE_128_BASE_SIZE = 128;
|
||||||
|
static const int TILE_256_BASE_SIZE = 256;
|
||||||
|
|
||||||
|
|
||||||
TileModel(const QStringList &headers, QObject *parent);
|
TileModel(const QStringList &headers, QObject *parent);
|
||||||
~TileModel();
|
~TileModel();
|
||||||
|
@ -80,17 +85,18 @@ public:
|
||||||
static const char *getTileTypeName(TNodeTileType type);
|
static const char *getTileTypeName(TNodeTileType type);
|
||||||
static uint32 getTileTypeSize(TileModel::TNodeTileType type);
|
static uint32 getTileTypeSize(TileModel::TNodeTileType type);
|
||||||
|
|
||||||
|
static TTileZoomFactor CurrentZoomFactor;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void selectFilenameDisplay(bool selected);
|
void selectFilenameDisplay(bool selected);
|
||||||
void selectIndexDisplay(bool selected);
|
void selectIndexDisplay(bool selected);
|
||||||
void onZoomFactor(int level);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node *getItem(const QModelIndex &index) const;
|
Node *getItem(const QModelIndex &index) const;
|
||||||
|
|
||||||
bool m_fileDisplay;
|
bool m_fileDisplay;
|
||||||
bool m_indexDisplay;
|
bool m_indexDisplay;
|
||||||
TTileZoomFactor m_tileZoomFactor;
|
//TTileZoomFactor m_tileZoomFactor;
|
||||||
|
|
||||||
//QList<TileItem*> m_tiles;
|
//QList<TileItem*> m_tiles;
|
||||||
//int m_activeEditChannel;
|
//int m_activeEditChannel;
|
||||||
|
|
Loading…
Reference in a new issue