Blame view

build4/epsilon-master/escher/src/chevron_view.cpp 1.49 KB
6663b6c9   adorian   projet complet av...
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
  #include <escher/chevron_view.h>
  #include <escher/palette.h>
  
  const uint8_t chevronMask[ChevronView::k_chevronHeight][ChevronView::k_chevronWidth] = {
    {0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
    {0x00, 0x00, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
    {0x00, 0x00, 0x00, 0x0C, 0xE1, 0xFF, 0xFF, 0xFF},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xFF, 0xFF},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x45},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x45},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xFF, 0xFF},
    {0x00, 0x00, 0x00, 0x0C, 0xE1, 0xFF, 0xFF, 0xFF},
    {0x00, 0x00, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
    {0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
  };
  
  KDColor s_workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight];
  
  void ChevronView::drawRect(KDContext * ctx, KDRect rect) const {
    /* Draw the chevron aligned on the right of the view and vertically centered.
     * The heightCenter is the coordinate of the vertical middle of the view. That
     * way, (heightCenter-switchHalfHeight) indicates the top the chevron. */
    KDCoordinate width = bounds().width();
    KDCoordinate heightCenter = bounds().height()/2;
    KDCoordinate chevronHalfHeight = k_chevronHeight/2;
    KDRect frame(width - k_chevronWidth, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight);
    ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)chevronMask, s_workingBuffer);
  }
  
  KDSize ChevronView::minimalSizeForOptimalDisplay() const {
    return KDSize(k_chevronWidth, k_chevronHeight);
  }