From 8c3a00d7b5814b3745fb46a41070167c8b74096d Mon Sep 17 00:00:00 2001 From: mfreiholz Date: Mon, 18 Apr 2016 12:30:24 +0200 Subject: [PATCH] Create drop indicator images on the fly. No longer use PNG resources (better in case of license issues). Drop images should be scalable now! --- AdvancedDockingSystem/res/ads.qrc | 12 -- .../res/img/dnd-thumbnail.png | Bin 249 -> 0 bytes AdvancedDockingSystem/res/img/dock-bottom.png | Bin 489 -> 0 bytes AdvancedDockingSystem/res/img/dock-center.png | Bin 402 -> 0 bytes AdvancedDockingSystem/res/img/dock-left.png | Bin 527 -> 0 bytes AdvancedDockingSystem/res/img/dock-right.png | Bin 516 -> 0 bytes AdvancedDockingSystem/res/img/dock-top.png | Bin 498 -> 0 bytes .../res/img/split-bottom.png | Bin 628 -> 0 bytes AdvancedDockingSystem/res/img/split-left.png | Bin 638 -> 0 bytes AdvancedDockingSystem/res/img/split-right.png | Bin 647 -> 0 bytes AdvancedDockingSystem/res/img/split-top.png | Bin 619 -> 0 bytes .../res/img/splitter-horizontal.png | Bin 326 -> 0 bytes .../res/img/splitter-vertical.png | Bin 406 -> 0 bytes AdvancedDockingSystem/src/DropOverlay.cpp | 112 ++++++++++++++++-- README.md | 3 - 15 files changed, 102 insertions(+), 25 deletions(-) delete mode 100644 AdvancedDockingSystem/res/img/dnd-thumbnail.png delete mode 100644 AdvancedDockingSystem/res/img/dock-bottom.png delete mode 100644 AdvancedDockingSystem/res/img/dock-center.png delete mode 100644 AdvancedDockingSystem/res/img/dock-left.png delete mode 100644 AdvancedDockingSystem/res/img/dock-right.png delete mode 100644 AdvancedDockingSystem/res/img/dock-top.png delete mode 100644 AdvancedDockingSystem/res/img/split-bottom.png delete mode 100644 AdvancedDockingSystem/res/img/split-left.png delete mode 100644 AdvancedDockingSystem/res/img/split-right.png delete mode 100644 AdvancedDockingSystem/res/img/split-top.png delete mode 100644 AdvancedDockingSystem/res/img/splitter-horizontal.png delete mode 100644 AdvancedDockingSystem/res/img/splitter-vertical.png diff --git a/AdvancedDockingSystem/res/ads.qrc b/AdvancedDockingSystem/res/ads.qrc index c862541..e3dd656 100644 --- a/AdvancedDockingSystem/res/ads.qrc +++ b/AdvancedDockingSystem/res/ads.qrc @@ -1,17 +1,5 @@ - img/dnd-thumbnail.png - img/dock-bottom.png - img/dock-center.png - img/dock-left.png - img/dock-right.png - img/dock-top.png - img/split-bottom.png - img/split-left.png - img/split-right.png - img/split-top.png - img/splitter-horizontal.png - img/splitter-vertical.png stylesheets/default-windows.css stylesheets/vendor-partsolutions.css stylesheets/modern-windows.css diff --git a/AdvancedDockingSystem/res/img/dnd-thumbnail.png b/AdvancedDockingSystem/res/img/dnd-thumbnail.png deleted file mode 100644 index 9b3bdc29652475b22b70da30f2f87597d1accc10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3HQ#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G^recZx~4727)00r4gJbhi+Z!(H=D#=BwKa>RuReHKOhFF|l zJ0+0sfC7iJ{ITZUlgsxX<6utzza}EOS%Q%z%98o>t7?^R0nMqhp)zewk?TTb&z`&U z%R^)L^-X$4rM?RSJGLKY;JmV<3Ldt{~mkE}C`<$hn4au=^`U-f6| p{>sv<8{z5s7TRYwU-taX)Kg?#>+^TRZlEI=JYD@<);T3K0RTHnSe5_) diff --git a/AdvancedDockingSystem/res/img/dock-bottom.png b/AdvancedDockingSystem/res/img/dock-bottom.png deleted file mode 100644 index 54144b67200bcf6311c3636321e9cc9003d5fc3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 489 zcmVv5)uXfkfo!H6s00fJ|G1JRYXHYm!+_fBKypoLt%S;VOIfdB4upd zYaiV?kC|()KYRiZ3W=mBr<3&V=|GasYEscjIT;cqJ-&HbU46cJ{`L@nlq6e5>uOsy z&Zc48vT-(z8s}_MHO|&WhEr1D@=FEa+xKflMuwDBNZ|}pt`Nf+E=jq!*Gfr>kr5G* zQ=kIy{_qKQ!eajQ5$=YE=2u&z&yFsD9RJObIA6~HxBmHZK3lD(tDm#(yC0(dPwIM7*Jr0McA5X=;%L3@sNe16d-Ct<$FIeFxx)&;4)%}Vd|Uv??49b71|-Z9 zX@!+A8;;`LtCRb%~ewl_kG~p=&-3HY7wh*_z){))D{QHufTG zpKz$(36};ShqJwY!yxMhtV~w{pb`lDU1?3oA)bXqHu4p*ZTc*<%nfz(U-z#xVng;( fiG%&)yZHYb@(nX|>sSns00000NkvXXu0mjfcn8|{ diff --git a/AdvancedDockingSystem/res/img/dock-center.png b/AdvancedDockingSystem/res/img/dock-center.png deleted file mode 100644 index 7b510b3debe0c742c695cdfaef0e563c4d0cb321..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 402 zcmV;D0d4+?P)U2VoaIVabH&BQUWeGx(a}wM z(O81jJW6FoRBnK!>tSw+T7=ia!opl?g+EPbQeb(nwYC5M|5g9YH2?qr32;bR za{vGf6951U69E94oEQKA00(qQO+^Ra3<(AaAr4}3bN~PVTuDShR4C75uxDiCVB|1V zH&u}nmr|5rvd@aS3q=DJ#gE041ETf>DVlmB5QX1(cVk7O zrlF)sLx)6(at%}n?C&%YUuMYv3S`!*mQzfa?!a}mtr!JB#j485^T1Zo+sy_bxA_92&{5{FG zO*xmgO{z|^qjg2QPIF<->^kPcoHZA=DdxhiC~1YNYWVss0{HRsm#U{23N^)GZmLc- zRVy@7i<;63t*EMc2%V~vN^>(a^8+9Pc=?O~LSrd}7?Dysh#`h1#U?ZjfTJgm@Xxhg zeQzee;sVIzzyaXw<0W=j&HSF%4Gs}h)lU~6_7$oKf?&D{rxn zzHC<8Q=7bMg4MCTJKM+Un6=XWvnF-4YVH%j2hN&|c}PFBI}*vs@j3p-`U8At2(j*3 R*i--j002ovPDHLkV1haP>oouX diff --git a/AdvancedDockingSystem/res/img/dock-right.png b/AdvancedDockingSystem/res/img/dock-right.png deleted file mode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zT)ezo+(4wj%?%V~XJrK!t^Vgmr_kBdW!Pr4ca O0000bJ|{x69+u-tW}n@zvGU#nRJ@=h4y8b)4m(!2HzV@twW< z%i8SF-|)}g@4U|Cz|!bVdeKT(b6tqpYm?w}nB!G|)yv!LW{=)!cav0p(>zLL#@Fh> z(&yLL*U#VYSc28i-tbptfNqxJMRd(&bBRz-@e&VQz|bgP*p` z;z4lALQrf!O=v@M%W;34fTin6cFvQv^=y;hjj-~&&*atO@rSDKd7kG_deFDbZzR__ik}_udB#RrRa>>3Ur0PhOpYFYC(=7t5Lf zjF=RWA~9)qIBzb6eb5v1w5r!90%18Mhr)6+?DSWEykbw Y06t)g`CH%6{Qv*}07*qoM6N<$g8hP0HUIzs diff --git a/AdvancedDockingSystem/res/img/split-right.png b/AdvancedDockingSystem/res/img/split-right.png deleted file mode 100644 index 6a11acfea28b55b316279760557e1dcd5592cf48..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 647 zcmV;20(kw2P)FhL(BALG*Xq>b@wdz4yUyg*)z#47@6_V*%i8U<$l<%r<-5=2dWof(x%YCJ z_7roaNBp@WImOoxS_U#>U0P#nI8xO?uH@huFl##MI&O zz|!c;+U&f}<-pVDpuqfho#$nY+|Sqh^Re;sP!oojI zXkl)O&)@H9cawmn>(J29*VorF`dz24s5$jHds+uKq>oYT|OwY9bX|NqRpC?)^^010qN zS#tmY3ljhU3ljkVnw%H_000McNliru-wX&203aR+%ys|(0O(0XK~yNuV@MJZ5ET$L z3N!Z%bvFnK5SI{_u#a>zO=3ur5!4XWkP)Ksv+ zuHv==Iv3M&psTpR{=l?@4Je_)fyEypT)-gl$D%`7n~_x=tE+$#3~Jc?!NtfbjV*N9 hxOjvaph1EI0009TjO=R$FhLx69+u-tW}n@zCGz#ni~<;K?P)Zy~Q#l^

_7ETz8O#z|!c@-|*Do@nwwM%i8R`&gIe3(a+xR zz|-fu&*aR^%xQO%leP7AgP(Vu=U9T(LQrggrR#d1=$X0q(BAMtaLR0x-${1PMpSOs z*Vk=)mtu?C)#C9?cg}c*qj{d^W{=);nB!q?ic(;ERDRQ4h}p~A?1!rFJW6Gqz57pk z(7?dJYm?wyYK3l=;$?G=!P4k*ndG<3<8_?nLvqW;*XqyT??rUYjj-}@f1Fi-)mLSJ zKTT-1%i>yu*Vp9py}iBO-rmT_$lKf7QbC;4)6=!Jwg3PBPk};N00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-yu2n{^eMB>w+DxOs*z=sM?Q@3TlU*)IRQ6<7Vm?;sk9Mw-?0 z#3gPlHhnG~Kc70i*IXi(cpT1Ju(ir=vz&L|N7qw46;Cz3_b;%NUPMu(RHR$#6)dc# zJ!q58H&x{e14`{&2A0YluIpMP$HxC7RKiVyJN5XJxi002ovPDHLk FV1jjINHqWe diff --git a/AdvancedDockingSystem/res/img/splitter-horizontal.png b/AdvancedDockingSystem/res/img/splitter-horizontal.png deleted file mode 100644 index a10a87b5d5ee99b1268ddc9819809c7f7b453299..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XUU<4VhE&{2`t$$4J+o>? zLxB%Wg(3p_%#Y6V@$vB}@G#f^`;(ZFmv^kBv8jovXC}juoB*jv8P*L6#tRlMWPH+f z(!elfwjs}t@9*d9U$6{%A!KG|rg6@d-J$k;!Lu}R~{`}_MP zY9?5zsj0QCTD2-?1Gk)g-JeS*Pp)jZav?oEy`IzT!SnO;v+e8u^(g&(dRm+<#V{@| zj!jNZ?h%vVlAq7c&Q^Hlr1G$$w6t_hTY`)7q_e6D)15NeO2Q8bU%GIfTSS^cAc3J+ WsxTqqU1to?&kUZfelF{r5}E*xvwVR7 diff --git a/AdvancedDockingSystem/res/img/splitter-vertical.png b/AdvancedDockingSystem/res/img/splitter-vertical.png deleted file mode 100644 index f05169198ccb1160478df7e8b423e65382100992..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 406 zcmV;H0crk;P)1}cG zT^u|42zR@4hiZo^K{^5j=w2f*@d( zkpPBC$K=}>-zR|8y@5Q9mFc(*0d4eS{HTKukQYqkI$#9oALIK&1pI(p6-6QNfEWRg z2>^^;&&+_Rs!C*8UUYzdQ528YXcz|5P@RnguL2}&jgllC6BI?Um?^$Qyu#^+6vy!* zhIgMjI7N_U*?fk?NZ0ju(BJn6DE~YE2fqRg0CrNvAZ%8h`v3p{07*qoM6N<$g6)W> AW&i*H diff --git a/AdvancedDockingSystem/src/DropOverlay.cpp b/AdvancedDockingSystem/src/DropOverlay.cpp index ca112b6..e846a94 100644 --- a/AdvancedDockingSystem/src/DropOverlay.cpp +++ b/AdvancedDockingSystem/src/DropOverlay.cpp @@ -14,12 +14,104 @@ ADS_NAMESPACE_BEGIN // Helper ///////////////////////////////////////////////////////////// -static QWidget* createDropWidget(const QString& img) +static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DropArea dropArea) { - QLabel* label = new QLabel(); - label->setObjectName("DropAreaLabel"); - label->setPixmap(QPixmap(img)); - return label; + const QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight); + const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base); + const QColor areaBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(150); + + QPixmap pm(size.width(), size.height()); + pm.fill(QColor(0, 0, 0, 0)); + + QPainter p(&pm); + QPen pen = p.pen(); + QRectF baseRect(pm.rect()); + + // Fill + p.fillRect(baseRect, backgroundColor); + + // Drop area rect. + if (true) + { + p.save(); + QRectF areaRect; + QLineF areaLine; + QLinearGradient gradient; + switch (dropArea) + { + case TopDropArea: + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width(), baseRect.height() * .5f); + areaLine = QLineF(areaRect.bottomLeft(), areaRect.bottomRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.bottomLeft()); + gradient.setColorAt(0.f, areaBackgroundColor); + gradient.setColorAt(1.f, areaBackgroundColor.lighter(120)); + break; + case RightDropArea: + areaRect = QRectF(baseRect.width() * .5f, baseRect.y(), baseRect.width() * .5f, baseRect.height()); + areaLine = QLineF(areaRect.topLeft(), areaRect.bottomLeft()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.topRight()); + gradient.setColorAt(0.f, areaBackgroundColor.lighter(120)); + gradient.setColorAt(1.f, areaBackgroundColor); + break; + case BottomDropArea: + areaRect = QRectF(baseRect.x(), baseRect.height() * .5f, baseRect.width(), baseRect.height() * .5f); + areaLine = QLineF(areaRect.topLeft(), areaRect.topRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.bottomLeft()); + gradient.setColorAt(0.f, areaBackgroundColor.lighter(120)); + gradient.setColorAt(1.f, areaBackgroundColor); + break; + case LeftDropArea: + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width() * .5f, baseRect.height()); + areaLine = QLineF(areaRect.topRight(), areaRect.bottomRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.topRight()); + gradient.setColorAt(0.f, areaBackgroundColor); + gradient.setColorAt(1.f, areaBackgroundColor.lighter(120)); + break; + case CenterDropArea: + break; + } + if (areaRect.isValid()) + { + p.fillRect(areaRect, gradient); + + pen = p.pen(); + pen.setColor(borderColor); + pen.setStyle(Qt::DashLine); + p.setPen(pen); + p.drawLine(areaLine); + } + p.restore(); + } + + // Border + if (true) + { + p.save(); + pen = p.pen(); + pen.setColor(borderColor); + pen.setWidth(1); + + p.setPen(pen); + p.drawRect(baseRect.adjusted(0, 0, -pen.width(), -pen.width())); + p.restore(); + } + return pm; +} + +static QWidget* createDropIndicatorWidget(DropArea dropArea) +{ + QLabel* l = new QLabel(); + l->setObjectName("DropAreaLabel"); + + const qreal metric = static_cast(l->fontMetrics().height()) * 2.f; + const QSizeF size(metric, metric); + + l->setPixmap(createDropIndicatorPixmap(l->palette(), size, dropArea)); + return l; } /////////////////////////////////////////////////////////////////////// @@ -42,11 +134,11 @@ DropOverlay::DropOverlay(QWidget* parent) : // Cross with default drop area widgets. QHash areaWidgets; - areaWidgets.insert(ADS_NS::TopDropArea, createDropWidget(":/img/split-top.png")); - areaWidgets.insert(ADS_NS::RightDropArea, createDropWidget(":/img/split-right.png")); - areaWidgets.insert(ADS_NS::BottomDropArea, createDropWidget(":/img/split-bottom.png")); - areaWidgets.insert(ADS_NS::LeftDropArea, createDropWidget(":/img/split-left.png")); - areaWidgets.insert(ADS_NS::CenterDropArea, createDropWidget(":/img/dock-center.png")); + areaWidgets.insert(ADS_NS::TopDropArea, createDropIndicatorWidget(TopDropArea)); //createDropWidget(":/img/split-top.png")); + areaWidgets.insert(ADS_NS::RightDropArea, createDropIndicatorWidget(RightDropArea));//createDropWidget(":/img/split-right.png")); + areaWidgets.insert(ADS_NS::BottomDropArea, createDropIndicatorWidget(BottomDropArea));//createDropWidget(":/img/split-bottom.png")); + areaWidgets.insert(ADS_NS::LeftDropArea, createDropIndicatorWidget(LeftDropArea));//createDropWidget(":/img/split-left.png")); + areaWidgets.insert(ADS_NS::CenterDropArea, createDropIndicatorWidget(CenterDropArea));//createDropWidget(":/img/dock-center.png")); _cross->setAreaWidgets(areaWidgets); _cross->setVisible(false); diff --git a/README.md b/README.md index 738ba46..5b0d407 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,3 @@ This projects uses the [WTFPL license](http://www.wtfpl.net/) (Do **W**hat **T**he **F**uck You Want To **P**ublic **L**icense) Using it? Let us know by creating a [new issue](https://github.com/mfreiholz/qt-docks/issues/new) (You don't have to, of course). - -## Credits -- Drop indicator images from [Code Project Article](http://www.codeproject.com/Articles/140209/Building-a-Docking-Window-Management-Solution-in-W)