aboutsummaryrefslogtreecommitdiff
path: root/dw/stackingcontextmgr.hh
blob: 28cdd2f9c9e304c12061f5c897d8b6d9488365c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __DW_STACKINGCONTEXTMGR_HH__
#define __DW_STACKINGCONTEXTMGR_HH__

#ifndef __INCLUDED_FROM_DW_CORE_HH__
#   error Do not include this file directly, use "core.hh" instead.
#endif

#include "../lout/container.hh"

#include <limits.h>

namespace dw {

namespace core {

/**
 * \brief See \ref dw-stacking-context.
 */
class StackingContextMgr
{
private:
   Widget *widget;
   lout::container::typed::Vector<Widget> *childSCWidgets;
   int minZIndex, maxZIndex;

   void draw (View *view, Rectangle *area,
              StackingIteratorStack *iteratorStack, Widget **interruptedWidget,
              int *zIndexOffset, int startZIndex, int endZIndex, int *index);
   Widget *getWidgetAtPoint (int x, int y, int startZIndex, int endZIndex);

public:
   StackingContextMgr (Widget *widget);
   ~StackingContextMgr ();

   inline static bool isEstablishingStackingContext (Widget *widget) {
      return widget->getStyle()->position != style::POSITION_STATIC &&
         widget->getStyle()->zIndex != style::Z_INDEX_AUTO;
   }

   inline static bool handledByStackingContextMgr  (Widget *widget) {
      // Each widget establishing a stacking context is child of another
      // stacking context, so drawn by StackingContextMgr::drawTop or
      // StackingContextMgr::drawBottom etc.
      return widget->getParent () != NULL
         && isEstablishingStackingContext (widget);
   }

   void addChildSCWidget (Widget *widget);

   void drawBottom (View *view, Rectangle *area,
                    StackingIteratorStack *iteratorStack,
                    Widget **interruptedWidget, int *zIndexOffset, int *index);
   void drawTop (View *view, Rectangle *area,
                 StackingIteratorStack *iteratorStack,
                 Widget **interruptedWidget, int *zIndexOffset, int *index);

   Widget *getTopWidgetAtPoint (int x, int y);
   Widget *getBottomWidgetAtPoint (int x, int y);
};

} // namespace core

} // namespace dw

#endif // __DW_STACKINGCONTEXTMGR_HH__