コード例 #1
0
ファイル: led_test_controller.cpp プロジェクト: Tilka/epsilon
void LEDTestController::ContentView::layoutSubviews() {
  KDSize ledSize = m_ledView.minimalSizeForOptimalDisplay();
  m_ledView.setFrame(KDRect((Ion::Display::Width-ledSize.width()-k_indicatorSize-k_indicatorMargin)/2, k_arrowLength+2*k_arrowMargin, ledSize.width(), ledSize.height()));
  m_ledColorIndicatorView.setFrame(KDRect((Ion::Display::Width-k_indicatorSize)/2+k_indicatorMargin/2+ledSize.width()/2, k_arrowLength+2*k_arrowMargin, k_indicatorSize, k_indicatorSize));
  m_ledColorOutlineView.setFrame(KDRect((Ion::Display::Width-k_indicatorSize)/2+k_indicatorMargin/2+ledSize.width()/2-1, k_arrowLength+2*k_arrowMargin-1, k_indicatorSize+2, k_indicatorSize+2));
  m_arrowView.setFrame(KDRect(0, k_arrowMargin, bounds().width(), k_arrowLength));
}
コード例 #2
0
ファイル: text_field.cpp プロジェクト: toholio/epsilon
KDSize TextField::ContentView::minimalSizeForOptimalDisplay() const {
  KDSize charSize = KDText::charSize(m_fontSize);
  if (m_isEditing) {
    return KDSize(charSize.width()*strlen(text())+m_cursorView.minimalSizeForOptimalDisplay().width(), charSize.height());
  }
  return KDSize(charSize.width()*strlen(text()), charSize.height());
}
コード例 #3
0
ファイル: text_area.cpp プロジェクト: toholio/epsilon
void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
  // TODO: We're clearing areas we'll draw text over. It's not needed.
  clearRect(ctx, rect);

  KDSize charSize = KDText::charSize(m_fontSize);

  // We want to draw even partially visible characters. So we need to round
  // down for the top left corner and up for the bottom right one.
  Text::Position topLeft(
    rect.x()/charSize.width(),
    rect.y()/charSize.height()
  );
  Text::Position bottomRight(
    rect.right()/charSize.width() + 1,
    rect.bottom()/charSize.height() + 1
  );

  int y = 0;

  for (Text::Line line : m_text) {
    if (y >= topLeft.line() && y <= bottomRight.line() && topLeft.column() < (int)line.length()) {
      drawLine(ctx, y, line.text(), line.length(), topLeft.column(), bottomRight.column());
    }
    y++;
  }
}
コード例 #4
0
ファイル: text_area.cpp プロジェクト: toholio/epsilon
KDRect TextArea::ContentView::characterFrameAtIndex(size_t index) const {
  KDSize charSize = KDText::charSize(m_fontSize);
  Text::Position p = m_text.positionAtIndex(index);
  return KDRect(
    p.column() * charSize.width(),
    p.line() * charSize.height(),
    charSize.width(),
    charSize.height()
  );
}
コード例 #5
0
ファイル: text_area.cpp プロジェクト: toholio/epsilon
KDSize TextArea::ContentView::minimalSizeForOptimalDisplay() const {
  KDSize charSize = KDText::charSize(m_fontSize);
  Text::Position span = m_text.span();
  return KDSize(
    /* We take into account the space required to draw a cursor at the end of
     * line by adding charSize.width() to the width. */
    charSize.width() * (span.column()+1),
    charSize.height() * span.line()
  );
}
コード例 #6
0
ファイル: text_area.cpp プロジェクト: toholio/epsilon
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, size_t length, KDColor textColor, KDColor backgroundColor) const {
  KDSize charSize = KDText::charSize(m_fontSize);
  ctx->drawString(
    text,
    KDPoint(column*charSize.width(), line*charSize.height()),
    m_fontSize,
    textColor,
    backgroundColor,
    length
  );
}
コード例 #7
0
ファイル: bracket_pair_layout.cpp プロジェクト: Tilka/epsilon
void BracketPairLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
  const KDCoordinate k_widthMargin = widthMargin();
  const KDCoordinate k_externWidthMargin = externWidthMargin();
  KDSize operandSize = operandLayout()->size();
  KDCoordinate verticalBarHeight = operandLayout()->size().height() + 2*k_verticalMargin;
  ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+verticalExternMargin(), k_lineThickness, verticalBarHeight), expressionColor);
  ctx->fillRect(KDRect(p.x()+k_externWidthMargin+operandSize.width()+2*k_widthMargin+k_lineThickness, p.y()+verticalExternMargin(), k_lineThickness, verticalBarHeight), expressionColor);
  if (renderTopBar()) {
    ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+verticalExternMargin(), k_bracketWidth, k_lineThickness), expressionColor);
    ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y() + verticalExternMargin(), k_bracketWidth, k_lineThickness), expressionColor);
  }
  if (renderBottomBar()) {
    ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+verticalExternMargin()+verticalBarHeight-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
    ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y()+verticalExternMargin()+verticalBarHeight-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
  }
}
コード例 #8
0
ファイル: horizontal_layout.cpp プロジェクト: Tilka/epsilon
KDSize HorizontalLayout::computeSize() {
  KDCoordinate totalWidth = 0;
  int i = 0;
  KDCoordinate max_under_baseline = 0;
  KDCoordinate max_above_baseline = 0;
  while (ExpressionLayout * c = editableChild(i++)) {
    KDSize childSize = c->size();
    totalWidth += childSize.width();
    if (childSize.height() - c->baseline() > max_under_baseline) {
      max_under_baseline = childSize.height() - c->baseline() ;
    }
    if (c->baseline() > max_above_baseline) {
      max_above_baseline = c->baseline();
    }
  }
  return KDSize(totalWidth, max_under_baseline + max_above_baseline);
}
コード例 #9
0
ファイル: editor_view.cpp プロジェクト: Tilka/epsilon
void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const {
  KDColor textColor = KDColor::RGB24(0x919EA4);
  KDColor backgroundColor = KDColor::RGB24(0xE4E6E7);

  ctx->fillRect(rect, backgroundColor);

  KDSize charSize = KDText::charSize(m_fontSize);

  KDCoordinate firstLine = m_offset / charSize.height();
  KDCoordinate firstLinePixelOffset = m_offset - firstLine * charSize.height();

  char lineNumber[4];
  int numberOfLines = bounds().height() / charSize.height() + 1;
  for (int i=0; i<numberOfLines; i++) {
    Poincare::Integer line(i + firstLine + 1);
    line.writeTextInBuffer(lineNumber, 4);
    KDCoordinate leftPadding = (2 - strlen(lineNumber)) * charSize.width();
    ctx->drawString(
      lineNumber,
      KDPoint(k_margin + leftPadding, i*charSize.height() - firstLinePixelOffset),
      m_fontSize,
      textColor,
      backgroundColor
    );
  }
}
コード例 #10
0
ファイル: history_view_cell.cpp プロジェクト: Tilka/epsilon
void HistoryViewCell::layoutSubviews() {
  KDCoordinate width = bounds().width();
  KDCoordinate height = bounds().height();
  KDSize inputSize = m_inputView.minimalSizeForOptimalDisplay();
  if (inputSize.width() + Metric::HistoryHorizontalMargin > width) {
    m_inputView.setFrame(KDRect(Metric::HistoryHorizontalMargin, k_digitVerticalMargin, width - Metric::HistoryHorizontalMargin, inputSize.height()));
  } else {
    m_inputView.setFrame(KDRect(Metric::HistoryHorizontalMargin, k_digitVerticalMargin, inputSize.width(), inputSize.height()));
  }
  KDSize outputSize = m_scrollableOutputView.minimalSizeForOptimalDisplay();
  if (outputSize.width() + Metric::HistoryHorizontalMargin > width) {
    m_scrollableOutputView.setFrame(KDRect(Metric::HistoryHorizontalMargin, inputSize.height() + 2*k_digitVerticalMargin, width - Metric::HistoryHorizontalMargin, height - inputSize.height() - 3*k_digitVerticalMargin));
  } else {
    m_scrollableOutputView.setFrame(KDRect(width - outputSize.width() - Metric::HistoryHorizontalMargin, inputSize.height() + 2*k_digitVerticalMargin, outputSize.width(), height - inputSize.height() - 3*k_digitVerticalMargin));
  }
}
コード例 #11
0
ファイル: expression_view.cpp プロジェクト: Tilka/epsilon
KDPoint ExpressionView::drawingOrigin() const {
  KDSize expressionSize = m_expressionLayout->size();
  return KDPoint(m_horizontalAlignment*(m_frame.width() - expressionSize.width()), max(0, (m_frame.height() - expressionSize.height())/2));
}
コード例 #12
0
ファイル: bracket_pair_layout.cpp プロジェクト: Tilka/epsilon
KDSize BracketPairLayout::computeSize() {
  const KDCoordinate k_widthMargin = widthMargin();
  const KDCoordinate k_externWidthMargin = externWidthMargin();
  KDSize operandSize = operandLayout()->size();
  return KDSize(operandSize.width() + 2*k_externWidthMargin + 2*k_widthMargin + 2*k_lineThickness, operandSize.height() + 2 * k_verticalMargin + 2*verticalExternMargin());
}
コード例 #13
0
ファイル: text_field.cpp プロジェクト: toholio/epsilon
KDRect TextField::ContentView::characterFrameAtIndex(size_t index) const {
  KDSize charSize = KDText::charSize(m_fontSize);
  KDSize textSize = KDText::stringSize(text(), m_fontSize);
  KDCoordinate cursorWidth = m_cursorView.minimalSizeForOptimalDisplay().width();
  return KDRect(m_horizontalAlignment*(m_frame.width() - textSize.width()-cursorWidth)+ index * charSize.width(), m_verticalAlignment*(m_frame.height() - charSize.height()), charSize);
}