class Syskit::GUI::RuntimeState::ActionListDelegate

Constants

INTERLINE
OUTER_MARGIN

Public Instance Methods

paint(painter, option, index) click to toggle source
# File lib/syskit/gui/runtime_state.rb, line 82
def paint(painter, option, index)
    painter.save

    if (option.state & Qt::Style::State_Selected) != 0
        painter.fill_rect(option.rect, option.palette.highlight)
        painter.brush = option.palette.highlighted_text
    end

    main = index.data.toString
    doc = index.data(Qt::UserRole).to_string || ''
    text_bounds = Qt::Rect.new

    fm = option.font_metrics
    painter.draw_text(
        Qt::Rect.new(option.rect.x + OUTER_MARGIN, option.rect.y + OUTER_MARGIN, option.rect.width - 2 * OUTER_MARGIN, fm.height),
        Qt::AlignLeft, main, text_bounds)

    font = painter.font
    font.italic = true
    painter.font = font
    painter.draw_text(
        Qt::Rect.new(option.rect.x + OUTER_MARGIN, text_bounds.bottom + INTERLINE, option.rect.width - 2 * OUTER_MARGIN, fm.height),
        Qt::AlignLeft, doc, text_bounds)
ensure
    painter.restore
end
sizeHint(option, index) click to toggle source
# File lib/syskit/gui/runtime_state.rb, line 73
def sizeHint(option, index)
    fm = option.font_metrics
    main = index.data.toString
    doc = index.data(Qt::UserRole).to_string || ''
    Qt::Size.new(
        [fm.width(main), fm.width(doc)].max + 2 * OUTER_MARGIN,
        fm.height * 2 + OUTER_MARGIN * 2 + INTERLINE)
end