summaryrefslogtreecommitdiff
authorsandman <sandman>2002-07-06 19:16:43 (UTC)
committer sandman <sandman>2002-07-06 19:16:43 (UTC)
commit2fa52f80f59249c3f838fa6fdbc2a890e4d96334 (patch) (unidiff)
tree676cd870c02fad226755f0d6ddb95ed6147bfa4a
parent3a422983abc7342c9229dccac825d0608fca10f3 (diff)
downloadopie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.zip
opie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.tar.gz
opie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.tar.bz2
Use only two (instead of three) button controls on scrollbars due to space
constraints) -- will be configureable somtime ...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index acf0a42..67e53e9 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1499,77 +1499,77 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1499 int extent = horiz ? sb->height() : sb->width(); 1499 int extent = horiz ? sb->height() : sb->width();
1500 1500
1501 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar 1501 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
1502 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. 1502 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
1503 bool brokenApp; 1503 bool brokenApp;
1504 if(extent == 16) 1504 if(extent == 16)
1505 brokenApp = true; 1505 brokenApp = true;
1506 else 1506 else
1507 brokenApp = false; 1507 brokenApp = false;
1508 1508
1509 if (horiz) { 1509 if (horiz) {
1510 subY = addY = ( extent - buttonDim ) / 2; 1510 subY = addY = ( extent - buttonDim ) / 2;
1511 subX = 0; 1511 subX = 0;
1512 addX = len - buttonDim; 1512 addX = len - buttonDim;
1513 if(sbBuffer.size() != sb->size()) 1513 if(sbBuffer.size() != sb->size())
1514 sbBuffer.resize(sb->size()); 1514 sbBuffer.resize(sb->size());
1515 } 1515 }
1516 else { 1516 else {
1517 subX = addX = ( extent - buttonDim ) / 2; 1517 subX = addX = ( extent - buttonDim ) / 2;
1518 subY = 0; 1518 subY = 0;
1519 addY = len - buttonDim; 1519 addY = len - buttonDim;
1520 if(sbBuffer.size() != sb->size()) 1520 if(sbBuffer.size() != sb->size())
1521 sbBuffer.resize(sb->size()); 1521 sbBuffer.resize(sb->size());
1522 } 1522 }
1523 subB.setRect( subX,subY,buttonDim,buttonDim ); 1523 subB.setRect( subX,subY,0,0); // buttonDim,buttonDim );
1524 addB.setRect( addX,addY,buttonDim,buttonDim ); 1524 addB.setRect( addX,addY,buttonDim,buttonDim );
1525 if(horiz) 1525 if(horiz)
1526 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); 1526 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
1527 else 1527 else
1528 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); 1528 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
1529 1529
1530 int sliderEnd = sliderStart + sliderLength; 1530 int sliderEnd = sliderStart + sliderLength;
1531 int sliderW = extent; 1531 int sliderW = extent;
1532 1532
1533 if (horiz) { 1533 if (horiz) {
1534 subPageR.setRect( subB.right() + 1, 0, 1534 subPageR.setRect( subB.right() + 1, 0,
1535 sliderStart - subB.right() - 1 , sliderW ); 1535 sliderStart - subB.right() - 1 , sliderW );
1536 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); 1536 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
1537 sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); 1537 sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
1538 } 1538 }
1539 else { 1539 else {
1540 subPageR.setRect( 0, subB.bottom() + 1, sliderW, 1540 subPageR.setRect( 0, subB.bottom() + 1, sliderW,
1541 sliderStart - subB.bottom() - 1 ); 1541 sliderStart - subB.bottom() - 1 );
1542 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); 1542 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
1543 sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); 1543 sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
1544 } 1544 }
1545 1545
1546 bool maxed = sb->maxValue() == sb->minValue(); 1546 bool maxed = sb->maxValue() == sb->minValue();
1547 1547
1548 QPainter painter; 1548 QPainter painter;
1549 if(!horiz){ 1549 if(!horiz){
1550 painter.begin(&sbBuffer); 1550 painter.begin(&sbBuffer);
1551 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1); 1551 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1);
1552 if(sliderR.height() >= 8){ 1552 if(sliderR.height() >= 8){
1553 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, 1553 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
1554 13, 8); 1554 13, 8);
1555 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); 1555 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
1556 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, 1556 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
1557 bgR.height()-16, *getPixmap(VSBSliderMidBg)); 1557 bgR.height()-16, *getPixmap(VSBSliderMidBg));
1558 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, 1558 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
1559 0, 0, 13, 8); 1559 0, 0, 13, 8);
1560 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); 1560 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
1561 } 1561 }
1562 else{ 1562 else{
1563 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), 1563 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
1564 *getPixmap(VSBSliderMidBg)); 1564 *getPixmap(VSBSliderMidBg));
1565 painter.setPen(g.background().dark(210)); 1565 painter.setPen(g.background().dark(210));
1566 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); 1566 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
1567 painter.setPen(g.mid()); 1567 painter.setPen(g.mid());
1568 painter.drawPoint(bgR.x()+1, bgR.y()); 1568 painter.drawPoint(bgR.x()+1, bgR.y());
1569 painter.drawPoint(bgR.x()+13, bgR.y()); 1569 painter.drawPoint(bgR.x()+13, bgR.y());
1570 painter.drawPoint(bgR.x()+1, bgR.bottom()-1); 1570 painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
1571 painter.drawPoint(bgR.x()+13, bgR.bottom()-1); 1571 painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
1572 } 1572 }
1573 if(controls & Slider){ 1573 if(controls & Slider){
1574 if(sliderR.height() >= 16){ 1574 if(sliderR.height() >= 16){
1575 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1575 painter.drawPixmap(sliderR.x()+1, sliderR.y(),
@@ -1593,49 +1593,49 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1593 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); 1593 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1594 } 1594 }
1595 else{ 1595 else{
1596 painter.setPen(g.button().dark(210)); 1596 painter.setPen(g.button().dark(210));
1597 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), 1597 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
1598 13, sliderR.height()); 1598 13, sliderR.height());
1599 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, 1599 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
1600 11, sliderR.height()-2, 1600 11, sliderR.height()-2,
1601 isHover ? *getPixmap(VSBSliderMidHover) : 1601 isHover ? *getPixmap(VSBSliderMidHover) :
1602 *getPixmap(VSBSliderMid), 1, 0); 1602 *getPixmap(VSBSliderMid), 1, 0);
1603 } 1603 }
1604 } 1604 }
1605 painter.setPen(g.mid()); 1605 painter.setPen(g.mid());
1606 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); 1606 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
1607 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); 1607 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
1608 if(brokenApp && (controls & Slider)){ 1608 if(brokenApp && (controls & Slider)){
1609 painter.setPen(g.background()); 1609 painter.setPen(g.background());
1610 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, 1610 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
1611 bgR.bottom()); 1611 bgR.bottom());
1612 } 1612 }
1613 painter.end(); 1613 painter.end();
1614 } 1614 }
1615 else{ 1615 else{
1616 painter.begin(&sbBuffer); 1616 painter.begin(&sbBuffer);
1617 QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height()); 1617 QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height());
1618 if(sliderR.width() >= 8){ 1618 if(sliderR.width() >= 8){
1619 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, 1619 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
1620 8, 13); 1620 8, 13);
1621 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); 1621 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
1622 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, 1622 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
1623 13, *getPixmap(HSBSliderMidBg)); 1623 13, *getPixmap(HSBSliderMidBg));
1624 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, 1624 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
1625 0, 0, 8, 13); 1625 0, 0, 8, 13);
1626 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); 1626 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
1627 } 1627 }
1628 else{ 1628 else{
1629 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, 1629 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
1630 *getPixmap(HSBSliderMidBg)); 1630 *getPixmap(HSBSliderMidBg));
1631 painter.setPen(g.background().dark(210)); 1631 painter.setPen(g.background().dark(210));
1632 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); 1632 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
1633 painter.setPen(g.mid()); 1633 painter.setPen(g.mid());
1634 painter.drawPoint(bgR.x(), bgR.y()+1); 1634 painter.drawPoint(bgR.x(), bgR.y()+1);
1635 painter.drawPoint(bgR.x(), bgR.bottom()-1); 1635 painter.drawPoint(bgR.x(), bgR.bottom()-1);
1636 painter.drawPoint(bgR.right()-1, bgR.y()+1); 1636 painter.drawPoint(bgR.right()-1, bgR.y()+1);
1637 painter.drawPoint(bgR.right()-1, bgR.bottom()-1); 1637 painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
1638 } 1638 }
1639 if(controls & Slider){ 1639 if(controls & Slider){
1640 if(sliderR.width() >= 16){ 1640 if(sliderR.width() >= 16){
1641 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1641 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
@@ -1664,52 +1664,52 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1664 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1664 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1665 sliderR.width()-2, 11, isHover ? 1665 sliderR.width()-2, 11, isHover ?
1666 *getPixmap(HSBSliderMidHover) : 1666 *getPixmap(HSBSliderMidHover) :
1667 *getPixmap(HSBSliderMid), 0, 1); 1667 *getPixmap(HSBSliderMid), 0, 1);
1668 } 1668 }
1669 } 1669 }
1670 painter.setPen(g.mid()); 1670 painter.setPen(g.mid());
1671 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); 1671 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
1672 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); 1672 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
1673 if(brokenApp && (controls & Slider)){ 1673 if(brokenApp && (controls & Slider)){
1674 painter.setPen(g.background()); 1674 painter.setPen(g.background());
1675 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), 1675 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
1676 bgR.bottom()-1); 1676 bgR.bottom()-1);
1677 } 1677 }
1678 painter.end(); 1678 painter.end();
1679 } 1679 }
1680 1680
1681 if ( controls & AddLine ) { 1681 if ( controls & AddLine ) {
1682 drawSBButton(p, addB, g, activeControl == AddLine); 1682 drawSBButton(p, addB, g, activeControl == AddLine);
1683 drawArrow( p, horiz ? RightArrow : DownArrow, 1683 drawArrow( p, horiz ? RightArrow : DownArrow,
1684 false, addB.x()+4, addB.y()+4, 1684 false, addB.x()+4, addB.y()+4,
1685 addB.width()-8, addB.height()-8, g, !maxed); 1685 addB.width()-8, addB.height()-8, g, !maxed);
1686 } 1686 }
1687 if ( controls & SubLine ) { 1687 if ( controls & SubLine ) {
1688 drawSBButton(p, subB, g, activeControl == SubLine); 1688 // drawSBButton(p, subB, g, activeControl == SubLine);
1689 drawArrow( p, horiz ? LeftArrow : UpArrow, 1689 // drawArrow( p, horiz ? LeftArrow : UpArrow,
1690 false, subB.x()+4, subB.y()+4, 1690 // false, subB.x()+4, subB.y()+4,
1691 subB.width()-8, subB.height()-8, g, !maxed); 1691 // subB.width()-8, subB.height()-8, g, !maxed);
1692 drawSBButton(p, subHC, g, activeControl == SubLine); 1692 drawSBButton(p, subHC, g, activeControl == SubLine);
1693 drawArrow( p, horiz ? LeftArrow : UpArrow, 1693 drawArrow( p, horiz ? LeftArrow : UpArrow,
1694 false, subHC.x()+4, subHC.y()+4, 1694 false, subHC.x()+4, subHC.y()+4,
1695 subHC.width()-8, subHC.height()-8, g, !maxed); 1695 subHC.width()-8, subHC.height()-8, g, !maxed);
1696 } 1696 }
1697 1697
1698 if(controls & AddPage){ 1698 if(controls & AddPage){
1699 if(addPageR.width()){ 1699 if(addPageR.width()){
1700 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, 1700 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
1701 addPageR.x(), addPageR.y(), addPageR.width(), 1701 addPageR.x(), addPageR.y(), addPageR.width(),
1702 addPageR.height()); 1702 addPageR.height());
1703 } 1703 }
1704 } 1704 }
1705 if(controls & SubPage){ 1705 if(controls & SubPage){
1706 if(subPageR.height()){ 1706 if(subPageR.height()){
1707 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, 1707 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
1708 subPageR.x(), subPageR.y(), subPageR.width(), 1708 subPageR.x(), subPageR.y(), subPageR.width(),
1709 subPageR.height()); 1709 subPageR.height());
1710 } 1710 }
1711 } 1711 }
1712 if ( controls & Slider ) { 1712 if ( controls & Slider ) {
1713 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, 1713 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
1714 sliderR.x(), sliderR.y(), sliderR.width(), 1714 sliderR.x(), sliderR.y(), sliderR.width(),
1715 sliderR.height()); 1715 sliderR.height());
@@ -1768,50 +1768,50 @@ void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
1768 p->drawLine(x, y+4, x2, y+4); 1768 p->drawLine(x, y+4, x2, y+4);
1769 p->drawLine(x, y+7, x2, y+7); 1769 p->drawLine(x, y+7, x2, y+7);
1770 } 1770 }
1771 } 1771 }
1772 1772
1773} 1773}
1774 1774
1775 1775
1776void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, 1776void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
1777 int &sliderMax, int &sliderLength, 1777 int &sliderMax, int &sliderLength,
1778 int &buttonDim) 1778 int &buttonDim)
1779{ 1779{
1780 1780
1781 int maxLength; 1781 int maxLength;
1782 int b = 0; 1782 int b = 0;
1783 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1783 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1784 int length = horiz ? sb->width() : sb->height(); 1784 int length = horiz ? sb->width() : sb->height();
1785 int extent = horiz ? sb->height() : sb->width(); 1785 int extent = horiz ? sb->height() : sb->width();
1786 1786
1787 if ( length > ( extent - b*2 - 1 )*2 + b*2 ) 1787 if ( length > ( extent - b*2 - 1 )*2 + b*2 )
1788 buttonDim = extent - b*2; 1788 buttonDim = extent - b*2;
1789 else 1789 else
1790 buttonDim = ( length - b*2 )/2 - 1; 1790 buttonDim = ( length - b*2 )/2 - 1;
1791 1791
1792 sliderMin = b + buttonDim; 1792 sliderMin = b + 0; // buttonDim;
1793 maxLength = length - b*2 - buttonDim*3; 1793 maxLength = length - b*2 - buttonDim*2; // 3;
1794 1794
1795 if ( sb->maxValue() == sb->minValue() ) { 1795 if ( sb->maxValue() == sb->minValue() ) {
1796 sliderLength = maxLength; 1796 sliderLength = maxLength;
1797 } else { 1797 } else {
1798 sliderLength = (sb->pageStep()*maxLength)/ 1798 sliderLength = (sb->pageStep()*maxLength)/
1799 (sb->maxValue()-sb->minValue()+sb->pageStep()); 1799 (sb->maxValue()-sb->minValue()+sb->pageStep());
1800 uint range = sb->maxValue()-sb->minValue(); 1800 uint range = sb->maxValue()-sb->minValue();
1801 if ( sliderLength < 9 || range > INT_MAX/2 ) 1801 if ( sliderLength < 9 || range > INT_MAX/2 )
1802 sliderLength = 9; 1802 sliderLength = 9;
1803 if ( sliderLength > maxLength ) 1803 if ( sliderLength > maxLength )
1804 sliderLength = maxLength; 1804 sliderLength = maxLength;
1805 } 1805 }
1806 sliderMax = sliderMin + maxLength - sliderLength; 1806 sliderMax = sliderMin + maxLength - sliderLength;
1807 1807
1808} 1808}
1809 1809
1810QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, 1810QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
1811 int sliderStart, 1811 int sliderStart,
1812 const QPoint &p) 1812 const QPoint &p)
1813{ 1813{
1814 if ( !sb->rect().contains( p ) ) 1814 if ( !sb->rect().contains( p ) )
1815 return NoScroll; 1815 return NoScroll;
1816 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 1816 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
1817 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1817 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );