Commit df1d89b8 authored by Christoffer Ackelman's avatar Christoffer Ackelman Committed by Esteban Blanc

QT: Made dashed lines shorter.

parent beed7f1f
......@@ -111,42 +111,22 @@ static unique_ptr<QPainter> get_painter(
QPaintDevice* window, FlowDrawQt* draw_ctx, int painter_type, int size)
{
unique_ptr<QPainter> painter(new QPainter(window));
switch (painter_type) {
case flow_eDrawType_LineDashed:
case flow_eDrawType_LineDashedRed: {
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setBackground(QBrush(draw_ctx->background));
QPen pen = QPen(painter->brush(), size + 1, Qt::DashLine);
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setBackground(QBrush(draw_ctx->background));
painter->setPen(QPen(painter->brush(), size + 1));
if (painter_type == flow_eDrawType_LineDashed || painter_type == flow_eDrawType_LineDashedRed) {
QPen pen = painter->pen();
QVector<double> dashes;
dashes << 7 + size << 7 + size;
dashes << (7 + size) / pen.widthF() << (7 + size) / pen.widthF();
pen.setDashPattern(dashes);
painter->setPen(pen);
return painter;
}
case flow_eDrawType_TextHelvetica:
case flow_eDrawType_TextHelveticaBold:
case flow_eDrawType_TextHelveticaErase:
case flow_eDrawType_TextHelveticaEraseBold: {
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setBackground(QBrush(draw_ctx->background));
if (painter_type >= flow_eDrawType_TextHelvetica &&
painter_type <= flow_eDrawType_TextHelveticaEraseBold) {
int sizes[9] = {8, 10, 12, 14, 14, 18, 18, 18, 24};
painter->setFont(get_font(painter_type, sizes[size], "Helvetica"));
return painter;
}
case flow_eDrawType_Green:
case flow_eDrawType_Yellow:
case flow_eDrawType_DarkGray:
case flow_eDrawType_Line:
case flow_eDrawType_LineErase:
case flow_eDrawType_LineRed:
case flow_eDrawType_LineGray:
default:
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setBackground(QBrush(draw_ctx->background));
painter->setPen(QPen(painter->brush(), size + 1));
return painter;
}
return painter;
}
static QColor flow_allocate_color(FlowDrawQt* draw_ctx, const char* named_color)
......
......@@ -159,41 +159,23 @@ static unique_ptr<QPainter> get_painter(
QPaintDevice* window, GlowDrawQt* draw_ctx, int painter_type, int size)
{
unique_ptr<QPainter> painter = new QPainter(window);
switch (painter_type) {
case glow_eDrawType_LineDashed:
case glow_eDrawType_LineDashedRed: {
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type, size)));
painter->setBackground(QBrush(draw_ctx->background));
QPen pen = QPen(painter->brush(), size + 1, Qt::DashLine);
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type, size)));
painter->setBackground(QBrush(draw_ctx->background));
painter->setPen(QPen(painter->brush(), size + 1));
if (painter_type == glow_eDrawType_LineDashed || painter_type == glow_eDrawType_LineDashedRed) {
QPen pen = painter->pen();
QVector<double> dashes;
dashes << 7 + size << 7 + size;
dashes << (7 + size) / pen.widthF() << (7 + size) / pen.widthF();
pen.setDashPattern(dashes);
painter->setPen(pen);
return painter;
}
case glow_eDrawType_TextHelvetica:
case glow_eDrawType_TextHelveticaBold:
case glow_eDrawType_TextHelveticaErase:
case glow_eDrawType_TextHelveticaEraseBold: {
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type, size)));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setBackground(QBrush(draw_ctx->background));
if (painter_type >= glow_eDrawType_TextHelvetica &&
painter_type <= glow_eDrawType_TextHelveticaEraseBold) {
if (size > 0) {
painter->setFont(get_font(glow_eFont_Helvetica, painter_type, size));
}
return painter;
}
case glow_eDrawType_Line:
case glow_eDrawType_LineErase:
case glow_eDrawType_LineRed:
case glow_eDrawType_LineGray:
default: {
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type, size)));
painter->setBackground(QBrush(draw_ctx->background));
painter->setPen(QPen(painter->brush(), size + 1));
return painter;
}
}
return painter;
}
static QColor glow_allocate_named_color(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment