Commit 4b0b24eb authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

update example app; add dtkWidgetsStackBar

parent aed6eb54
...@@ -228,7 +228,7 @@ bool dummyEventFilter::eventFilter(QObject *object, QEvent *event) ...@@ -228,7 +228,7 @@ bool dummyEventFilter::eventFilter(QObject *object, QEvent *event)
qDebug() << "Ate key mouse event for" << object; qDebug() << "Ate key mouse event for" << object;
return true; return true;
} else { } else {
return QObject::eventFilter(object, event); return QObject::eventFilter(object, event);
...@@ -303,11 +303,11 @@ dummy::dummy(void) : QMainWindow(0) ...@@ -303,11 +303,11 @@ dummy::dummy(void) : QMainWindow(0)
QString placeholder = "SubSub"; QString placeholder = "SubSub";
dtkWidgetsMenu *m = this->menu_22->addMenu(fa::home, QString("%1Level3").arg(placeholder)); dtkWidgetsMenu *m = this->menu_22->addMenu(fa::home, QString("%1Level3").arg(placeholder));
for(int i = 0; i < 10; i++) { for(int i = 0; i < 10; i++) {
placeholder += "Sub"; placeholder += "Sub";
m->addItem(fa::home, QString("%1Level1").arg(placeholder)); m->addItem(fa::home, QString("%1Level1").arg(placeholder));
dtkWidgetsMenu *menu = m->addMenu(fa::home, QString("%1Level2").arg(placeholder)); dtkWidgetsMenu *menu = m->addMenu(fa::home, QString("%1Level2").arg(placeholder));
m->addItem(fa::home, QString("%1Level3").arg(placeholder)); m->addItem(fa::home, QString("%1Level3").arg(placeholder));
...@@ -316,13 +316,14 @@ dummy::dummy(void) : QMainWindow(0) ...@@ -316,13 +316,14 @@ dummy::dummy(void) : QMainWindow(0)
m = menu; m = menu;
} }
this->menubar = new dtkWidgetsMenuBar(this);
this->menubar->addMenu(this->menu_1); this->menubar->addMenu(this->menu_1);
this->menubar->addMenu(this->menu_2); this->menubar->addMenu(this->menu_2);
this->menubar->addMenu(this->menu_3); this->menubar->addMenu(this->menu_3);
for(int i = 0; i < 15; i++) { for(int i = 0; i < 15; i++) {
dtkWidgetsMenu *menu = this->menubar->addMenu(fa::circlethin, QString("Dummy %1").arg(i)); dtkWidgetsMenu *menu = this->menubar->addMenu(fa::circlethin, QString("Dummy %1").arg(i));
for(int j = 0; j < 5; j++) for(int j = 0; j < 5; j++)
...@@ -333,7 +334,7 @@ dummy::dummy(void) : QMainWindow(0) ...@@ -333,7 +334,7 @@ dummy::dummy(void) : QMainWindow(0)
for(int j = 0; j < 5; j++) for(int j = 0; j < 5; j++)
menu->addItem(fa::circleo, QString("DummyItem %1").arg(j + 5)); menu->addItem(fa::circleo, QString("DummyItem %1").arg(j + 5));
} }
this->menubar->build(); this->menubar->build();
this->setStyleSheet(m_style); this->setStyleSheet(m_style);
......
...@@ -19,13 +19,17 @@ project(dtkWidgetsWorkspace) ...@@ -19,13 +19,17 @@ project(dtkWidgetsWorkspace)
## ################################################################# ## #################################################################
set(${PROJECT_NAME}_SOURCES main.cpp) set(${PROJECT_NAME}_SOURCES main.cpp)
set(${PROJECT_NAME}_SOURCES_QRC main.qrc)
## ################################################################# ## #################################################################
## Build rules ## Build rules
## ################################################################# ## #################################################################
add_executable(${PROJECT_NAME} qt5_add_resources(${PROJECT_NAME}_SOURCES_RCC ${${PROJECT_NAME}_SOURCES_QRC})
${${PROJECT_NAME}_SOURCES})
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_SOURCES_RCC})
target_link_libraries(${PROJECT_NAME} Qt5::Core) target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets) target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
......
...@@ -16,6 +16,200 @@ ...@@ -16,6 +16,200 @@
#include <dtkWidgets> #include <dtkWidgets>
#include <dtkFonts> #include <dtkFonts>
// ///////////////////////////////////////////////////////////////////
// TODO: Use dtkThemeEngine instead
// ///////////////////////////////////////////////////////////////////
static const QString bg_color = "#88999999";
static const QString fg_color = "#88dddddd";
static const QString bd_color = "#88555555";
static const QString hl_color = "#88999999";
static const QString bl_color = "#88000000";
static const QString altbg_color = "#88111111";
static const QString m_style = QString(""
"QScrollArea"
"{"
"background: transparent;"
"}"
""
"QScrollArea > QWidget > QWidget"
"{"
" background: transparent;"
"}"
""
"QScrollArea > QWidget > QScrollBar"
"{"
" background: palette(base);"
"}"
""
"dtkWidgetsOverlayPaneItemHeader"
"{"
" background: %1;"
" color: %2;"
"}"
""
"dtkWidgetsOverlayPaneItemFooter QLabel"
"{"
" color: %2;"
"}"
"QScrollBar:horizontal {"
" background: transparent;"
" height: 6px;"
" margin: 0px 0px 0px 0px;"
"}"
""
"QScrollBar::handle:horizontal {"
" background: %1;"
" border: 1px solid %3;"
" border-radius: 2px;"
" min-height: 20px;"
"}"
""
"QScrollBar::add-line:horizontal {"
" height: 0px;"
"}"
""
"QScrollBar::sub-line:horizontal {"
" height: 0px;"
"}"
""
"QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal {"
" width: 0px;"
" height: 0px;"
" background: none;"
"}"
""
"QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {"
" background: none;"
"}"
""
"QScrollBar:vertical {"
" background: transparent;"
" width: 6px;"
" margin: 0px 0px 0px 0px;"
"}"
""
"QScrollBar::handle:vertical {"
" background: %1;"
" border: 1px solid %3;"
" border-radius: 2px;"
" min-height: 20px;"
"}"
""
"QScrollBar::add-line:vertical {"
" height: 0px;"
"}"
""
"QScrollBar::sub-line:vertical {"
" height: 0px;"
"}"
""
"QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {"
" width: 0px;"
" height: 0px;"
" background: none;"
"}"
""
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
" background: none;"
"}"
""
"dtkWidgetsMenuNavigationFacade"
"{"
" padding-left: 5px;"
" padding-right: 5px;"
" background: #11000000;"
" border-bottom: 1px solid #88222222;"
"}"
""
"dtkWidgetsMenuInnerFacade"
"{"
" margin-left: 5px;"
" margin-right: 5px;"
" background: %1;"
" border-radius: 5px;"
"}"
""
"dtkWidgetsMenuInnerFacade[state=\"first\"]"
"{"
" border-bottom-left-radius: 0;"
" border-bottom-right-radius: 0;"
"}"
""
"dtkWidgetsMenuInnerFacade[state=\"inner\"]"
"{"
" border-top-left-radius: 0;"
" border-top-right-radius: 0;"
" border-bottom-left-radius: 0;"
" border-bottom-right-radius: 0;"
"}"
""
"dtkWidgetsMenuInnerFacade[state=\"last\"]"
"{"
" border-top-left-radius: 0;"
" border-top-right-radius: 0;"
"}"
""
"dtkWidgetsMenuItemFacade"
"{"
" background: %1;"
" border-radius: 5px;"
" margin-left: 5px;"
" margin-right: 5px;"
"}"
""
"dtkWidgetsMenuItemFacade[state=\"prout\"]"
"{"
" background: %1;"
"}"
""
"dtkWidgetsMenuItemFacade[state=\"first\"]"
"{"
" border-bottom-left-radius: 0;"
" border-bottom-right-radius: 0;"
"}"
""
"dtkWidgetsMenuItemFacade[state=\"inner\"]"
"{"
" border-top-left-radius: 0;"
" border-top-right-radius: 0;"
" border-bottom-left-radius: 0;"
" border-bottom-right-radius: 0;"
"}"
""
"dtkWidgetsMenuItemFacade[state=\"last\"]"
"{"
" border-top-left-radius: 0;"
" border-top-right-radius: 0;"
"}"
""
"dtkWidgetsMenuBar"
"{"
" background: %6;"
" border-right: 1px solid %5;"
"}"
""
"dtkWidgetsMenuBarButtonCollapse"
"{"
" border-top: 1px solid %5;"
"}"
""
"dtkWidgetsMenuBarButton:hover"
"{"
" background: %4;"
" border-radius: 5px;"
"}"
""
"dtkWidgetsMenuBarButton[state=\"current\"]"
"{"
" background: %4;"
" border-radius: 5px;"
"}"
"").arg(bg_color).arg(fg_color).arg(bd_color).arg(hl_color).arg(bl_color).arg(altbg_color);
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
// dummy workspace // dummy workspace
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
...@@ -27,15 +221,29 @@ class dummyWorkspaceA: public dtkWidgetsWorkspace ...@@ -27,15 +221,29 @@ class dummyWorkspaceA: public dtkWidgetsWorkspace
public: public:
dummyWorkspaceA(QWidget *parent = nullptr) { dummyWorkspaceA(QWidget *parent = nullptr) {
QLabel *label = new QLabel("my dummy workspace");
this->menubar = new dtkWidgetsMenuBar(this);
dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
dtkWidgetsMenu *menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
dtkWidgetsMenu *menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
menubar->addMenu(menu_1);
menubar->addMenu(menu_2);
menubar->addMenu(menu_3);
menubar->build();
QLabel *label = new QLabel("my dummy workspace with menu");
QHBoxLayout *layout = new QHBoxLayout(this); QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(30, 30, 30, 30);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(label); layout->addWidget(label);
}; };
~dummyWorkspaceA(void) {}; ~dummyWorkspaceA(void) {};
public:
void resizeEvent(QResizeEvent *event);
public: public:
void enter(void) override {} void enter(void) override {}
void leave(void) override {} void leave(void) override {}
...@@ -43,8 +251,17 @@ public: ...@@ -43,8 +251,17 @@ public:
public slots: public slots:
void apply(void) override {}; void apply(void) override {};
private:
dtkWidgetsMenuBar *menubar;
}; };
void dummyWorkspaceA::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
this->menubar->setFixedHeight(event->size().height());
}
static dtkWidgetsWorkspace *dummyWorkspaceCreatorA(void) { static dtkWidgetsWorkspace *dummyWorkspaceCreatorA(void) {
return new dummyWorkspaceA; return new dummyWorkspaceA;
} }
...@@ -60,6 +277,7 @@ public: ...@@ -60,6 +277,7 @@ public:
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(label); layout->addWidget(label);
this->setStyleSheet(m_style);
}; };
~dummyWorkspaceB(void) {}; ~dummyWorkspaceB(void) {};
...@@ -77,6 +295,35 @@ static dtkWidgetsWorkspace *dummyWorkspaceCreatorB(void) { ...@@ -77,6 +295,35 @@ static dtkWidgetsWorkspace *dummyWorkspaceCreatorB(void) {
return new dummyWorkspaceB; return new dummyWorkspaceB;
} }
class dummyWorkspaceC: public dtkWidgetsWorkspace
{
Q_OBJECT
public:
dummyWorkspaceC(QWidget *parent = nullptr) {
QLabel *label = new QLabel;
label->setPixmap(QPixmap(":/logo.jpg"));
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(label);
};
~dummyWorkspaceC(void) {};
public:
void enter(void) override {}
void leave(void) override {}
public slots:
void apply(void) override {};
};
static dtkWidgetsWorkspace *dummyWorkspaceCreatorC(void) {
return new dummyWorkspaceC;
}
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
// //
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
...@@ -91,6 +338,16 @@ public: ...@@ -91,6 +338,16 @@ public:
public: public:
QSize sizeHint(void) const { return QSize(640, 480); } QSize sizeHint(void) const { return QSize(640, 480); }
private:
dtkWidgetsMenuBar *menubar;
dtkWidgetsMenu *menu_1;
dtkWidgetsMenu *menu_2;
dtkWidgetsMenu *menu_3;
public:
void resizeEvent(QResizeEvent *event);
public: public:
QStackedWidget *stack; QStackedWidget *stack;
}; };
...@@ -99,15 +356,39 @@ dummyWindow::dummyWindow(QWidget *parent) : QFrame(parent) ...@@ -99,15 +356,39 @@ dummyWindow::dummyWindow(QWidget *parent) : QFrame(parent)
{ {
this->stack = new QStackedWidget(this); this->stack = new QStackedWidget(this);
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceA")); // this->menubar = new dtkWidgetsMenuBar(this);
// this->menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
// this->menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
// this->menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
// this->menubar->addMenu(this->menu_1);
// this->menubar->addMenu(this->menu_2);
// this->menubar->addMenu(this->menu_3);
// this->menubar->build();
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceB")); this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceB"));
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceC"));
QVBoxLayout *l = new QVBoxLayout(this); dtkWidgetsStackBar *stack_bar = new dtkWidgetsStackBar(this);
stack_bar->setStack(this->stack);
QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0); l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0); l->setSpacing(0);
l->addWidget(stack_bar);
l->addWidget(this->stack); l->addWidget(this->stack);
this->setStyleSheet(m_style);
} }
void dummyWindow::resizeEvent(QResizeEvent *event)
{
QFrame::resizeEvent(event);
// this->menubar->setFixedHeight(event->size().height());
}
class dummyWindowBar : public QFrame class dummyWindowBar : public QFrame
{ {
Q_OBJECT Q_OBJECT
...@@ -132,12 +413,15 @@ dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent) ...@@ -132,12 +413,15 @@ dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent)
bar->addWorkspaceInMenu("My Dummy Workspace A", fa::sitemap, "dummyWorkspaceA" ); bar->addWorkspaceInMenu("My Dummy Workspace A", fa::sitemap, "dummyWorkspaceA" );
bar->addWorkspaceInMenu("My Dummy Workspace B", fa::image, "dummyWorkspaceB" ); bar->addWorkspaceInMenu("My Dummy Workspace B", fa::image, "dummyWorkspaceB" );
bar->addWorkspaceInMenu("dtk", fa::image, "dummyWorkspaceC" );
QVBoxLayout *l = new QVBoxLayout(this); QVBoxLayout *l = new QVBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0); l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0); l->setSpacing(0);
l->addWidget(stack); l->addWidget(stack);
l->addWidget(bar); l->addWidget(bar);
this->setStyleSheet(m_style);
} }
...@@ -153,6 +437,7 @@ int main(int argc, char **argv) ...@@ -153,6 +437,7 @@ int main(int argc, char **argv)
dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceA", dummyWorkspaceCreatorA); dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceA", dummyWorkspaceCreatorA);
dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceB", dummyWorkspaceCreatorB); dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceB", dummyWorkspaceCreatorB);
dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceC", dummyWorkspaceCreatorC);
dummyWindow *window = new dummyWindow; dummyWindow *window = new dummyWindow;
window->show(); window->show();
......
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file>logo.jpg</file>
</qresource>
</RCC>
...@@ -81,6 +81,8 @@ set(${PROJECT_NAME}_HEADERS ...@@ -81,6 +81,8 @@ set(${PROJECT_NAME}_HEADERS
dtkWidgetsParameterStringListComboBox.h dtkWidgetsParameterStringListComboBox.h
dtkWidgetsSettings dtkWidgetsSettings
dtkWidgetsSettings.h dtkWidgetsSettings.h
dtkWidgetsStackBar
dtkWidgetsStackBar.h
dtkWidgetsWidget dtkWidgetsWidget
dtkWidgetsWidget.h dtkWidgetsWidget.h
dtkWidgetsWorkspace dtkWidgetsWorkspace
...@@ -120,6 +122,7 @@ set(${PROJECT_NAME}_SOURCES ...@@ -120,6 +122,7 @@ set(${PROJECT_NAME}_SOURCES
dtkWidgetsParameterMenuBarGenerator.cpp dtkWidgetsParameterMenuBarGenerator.cpp
dtkWidgetsParameterStringListComboBox.cpp dtkWidgetsParameterStringListComboBox.cpp
dtkWidgetsSettings.cpp dtkWidgetsSettings.cpp
dtkWidgetsStackBar.cpp
dtkWidgetsWidget.cpp dtkWidgetsWidget.cpp
dtkWidgetsWorkspace.cpp dtkWidgetsWorkspace.cpp
dtkWidgetsWorkspaceBar.cpp) dtkWidgetsWorkspaceBar.cpp)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "dtkWidgetsParameterMenuBarGenerator.h" #include "dtkWidgetsParameterMenuBarGenerator.h"
#include "dtkWidgetsParameterStringListComboBox.h" #include "dtkWidgetsParameterStringListComboBox.h"
#include "dtkWidgetsSettings.h" #include "dtkWidgetsSettings.h"
#include "dtkWidgetsStackBar.h"
#include "dtkWidgetsWidget.h" #include "dtkWidgetsWidget.h"
#include "dtkWidgetsWorkspace.h" #include "dtkWidgetsWorkspace.h"
#include "dtkWidgetsWorkspaceBar.h" #include "dtkWidgetsWorkspaceBar.h"
#include "dtkWidgetsStackBar.h"
#include "dtkWidgetsStackBar.h"
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsStackBarItem : public QFrame
{
Q_OBJECT
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
public:
dtkWidgetsStackBarItem(int index, QWidget *parent = nullptr);
~dtkWidgetsStackBarItem(void);
signals:
void clicked(int);
signals:
void activeChanged(void);
public:
bool active(void) {
return this->on;
}
void setActive(bool active) {
this->on = active;
emit activeChanged();
}
public:
void setSource(QWidget *);
protected:
void mousePressEvent(QMouseEvent *);
private:
QWidget *source = nullptr;
private:
QLabel *name;
QLabel *overview;
private:
int index = -1;
private:
bool on = false;
};
dtkWidgetsStackBarItem::dtkWidgetsStackBarItem(int index, QWidget *parent) : QFrame(parent)
{
this->index = index;
this->name = new QLabel(this);
this->name->setAlignment(Qt::AlignCenter);
this->overview = new QLabel(this);
this->overview->setObjectName("overview");
this->overview->setAlignment(Qt::AlignCenter);