tahoma2d/toonz/sources/toonzfarm/tfarmclient/thumbnailviewer.h

105 lines
2.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef T_THUMBNAILVIEWE_INCLUDED
#define T_THUMBNAILVIEWE_INCLUDED
#include "tw/scrollview.h"
2016-06-15 18:43:10 +12:00
// forward declaration
2016-03-19 06:57:51 +13:00
class Thumbnail;
class TTextField;
class TFilePath;
2016-06-15 18:43:10 +12:00
class ThumbnailViewer : public TScrollView {
vector<Thumbnail *> m_items;
int m_selectedItemIndex;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
const TDimension m_itemSize;
const TDimension m_itemSpace;
const TDimension m_margins;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
const TRect m_playButtonBox;
const TRect m_iconBox;
const TRect m_textBox;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TPoint m_oldPos;
bool m_dragDropArmed;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_flag;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_playing, m_loading;
bool m_timerActive;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
class NameField;
NameField *m_nameField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ThumbnailViewer(TWidget *parent, string name = "thumbnailViewer");
~ThumbnailViewer();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void addItem(Thumbnail *item);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! removes the item from the ThumbnailViewer. It doesn't destroy the item
void removeItem(Thumbnail *item);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TDimension getIconSize() const { return m_iconBox.getSize(); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getItemCount() const;
Thumbnail *getItem(int index) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! find the max number of thumbnails which fit the current widget width
int getColumnCount() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! find the bottom-left corner coordinate of the index-th thumbnail
//! (icon+controls)
TPoint getItemPos(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// ! find the region covered by the index-th thumbnail (icon+controls)
TRect getItemBounds(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// ! coordinate --> thumbnail index; returns -1 if not found
int findItem(const TPoint &pos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void configureNotify(const TDimension &d);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! draw the index-th thumbnail current frame
void drawFrame(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! draw the index-th thumbnail
void drawItem(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! draw the empty space around and between thumbnails
void drawBackground();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void repaint();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void leftButtonDown(const TMouseEvent &e);
void leftButtonDrag(const TMouseEvent &e);
void leftButtonUp(const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void leftButtonDoubleClick(const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onTimer(int);
void startPlaying();
void stopPlaying();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void select(int);
int getSelectedItemIndex() { return m_selectedItemIndex; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void clearItems();
void loadDirectory(const TFilePath &dirPath, const vector<string> &fileTypes);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void updateContentSize();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void middleButtonDown(const TMouseEvent &e) {}
void middleButtonDrag(const TMouseEvent &e) {}
void middleButtonUp(const TMouseEvent &e) {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void scrollPage(int y);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void onDoubleClick(int index) {}
virtual void onSelect(int index) {}
2016-03-19 06:57:51 +13:00
};
#endif