ginebra2/ChromeLayout.h
changeset 6 1c3b8676e58c
child 16 3c88a81ff781
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 *
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #ifndef __GINEBRA_CHROMELAYOUT_H__
       
    23 #define __GINEBRA_CHROMELAYOUT_H__
       
    24 
       
    25 #include <QtGui>
       
    26 
       
    27 class ControllableViewBase;
       
    28 class QGraphicsSceneContextMenuEvent;
       
    29 
       
    30 namespace GVA {
       
    31 
       
    32   class ChromeSnippet;
       
    33   class SlidingWidget;
       
    34 
       
    35   enum ChromeAnchor
       
    36   {
       
    37     anchorNone,
       
    38     anchorCenter,
       
    39     anchorTop,
       
    40     anchorBottom,
       
    41     anchorLeft,
       
    42     anchorRight,
       
    43     anchorTopLeft,
       
    44     anchorTopRight,
       
    45     anchorBottomLeft,
       
    46     anchorBottomRight
       
    47   };
       
    48 
       
    49   enum Aspect
       
    50   {
       
    51     portrait,
       
    52     landscape
       
    53   };
       
    54  
       
    55 
       
    56   /*!
       
    57    * \brief This class is responsible for laying out the snippets and views that constitute the UI
       
    58    */
       
    59 
       
    60   class ChromeLayout : public QGraphicsWidget
       
    61   {
       
    62 
       
    63   Q_OBJECT
       
    64 
       
    65   public:
       
    66     ChromeLayout(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
       
    67     virtual ~ChromeLayout();
       
    68     void addView(ControllableViewBase * controllableView);
       
    69     void addSnippet(ChromeSnippet * snippet, ChromeSnippet * container);
       
    70     void anchorSnippet(ChromeSnippet * snippet); //TODO: should be private, but is needed from ChromeWidget::anchorSnippet which is caled from ChromeSnippet
       
    71     //NB: Should be deprecated (see comment in .cpp)
       
    72     void adjustAnchorOffset(ChromeSnippet * snippet, qreal delta);
       
    73     void anchorToView(ChromeSnippet* snippet, const QString & where = "top");
       
    74     void detachFromView(ChromeSnippet* snippet, const QString & where = "top");
       
    75     void anchorTogether(ChromeSnippet* first, ChromeSnippet *  second, qreal x = 0, qreal y = 0);
       
    76     void unAnchor(ChromeSnippet* first);
       
    77     QGraphicsScene * scene() { return m_scene; }
       
    78     void setScene(QGraphicsScene *scene);
       
    79     int bottomBarHeight() { return m_bottomBarHeight;}
       
    80     /// \brief Returns either "portrait" or "landscape".
       
    81     QString getDisplayMode() const;
       
    82     Q_PROPERTY(QString displayMode READ getDisplayMode)
       
    83 
       
    84   public slots:
       
    85     void snippetShown(ChromeSnippet * snippet);
       
    86     void snippetHiding(ChromeSnippet * snippet);
       
    87     qreal slideView(qreal delta);
       
    88     qreal shrinkView(qreal delta);
       
    89     int width(){ return (int)size().width(); }
       
    90   
       
    91   signals:
       
    92     void resizing(QSizeF newSize);
       
    93     void aspectChanged(int aspect);
       
    94 
       
    95   protected:
       
    96     virtual void resizeEvent(QGraphicsSceneResizeEvent *ev);
       
    97     virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
       
    98 
       
    99   private:
       
   100     void addAnchors();
       
   101     QGraphicsScene * m_scene;
       
   102     QGraphicsAnchorLayout *m_layout;
       
   103     QGraphicsAnchorLayout *m_viewLayout;
       
   104     SlidingWidget *m_viewPort;
       
   105     QGraphicsWidget *m_topBar;
       
   106     QGraphicsWidget *m_bottomBar;
       
   107     QGraphicsWidget *m_leftBar;
       
   108     QGraphicsWidget *m_rightBar;
       
   109     Aspect m_aspect;
       
   110     int m_bottomBarHeight;
       
   111   };
       
   112 
       
   113 } // end of namespace GVA
       
   114 
       
   115 #endif // __GINEBRA_CHROMEWIDGET_H__