Added UI responsivness

This commit is contained in:
atlante45 2013-07-02 16:17:25 +02:00
parent 05a77bf373
commit 78aa3ac9f9
8 changed files with 194 additions and 177 deletions

View file

@ -1,166 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="152px" height="506px" viewBox="0 0 152 506" enable-background="new 0 0 152 506" xml:space="preserve">
<g>
<rect y="161" width="61" height="39"/>
</g>
<g>
<rect y="80" width="61" height="39"/>
</g>
<g>
<rect y="121" width="61" height="38"/>
</g>
width="124px" height="400px" viewBox="-0.5 0.5 124 400" enable-background="new -0.5 0.5 124 400" xml:space="preserve">
<g>
<g>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.944,187.889 19.944,188.889 19.031,188.481 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9973,1.9973" x1="17.208" y1="187.666" x2="10.825" y2="184.815"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9.913,184.408 9,184 9,183 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="8.5" y1="181" x2="8.5" y2="174"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9,173 9,172 9.927,172.376 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9625,1.9625" x1="11.745" y1="173.115" x2="18.109" y2="175.699"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.018,176.068 19.944,176.444 19.944,177.444 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="19.5" y1="180" x2="19.5" y2="187"/>
<rect x="-0.5" y="120.382" width="62" height="40"/>
</g>
<g>
<g>
<path fill="#999999" d="M13.77,149.864c0.296,0.296,0.665,0.102,0.665,0.102s0.527-0.615,1.101-0.328
c0.811,0.405,1.315-0.113,1.315-0.113l10.611-10.611l-1.419-1.419l-1.161-1.161l-10.61,10.61c0,0-0.575,0.449-0.169,1.261
c0.287,0.573-0.384,1.045-0.384,1.045S13.474,149.569,13.77,149.864"/>
</g>
<g>
<path fill="#CCCCCC" d="M25.913,135.042l2.173-2.173c0,0,1.898-1.905,3.256-0.547c0.68,0.68,1.083,1.627-0.546,3.257
c-1.549,1.548-2.173,2.172-2.173,2.172L25.913,135.042z"/>
</g>
<g>
<rect x="22.984" y="135.651" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -52.0828 253.0143)" fill="#CCCCCC" width="6.751" height="3.285"/>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M46.482,138.915h3.697v4.617c-1.004,0.344-2.107,0.516-3.311,0.516c-1.32,0-2.341-0.383-3.062-1.148
s-1.081-1.857-1.081-3.275c0-1.383,0.395-2.459,1.184-3.229s1.895-1.154,3.316-1.154c0.539,0,1.048,0.051,1.526,0.152
s0.896,0.23,1.251,0.387l-0.732,1.816c-0.617-0.305-1.295-0.457-2.033-0.457c-0.676,0-1.198,0.22-1.567,0.659
s-0.554,1.067-0.554,1.884c0,0.801,0.167,1.411,0.501,1.831s0.815,0.63,1.444,0.63c0.344,0,0.66-0.033,0.949-0.1v-1.342h-1.529
L46.482,138.915L46.482,138.915z"/>
</g>
</g>
<g>
<rect y="40" width="61" height="38"/>
<g>
<rect x="-0.5" y="80.5" width="62" height="40"/>
</g>
<g>
<path fill="#FFFFFF" d="M43.84,96.434h2.988c1.164,0,2.028,0.173,2.593,0.519s0.847,0.884,0.847,1.614
c0,0.48-0.123,0.891-0.369,1.23s-0.57,0.559-0.973,0.656v0.059c0.531,0.141,0.916,0.375,1.154,0.703s0.357,0.754,0.357,1.277
c0,0.777-0.292,1.39-0.876,1.837S48.182,105,47.174,105H43.84V96.434z M46.154,99.721h0.697c0.332,0,0.589-0.068,0.771-0.205
s0.272-0.34,0.272-0.609c0-0.48-0.363-0.721-1.09-0.721h-0.65C46.154,98.186,46.154,99.721,46.154,99.721z M46.154,101.414v1.799
h0.814c0.723,0,1.084-0.305,1.084-0.914c0-0.285-0.097-0.504-0.29-0.656s-0.474-0.229-0.841-0.229
C46.921,101.414,46.154,101.414,46.154,101.414z"/>
</g>
<g>
<path fill="#FFFFFF" d="M18,106.06c-3,1-3,3-7,3c2,1,8,4,9,0C20.47,107.181,18,106.06,18,106.06z"/>
<path fill="#CCCCCC" d="M19,105.06l2,2c0,0,3.952-4.712,7-9c3.048-4.287,7.32-10.785,3-7C28.399,93.338,22.048,100.772,19,105.06z
"/>
</g>
</g>
<g>
<g>
<rect x="-0.5" y="40.5" width="62" height="40"/>
</g>
<g>
<g>
<g>
<polygon fill="#A5A5A5" points="26,58.63 39,53.893 39,67.213 26,72.394 "/>
</g>
<g>
<g>
<path fill="#333333" d="M38,54.5v12.59l-12,5.032V58.757l12.204-4.468 M39,53.63l-13,4.873v14.162l13-5.33V53.63L39,53.63z"/>
</g>
</g>
</g>
<g>
<g>
<polygon fill="#BFBFBF" points="13,67.213 13,53.893 25,58.63 25,72.394 "/>
</g>
<g>
<path fill="#BFBFBF" d="M12.887,54.289L25,58.757v13.365L13,67.09V54.5 M13,53.63v13.705l13,5.33V58.503L13,53.63L13,53.63z"/>
</g>
</g>
<g>
<g>
<polygon fill="#FFFFFF" points="13.173,53.63 25.746,48.952 38.318,53.63 25.746,58.309 "/>
</g>
<g>
<path fill="#333333" d="M25.746,49.146l12.049,4.483l-12.049,4.483L13.697,53.63L25.746,49.146 M25.746,48.758L12.65,53.63
l13.096,4.873l13.096-4.873L25.746,48.758L25.746,48.758z"/>
</g>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M46.119,62.383V65.5h-2.314v-8.566h2.807c2.328,0,3.492,0.844,3.492,2.531c0,0.992-0.484,1.76-1.453,2.303
l2.495,3.732h-2.625l-1.816-3.117H46.119z M46.119,60.643h0.434c0.809,0,1.213-0.357,1.213-1.072c0-0.59-0.396-0.885-1.189-0.885
H46.12L46.119,60.643L46.119,60.643z"/>
</g>
<g>
<polygon fill="#333333" points="7,59.5 9,59.5 10,59.5 15,59.5 16,59.5 18,59.5 18,64.5 16,64.5 15,64.5 10,64.5 9,64.5 7,64.5
"/>
<g>
<g>
<rect x="8" y="60.5" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
</g>
<g>
<rect x="-0.5" y="0.5" width="62" height="40"/>
</g>
<g>
<g>
<g>
<polygon fill="#A5A5A5" points="26,57.13 39,52.393 39,65.713 26,70.894 "/>
<polygon fill="#A5A5A5" points="26,18.63 39,13.893 39,27.213 26,32.394 "/>
</g>
<g>
<g>
<path fill="#333333" d="M38,53v12.59l-12,5.032V57.257l12.204-4.468 M39,52.13l-13,4.873v14.162l13-5.33V52.13L39,52.13z"/>
<path fill="#333333" d="M38,14.5v12.59l-12,5.032V18.757l12.204-4.468 M39,13.63l-13,4.873v14.162l13-5.33V13.63L39,13.63z"/>
</g>
</g>
</g>
<g>
<g>
<polygon fill="#BFBFBF" points="13,65.713 13,52.393 25,57.13 25,70.894 "/>
<polygon fill="#BFBFBF" points="13,27.213 13,13.893 25,18.63 25,32.394 "/>
</g>
<g>
<path fill="#BFBFBF" d="M12.887,52.789L25,57.257v13.365L13,65.59V53 M13,52.13v13.705l13,5.33V57.003L13,52.13L13,52.13z"/>
<path fill="#BFBFBF" d="M12.887,14.289L25,18.757v13.365L13,27.09V14.5 M13,13.63v13.705l13,5.33V18.503L13,13.63L13,13.63z"/>
</g>
</g>
<g>
<g>
<polygon fill="#FFFFFF" points="13.173,52.13 25.746,47.452 38.318,52.13 25.746,56.809 "/>
<polygon fill="#FFFFFF" points="13.173,13.63 25.746,8.952 38.318,13.63 25.746,18.309 "/>
</g>
<g>
<path fill="#333333" d="M25.746,47.646l12.049,4.483l-12.049,4.483L13.697,52.13L25.746,47.646 M25.746,47.258L12.65,52.13
l13.096,4.873l13.096-4.873L25.746,47.258L25.746,47.258z"/>
<path fill="#333333" d="M25.746,9.146l12.049,4.483l-12.049,4.483L13.697,13.63L25.746,9.146 M25.746,8.758L12.65,13.63
l13.096,4.873l13.096-4.873L25.746,8.758L25.746,8.758z"/>
</g>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M48.41,16.934H51L48.193,25.5h-2.725l-2.795-8.566h2.602l1.166,4.342c0.242,0.965,0.375,1.637,0.398,2.016
c0.027-0.273,0.082-0.615,0.164-1.025s0.154-0.732,0.217-0.967L48.41,16.934z"/>
</g>
<g>
<polygon fill="#333333" points="7,19.5 10,19.5 10,16.5 15,16.5 15,19.5 18,19.5 18,24.5 15,24.5 15,27.5 10,27.5 10,24.5 7,24.5
"/>
<g>
<g>
<rect x="11" y="17.5" fill="#FFFFFF" width="3" height="9"/>
</g>
<g>
<rect x="8" y="20.5" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
<g>
<g>
<path fill="#999999" d="M13.77,148.933c0.296,0.296,0.665,0.102,0.665,0.102s0.527-0.615,1.101-0.328
c0.811,0.405,1.315-0.113,1.315-0.113l10.611-10.611l-1.419-1.419l-1.161-1.161l-10.61,10.61c0,0-0.575,0.449-0.169,1.261
c0.287,0.573-0.384,1.045-0.384,1.045S13.474,148.638,13.77,148.933"/>
<rect x="-0.5" y="160.5" width="62" height="40"/>
</g>
<g>
<path fill="#CCCCCC" d="M25.913,134.111l2.173-2.173c0,0,1.898-1.905,3.256-0.547c0.68,0.68,1.083,1.627-0.546,3.257
c-1.549,1.548-2.173,2.172-2.173,2.172L25.913,134.111z"/>
</g>
<g>
<rect x="22.989" y="134.726" transform="matrix(0.7071 0.7071 -0.7071 0.7071 104.1434 21.2946)" fill="#CCCCCC" width="6.751" height="3.285"/>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M46.119,60.883V64h-2.314v-8.566h2.807c2.328,0,3.492,0.844,3.492,2.531c0,0.992-0.484,1.76-1.453,2.303
L51.146,64h-2.625l-1.816-3.117H46.119z M46.119,59.143h0.434c0.809,0,1.213-0.357,1.213-1.072c0-0.59-0.396-0.885-1.189-0.885
h-0.457V59.143z"/>
</g>
<g>
<path fill="#FFFFFF" d="M43.84,95.434h2.988c1.164,0,2.028,0.173,2.593,0.519s0.847,0.884,0.847,1.614
c0,0.48-0.123,0.891-0.369,1.23s-0.57,0.559-0.973,0.656v0.059c0.531,0.141,0.916,0.375,1.154,0.703s0.357,0.754,0.357,1.277
c0,0.777-0.292,1.39-0.876,1.837S48.182,104,47.174,104H43.84V95.434z M46.154,98.721h0.697c0.332,0,0.589-0.068,0.771-0.205
s0.272-0.34,0.272-0.609c0-0.48-0.363-0.721-1.09-0.721h-0.65V98.721z M46.154,100.414v1.799h0.814
c0.723,0,1.084-0.305,1.084-0.914c0-0.285-0.097-0.504-0.29-0.656s-0.474-0.229-0.841-0.229H46.154z"/>
</g>
<g>
<path fill="#FFFFFF" d="M46.482,137.984h3.697v4.617c-1.004,0.344-2.107,0.516-3.311,0.516c-1.32,0-2.341-0.383-3.062-1.148
s-1.081-1.857-1.081-3.275c0-1.383,0.395-2.459,1.184-3.229s1.895-1.154,3.316-1.154c0.539,0,1.048,0.051,1.526,0.152
s0.896,0.23,1.251,0.387l-0.732,1.816c-0.617-0.305-1.295-0.457-2.033-0.457c-0.676,0-1.198,0.22-1.567,0.659
s-0.554,1.067-0.554,1.884c0,0.801,0.167,1.411,0.501,1.831s0.815,0.63,1.444,0.63c0.344,0,0.66-0.033,0.949-0.1v-1.342h-1.529
V137.984z"/>
</g>
<g>
<path fill="#FFFFFF" d="M50.379,179.705c0,1.441-0.354,2.537-1.061,3.287s-1.742,1.125-3.105,1.125
c-1.344,0-2.374-0.377-3.091-1.131s-1.075-1.852-1.075-3.293c0-1.426,0.356-2.515,1.069-3.267s1.749-1.128,3.108-1.128
c1.363,0,2.396,0.373,3.1,1.119S50.379,178.26,50.379,179.705z M44.484,179.705c0,1.656,0.576,2.484,1.729,2.484
c0.586,0,1.021-0.201,1.304-0.604s0.425-1.029,0.425-1.881c0-0.855-0.144-1.487-0.431-1.896s-0.716-0.612-1.286-0.612
C45.064,177.197,44.484,178.033,44.484,179.705z"/>
</g>
<g>
<path fill="#FFFFFF" d="M18,105.06c-3,1-3,3-7,3c2,1,8,4,9,0C20.47,106.181,18,105.06,18,105.06z"/>
<path fill="#CCCCCC" d="M19,104.06l2,2c0,0,3.952-4.712,7-9c3.048-4.287,7.32-10.785,3-7C28.399,92.338,22.048,99.772,19,104.06z"
/>
</g>
<g>
<polygon fill="#333333" points="7,58 9,58 10,58 15,58 16,58 18,58 18,63 16,63 15,63 10,63 9,63 7,63 "/>
<g>
<g>
<rect x="8" y="59" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
<g>
<rect width="61" height="38"/>
</g>
<g>
<g>
<g>
<polygon fill="#A5A5A5" points="26,17.13 39,12.393 39,25.713 26,30.894 "/>
</g>
<g>
<g>
<path fill="#333333" d="M38,13v12.59l-12,5.032V17.257l12.204-4.468 M39,12.13l-13,4.873v14.162l13-5.33V12.13L39,12.13z"/>
</g>
</g>
<path fill="#FFFFFF" d="M50.379,179.205c0,1.441-0.354,2.537-1.061,3.287s-1.742,1.125-3.105,1.125
c-1.344,0-2.374-0.377-3.091-1.131s-1.075-1.852-1.075-3.293c0-1.426,0.356-2.515,1.069-3.267s1.749-1.128,3.108-1.128
c1.363,0,2.396,0.373,3.1,1.119S50.379,177.76,50.379,179.205z M44.484,179.205c0,1.656,0.576,2.484,1.729,2.484
c0.586,0,1.021-0.201,1.304-0.604s0.425-1.029,0.425-1.881c0-0.855-0.144-1.487-0.431-1.896s-0.716-0.612-1.286-0.612
C45.064,176.697,44.484,177.533,44.484,179.205z"/>
</g>
<g>
<g>
<polygon fill="#BFBFBF" points="13,25.713 13,12.393 25,17.13 25,30.894 "/>
</g>
<g>
<path fill="#BFBFBF" d="M12.887,12.789L25,17.257v13.365L13,25.59V13 M13,12.13v13.705l13,5.33V17.003L13,12.13L13,12.13z"/>
</g>
</g>
<g>
<g>
<polygon fill="#FFFFFF" points="13.173,12.13 25.746,7.452 38.318,12.13 25.746,16.809 "/>
</g>
<g>
<path fill="#333333" d="M25.746,7.646l12.049,4.483l-12.049,4.483L13.697,12.13L25.746,7.646 M25.746,7.258L12.65,12.13
l13.096,4.873l13.096-4.873L25.746,7.258L25.746,7.258z"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.944,187.389 19.944,188.389 19.031,187.981 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9973,1.9973" x1="17.208" y1="187.166" x2="10.825" y2="184.315"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9.913,183.908 9,183.5 9,182.5 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="8.5" y1="180.5" x2="8.5" y2="173.5"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9,172.5 9,171.5 9.927,171.876 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9625,1.9625" x1="11.745" y1="172.615" x2="18.109" y2="175.199"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.018,175.568 19.944,175.944 19.944,176.944 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="19.5" y1="179.5" x2="19.5" y2="186.5"/>
</g>
</g>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="19.944,175.944 30,171.5 20,168.5
9,171.5 "/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="20.333,188.611 29.5,183.5
29.5,171.5 "/>
</g>
<g>
<path fill="#FFFFFF" d="M48.41,15.434H51L48.193,24h-2.725l-2.795-8.566h2.602l1.166,4.342c0.242,0.965,0.375,1.637,0.398,2.016
c0.027-0.273,0.082-0.615,0.164-1.025s0.154-0.732,0.217-0.967L48.41,15.434z"/>
</g>
<g>
<polygon fill="#333333" points="7,18 10,18 10,15 15,15 15,18 18,18 18,23 15,23 15,26 10,26 10,23 7,23 "/>
<g>
<g>
<rect x="11" y="16" fill="#FFFFFF" width="3" height="9"/>
</g>
<g>
<rect x="8" y="19" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="19.944,176.444 30,172 20,169 9,172
"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="20.333,189.111 29.5,184 29.5,172
"/>
</svg>

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

@ -1585,7 +1585,7 @@ void Application::init() {
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
_palette.init();
_palette.init(_glWidget->width(), _glWidget->height());
_palette.addAction(_addVoxelMode, 0, 0);
_palette.addAction(_deleteVoxelMode, 0, 1);
_palette.addTool(_swatch);

View file

@ -3,10 +3,7 @@
Swatch::Swatch(QAction* action) : Tool(action, 0, -1, -1),
_selected(1),
_margin(4),
_textRenderer(MONO_FONT_FAMILY, 10, 100) {
_width = 62;
_height = 30;
}
void Swatch::reset() {
@ -131,14 +128,16 @@ void Swatch::handleEvent(int key, bool getColor) {
}
}
void Swatch::render(int screenWidth, int screenHeight) {
void Swatch::render(int width, int height) {
char str[2];
int margin = 0.10f*height;
height = 0.75f*height;
glBegin(GL_QUADS);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2f(0, 8*(_height - _margin) + _margin);
glVertex2f(_width, 8*(_height - _margin) + _margin);
glVertex2f(_width, 0);
glVertex2f(0, 8*(height - margin) + margin);
glVertex2f(width, 8*(height - margin) + margin);
glVertex2f(width, 0);
glVertex2f(0, 0);
glEnd();
@ -147,26 +146,26 @@ void Swatch::render(int screenWidth, int screenHeight) {
glColor3f(_colors[i].redF(),
_colors[i].greenF(),
_colors[i].blueF());
glVertex2f(_margin, (i + 1)*(_height - _margin));
glVertex2f(_width - _margin, (i + 1)*(_height - _margin));
glVertex2f(_width - _margin, i*(_height - _margin) + _margin);
glVertex2f(_margin, i*(_height - _margin) + _margin);
glVertex2f(margin, (i + 1)*(height - margin));
glVertex2f(width - margin, (i + 1)*(height - margin));
glVertex2f(width - margin, i*(height - margin) + margin);
glVertex2f(margin, i*(height - margin) + margin);
glEnd();
if (_colors[i].lightness() < 50) {
glBegin(GL_LINES);
glColor3f(1.0f, 1.0f, 1.0f);
glVertex2f(_margin, (i + 1)*(_height - _margin));
glVertex2f(_width - _margin, (i + 1)*(_height - _margin));
glVertex2f(margin, (i + 1)*(height - margin));
glVertex2f(width - margin, (i + 1)*(height - margin));
glVertex2f(_width - _margin, (i + 1)*(_height - _margin));
glVertex2f(_width - _margin, i*(_height - _margin) + _margin);
glVertex2f(width - margin, (i + 1)*(height - margin));
glVertex2f(width - margin, i*(height - margin) + margin);
glVertex2f(_width - _margin, i*(_height - _margin) + _margin);
glVertex2f(_margin, i*(_height - _margin) + _margin);
glVertex2f(width - margin, i*(height - margin) + margin);
glVertex2f(margin, i*(height - margin) + margin);
glVertex2f(_margin, i*(_height - _margin) + _margin);
glVertex2f(_margin, (i + 1)*(_height - _margin));
glVertex2f(margin, i*(height - margin) + margin);
glVertex2f(margin, (i + 1)*(height - margin));
glEnd();
@ -177,15 +176,15 @@ void Swatch::render(int screenWidth, int screenHeight) {
if (_selected == i + 1) {
glBegin(GL_TRIANGLES);
glVertex2f(_margin, (i + 1)*(_height - _margin) - _margin);
glVertex2f(_width/4 - _margin, i*(_height - _margin) + _height/2.0f);
glVertex2f(_margin, i*(_height - _margin) + _margin + _margin);
glVertex2f(margin, (i + 1)*(height - margin) - margin);
glVertex2f(width/4 - margin, i*(height - margin) + height/2.0f);
glVertex2f(margin, i*(height - margin) + margin + margin);
glEnd();
}
sprintf(str, "%d", i + 1);
_textRenderer.draw(3*_width/4, (i + 1)*(_height - _margin) - 6, str);
_textRenderer.draw(3*width/4, (i + 1)*(height - margin) - 0.2f*height, str);
}
glTranslated(0, 8*(_height - _margin) + _margin + 5, 0);
glTranslated(0, 8*(height - margin) + margin + 0.075f*height, 0);
}

View file

@ -24,15 +24,13 @@ public:
void loadData(QSettings* settings);
void reset();
void render(int screenWidth, int screenHeight);
void render(int width, int height);
void handleEvent(int key, bool getColor);
private:
TextRenderer _textRenderer;
QColor _colors[SWATCH_SIZE];
int _selected;
int _margin;
};
#endif /* defined(__interface__Swatch__) */

View file

@ -7,16 +7,14 @@
Tool::Tool(QAction *action, GLuint texture, int x, int y) : _texture(texture),
_action(action),
_x(x),
_y(y),
_width(62),
_height(40) {
_y(y) {
}
bool Tool::isActive() {
return _action->isChecked();
}
void Tool::render(int screenWidth, int screenHeight) {
void Tool::render(int width, int height) {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _texture);
@ -31,13 +29,13 @@ void Tool::render(int screenWidth, int screenHeight) {
glBegin(GL_QUADS);
glTexCoord2f(_x/TOOLS_COLS, 1.0f - (_y + 1)/TOOLS_ROWS);
glVertex2f(0, _height);
glVertex2f(0, height);
glTexCoord2f((_x + 1)/TOOLS_COLS, 1.0f - (_y + 1)/TOOLS_ROWS);
glVertex2f(_width, _height);
glVertex2f(width, height);
glTexCoord2f((_x + 1)/TOOLS_COLS, 1.0f - _y/TOOLS_ROWS);
glVertex2f(_width, 0);
glVertex2f(width, 0);
glTexCoord2f(_x/TOOLS_COLS, 1.0f - _y/TOOLS_ROWS);
glVertex2f(0, 0);
@ -45,5 +43,5 @@ void Tool::render(int screenWidth, int screenHeight) {
glDisable(GL_TEXTURE_2D);
glTranslated(0, _height + 5, 0);
glTranslated(0, 1.10f*height, 0);
}

View file

@ -15,16 +15,12 @@
class QAction;
// tool size
static double _width;
static double _height;
class Tool {
public:
Tool(QAction *action, GLuint texture, int x, int y);
bool isActive();
virtual void render(int screenWidth, int screenHeight);
virtual void render(int width, int height);
protected:
QAction* _action;
@ -33,10 +29,6 @@ protected:
// position in the SVG grid
double _x;
double _y;
// tool size
double _width;
double _height;
};
#endif /* defined(__interface__Tool__) */

View file

@ -6,12 +6,24 @@
#include <SharedUtil.h>
ToolsPalette::ToolsPalette() {
}
void ToolsPalette::init(int screenWidth, int screenHeight) {
_width = 3*screenWidth/100;
if (_width < 47) {
_width = 47;
}
_height = 40*_width/62;
_left = screenWidth/100;
_top = (screenHeight - 12*_height)/2;
// Load SVG
switchToResourcesParentIfRequired();
QSvgRenderer renderer(QString("./resources/images/hifi-interface-tools.svg"));
// Prepare a QImage with desired characteritisc
QImage image(124, 400, QImage::Format_ARGB32);
QImage image(TOOLS_COLS*_width, TOOLS_ROWS*_height, QImage::Format_ARGB32);
// Get QPainter that paints to the image
QPainter painter(&image);
@ -19,11 +31,6 @@ ToolsPalette::ToolsPalette() {
//get the OpenGL-friendly image
_textureImage = QGLWidget::convertToGLFormat(image);
}
void ToolsPalette::init(int top, int left) {
_top = top;
_left = left;
glGenTextures(1, &_textureID);
glBindTexture(GL_TEXTURE_2D, _textureID);
@ -51,6 +58,15 @@ void ToolsPalette::addTool(Tool *tool) {
}
void ToolsPalette::render(int screenWidth, int screenHeight) {
_width = 3*screenWidth/100;
if (_width < 47) {
_width = 47;
}
_height = 40*_width/62;
_left = screenWidth/150;
_top = (screenHeight - 13*_height)/2;
glPushMatrix();
glTranslated(_left, _top, 0);
@ -64,7 +80,7 @@ void ToolsPalette::render(int screenWidth, int screenHeight) {
if (show) {
for (unsigned int i(0); i < _tools.size(); ++i) {
_tools[i]->render(screenWidth, screenHeight);
_tools[i]->render(_width, _height);
}
}

View file

@ -17,7 +17,7 @@ class ToolsPalette {
public:
ToolsPalette();
void init(int top = 200, int left = 10);
void init(int screenWidth, int screenHeight);
void addAction(QAction* action, int x, int y);
void addTool(Tool *tool);
void render(int screenWidth, int screenHeight);
@ -30,6 +30,9 @@ private:
int _top;
int _left;
int _width;
int _height;
};
#endif /* defined(__interface__ToolsPalette__) */