Blame view

build1/epsilon-master/escher/src/ellipsis_view.cpp 1.39 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
  #include <escher/ellipsis_view.h>
  #include <kandinsky/color.h>
  
  const uint8_t ellipsisMask[EllipsisView::k_ellipsisHeight][EllipsisView::k_ellipsisWidth] = {
    {0xFF, 0xDA, 0xBB, 0xD1, 0xFF, 0xFF, 0xFF, 0xDA, 0xBB, 0xD1, 0xFF, 0xFF, 0xFF, 0xDA, 0xBB, 0xD1, 0xFF},
    {0xFF, 0xBA, 0x8C, 0xA1, 0xFF, 0xFF, 0xFF, 0xBA, 0x8C, 0xA1, 0xFF, 0xFF, 0xFF, 0xBA, 0x8C, 0xA1, 0xFF},
    {0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF},
  };
  
  KDColor s_ellipsisWorkingBuffer[EllipsisView::k_ellipsisWidth*EllipsisView::k_ellipsisHeight];
  
  void EllipsisView::drawRect(KDContext * ctx, KDRect rect) const {
    /* Draw the ellipsis vertically and horizontally centered in the view.
     * The heightCenter is the coordinate of the vertical middle of the view. That
     * way, (heightCenter-switchHalfHeight) indicates the top the ellipsis. */
    KDCoordinate widthCenter = bounds().width()/2;
    KDCoordinate ellipsisHalfWidth = k_ellipsisWidth/2;
    KDCoordinate heightCenter =  bounds().height()/2;
    KDCoordinate ellipsisHalfHeight = k_ellipsisHeight/2;
    KDRect frame(widthCenter - ellipsisHalfWidth, heightCenter - ellipsisHalfHeight, k_ellipsisWidth, k_ellipsisHeight);
    ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)ellipsisMask, s_ellipsisWorkingBuffer);
  }
  
  KDSize EllipsisView::minimalSizeForOptimalDisplay() const {
    return KDSize(k_ellipsisWidth, k_ellipsisHeight);
  }