… | |
… | |
1538 | |
1538 | |
1539 | delete $self->{texture}; |
1539 | delete $self->{texture}; |
1540 | $self->SUPER::update; |
1540 | $self->SUPER::update; |
1541 | } |
1541 | } |
1542 | |
1542 | |
|
|
1543 | sub realloc { |
|
|
1544 | my ($self) = @_; |
|
|
1545 | |
|
|
1546 | delete $self->{ox}; |
|
|
1547 | $self->SUPER::realloc; |
|
|
1548 | } |
|
|
1549 | |
1543 | sub set_text { |
1550 | sub set_text { |
1544 | my ($self, $text) = @_; |
1551 | my ($self, $text) = @_; |
1545 | |
1552 | |
1546 | return if $self->{text} eq "T$text"; |
1553 | return if $self->{text} eq "T$text"; |
1547 | $self->{text} = "T$text"; |
1554 | $self->{text} = "T$text"; |
1548 | |
1555 | |
1549 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1556 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1550 | $self->{layout}->set_text ($text); |
1557 | $self->{layout}->set_text ($text); |
|
|
1558 | delete $self->{req_h}; |
1551 | |
1559 | |
1552 | $self->realloc; |
1560 | $self->realloc; |
1553 | $self->update; |
1561 | $self->update; |
1554 | } |
1562 | } |
1555 | |
1563 | |
… | |
… | |
1561 | |
1569 | |
1562 | my $rgba = $markup =~ /span.*(?:foreground|background)/; |
1570 | my $rgba = $markup =~ /span.*(?:foreground|background)/; |
1563 | |
1571 | |
1564 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1572 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1565 | $self->{layout}->set_markup ($markup); |
1573 | $self->{layout}->set_markup ($markup); |
|
|
1574 | delete $self->{req_h}; |
1566 | |
1575 | |
1567 | $self->realloc; |
1576 | $self->realloc; |
1568 | $self->update; |
1577 | $self->update; |
1569 | } |
1578 | } |
1570 | |
1579 | |
1571 | sub size_request { |
1580 | sub size_request { |
1572 | my ($self) = @_; |
1581 | my ($self) = @_; |
1573 | |
1582 | |
|
|
1583 | if (exists $self->{req_h}) { |
|
|
1584 | @$self{qw(req_w req_h)} |
|
|
1585 | } else { |
1574 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1586 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1575 | $self->{layout}->set_width ($self->{max_w} || -1); |
1587 | $self->{layout}->set_width ($self->{max_w} || -1); |
1576 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1588 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1577 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1589 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1578 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1590 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1579 | |
1591 | |
1580 | my ($w, $h) = $self->{layout}->size; |
1592 | my ($w, $h) = $self->{layout}->size; |
1581 | |
1593 | |
1582 | if (exists $self->{template}) { |
1594 | if (exists $self->{template}) { |
1583 | $self->{template}->set_font ($self->{font}) if $self->{font}; |
1595 | $self->{template}->set_font ($self->{font}) if $self->{font}; |
1584 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1596 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1585 | |
1597 | |
1586 | my ($w2, $h2) = $self->{template}->size; |
1598 | my ($w2, $h2) = $self->{template}->size; |
1587 | |
1599 | |
1588 | $w = List::Util::max $w, $w2; |
1600 | $w = List::Util::max $w, $w2; |
1589 | $h = List::Util::max $h, $h2; |
1601 | $h = List::Util::max $h, $h2; |
1590 | } |
1602 | } |
1591 | |
1603 | |
1592 | ($w, $h) |
1604 | ($w, $h) |
|
|
1605 | } |
1593 | } |
1606 | } |
1594 | |
1607 | |
1595 | sub size_allocate { |
1608 | sub size_allocate { |
1596 | my ($self, $w, $h) = @_; |
1609 | my ($self, $w, $h) = @_; |
1597 | |
1610 | |
… | |
… | |
1682 | $self->{last_activity} = $::NOW; |
1695 | $self->{last_activity} = $::NOW; |
1683 | $self->{text} = $text; |
1696 | $self->{text} = $text; |
1684 | |
1697 | |
1685 | $text =~ s/./*/g if $self->{hidden}; |
1698 | $text =~ s/./*/g if $self->{hidden}; |
1686 | $self->{layout}->set_text ("$text "); |
1699 | $self->{layout}->set_text ("$text "); |
|
|
1700 | delete $self->{req_h}; |
1687 | |
1701 | |
1688 | $self->_emit (changed => $self->{text}); |
1702 | $self->_emit (changed => $self->{text}); |
|
|
1703 | |
|
|
1704 | $self->realloc; |
1689 | $self->update; |
1705 | $self->update; |
1690 | } |
1706 | } |
1691 | |
1707 | |
1692 | sub set_text { |
1708 | sub set_text { |
1693 | my ($self, $text) = @_; |
1709 | my ($self, $text) = @_; |
1694 | |
1710 | |
1695 | $self->{cursor} = length $text; |
1711 | $self->{cursor} = length $text; |
1696 | $self->_set_text ($text); |
1712 | $self->_set_text ($text); |
1697 | |
|
|
1698 | $self->realloc; |
|
|
1699 | } |
1713 | } |
1700 | |
1714 | |
1701 | sub get_text { |
1715 | sub get_text { |
1702 | $_[0]{text} |
1716 | $_[0]{text} |
1703 | } |
1717 | } |