Git commit 93ef7c8ef97e3ba5a1349ba38408269205a9d2b8 by Wolthera van Hovell = tot Westerflier. Committed on 06/09/2016 at 14:17. Pushed by woltherav into branch 'master'. Merge in new internal color picker dialog! Tremble, dear commit reader, for a new era of color picking has arrived! This is the second part of my Google Summer of Code 206 project. It is a in= ternal color selector, that can handle wide-gamut colors, pick colors from = the screen (which is smart enough to identify Krita canvases and pick the c= orrect color managed color that way). It also changes properly using the lu= t manager exposure controls, and it=E2=80=99s main element, the visual colo= r selector can use the advanced color selector config. This selector is also intergrated into a kis_color_button and used where ev= er I could port it reliably. It=E2=80=99ll also show up in the pop-up palet= te. Furthermore, this merge contains little palette usability things, like bein= g able to see the swatch name, search by swatch name and have the split->la= yer functionality use a palette to name the resultant layers. Also allows c= ustom-pattern to be mindful of the active selection. Anyway, needs a lot of testing! CCMAIL:kimageshop@kde.org Ref T2337 Ref T2438 Squashed commit of the following: commit 1cf8527877d316b0c3149494535740b7ff3e5c6f Author: Wolthera van Hovell tot Westerflier Date: Tue Sep 6 16:16:24 2016 +0200 Fix build commit d39cecc36ab9fa2f32de8fa3cefe7072c1824dcf Author: Wolthera van Hovell tot Westerflier Date: Tue Sep 6 15:32:08 2016 +0200 Rename the internal color selector dialog to reflect it being a dialog commit afc8658b4114df00644061105b4ed56f08cc257b Merge: 27d4034 91bdcfe Author: Wolthera van Hovell tot Westerflier Date: Tue Sep 6 15:22:33 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 27d4034efe5d37cde00bb3dd33cab985f6deacd2 Author: Wolthera van Hovell tot Westerflier Date: Sat Sep 3 16:35:23 2016 +0200 Fix screencolor picker label. Ref T2438 commit 29d34d885455f1e5fbfd3ba0e1c5c92974d4f2bf Author: Wolthera van Hovell tot Westerflier Date: Sat Sep 3 16:20:07 2016 +0200 Fix color conversion issues with the selector. Now the selector will show grayscale on a mask, and will update upon ch= anging the image color space. Ref T2438 commit 3dc397583dbb93b4a362abce1ad6df50ee2c7485 Author: Wolthera van Hovell tot Westerflier Date: Fri Sep 2 17:47:53 2016 +0200 Simplify Gradient Map filter and make it usable as a filter layer. There's some awkwardness with the first two generic gradients as the co= lor isn't stored, but this is good for now. Fixes T1837 commit 4a4f704e1700a24f214a844879df09128df64b95 Author: Boudewijn Rempt Date: Fri Sep 2 17:34:00 2016 +0200 Fix drawing the gradient commit 13f83919be65000fc1682940afe6c81fdcc8c1ae Author: Julian Thijssen Date: Fri Sep 2 17:30:51 2016 +0200 Nearest neighbour filtering applies on all zoom levels commit 0a4a62bc9370878441d57f87ed50fbbc7d394ef7 Author: Boudewijn Rempt Date: Fri Sep 2 16:36:02 2016 +0200 Refactor KisColorSource to use KoColor in a saner way commit 58bf4b9ab601c6f5f0aa593c5e86c20ee994e545 Author: Boudewijn Rempt Date: Fri Sep 2 16:21:40 2016 +0200 Make KoSegmentGradient::colorAt threadsafe commit 54df09f834a5fa36db6b98742f7ac05ec9b90170 Author: Boudewijn Rempt Date: Fri Sep 2 16:21:19 2016 +0200 Make this class safe It means we don't cache the QImage, but there is no alternative commit 362c78b89d997845e0fdd7764dd896d031ac632c Author: Boudewijn Rempt Date: Fri Sep 2 16:21:02 2016 +0200 Warn that this class is not threadsafe commit cd02553f552f01cd73c2ec57874195f82d4110f3 Author: Boudewijn Rempt Date: Fri Sep 2 16:06:51 2016 +0200 Make KoStopGradient::colorAt threadsave Sneakily, the "buffer" variable was made a class variable. Marking it mutable allows us to change it from a const function, which hides the fact that this is global data (doubly hidden by there not being an m_ prefix), which makes the const function thread unsafe. commit 904cc82dbdc387e93a478a4a661b7122ce8b965e Author: Boudewijn Rempt Date: Fri Sep 2 15:56:24 2016 +0200 Also revert the patch commit 349b5e776205e844268835f603f36bf89c8eb7b3 Author: Boudewijn Rempt Date: Fri Sep 2 14:57:27 2016 +0200 Try harder to find the tag files on Windows and OSX This is yet another KoResourcePaths problem... BUG:366757 commit dbaa7bcdcdaf3ce139227988dca4ba2e6a85f191 Author: Boudewijn Rempt Date: Fri Sep 2 13:56:14 2016 +0200 Fix logic error... I shouldn't code during a sprint, only afterwards commit 71692523af5cd589e3b5059b8960a00b446c8e20 Author: Boudewijn Rempt Date: Fri Sep 2 12:09:42 2016 +0200 Fix typo commit 88bf822c445752d10ea962e88b8e31c8ad8cf337 Author: Boudewijn Rempt Date: Fri Sep 2 11:56:59 2016 +0200 Go back to ki18n 5.17 for now To avoid the system-language bug until it's fixed. CCBUG:368007 commit 6f057f4659283fb847f4a74f6781541e4cf91672 Author: Boudewijn Rempt Date: Fri Sep 2 11:35:54 2016 +0200 Remove unused ui file (Was forgotten in commit 010c0f3066d872d0f91ec3a38057b4fcaedca4ad Author: Boudewijn Rempt Date: Sat Mar 30 12:22:40 2013 +0100 Remove unimplemented custom palette dialog ) commit 4e053745797b9a70ef98555465f6dadb40eed117 Author: Eugene Ingerman Date: Tue Aug 30 22:14:51 2016 -0700 Fixing https://bugs.kde.org/show_bug.cgi?id=3D367901. Removing wait whi= ch causes possible race condition. commit 99b11b2bfa6a5b3af93c83de5877e4b1edbe07ee Author: Boudewijn Rempt Date: Fri Sep 2 14:30:20 2016 +0200 Improve the view selection when color picking We can easily grab a list of all existing views and check whether they are under the cursor. Color picking from a krita image now gets the color directly no matter the active window or view. commit 16c8832c93424f208ad54735777bdf2756c92161 Author: Wolthera van Hovell tot Westerflier Date: Fri Sep 2 12:18:36 2016 +0200 Port the last areas to use the KisColorButton as far as possible. There's still the grid docker, which has a bit of a UI problem, and the= n rest is flake and friends. Ref T2438 commit ef9aeb29492afed382ee8e153c6290867e42b6d3 Merge: ceaafb0 58364da Author: Wolthera van Hovell tot Westerflier Date: Thu Sep 1 22:04:37 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit ceaafb000d1ee9da7078bb589f418b59218f6948 Merge: f70701d 853e42f Author: Wolthera van Hovell tot Westerflier Date: Thu Sep 1 13:30:58 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit f70701dced469bdcd82aaadcc868d3bb06507465 Merge: ed64943 fe21cb5 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 31 22:37:24 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit ed649432567924e02ddb7c0ac45f259f0eab4b3a Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 31 22:32:02 2016 +0200 Add the kiscolorbutton in more places commit d635b53e2586af1e811d00c2f4b7110694ec21a6 Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 29 11:52:25 2016 +0200 Make the UI layout of the internal color selector a little nicer. Ref T2438 commit cf7c567a9194d999fa1c2dd90a20d9353ba61ee3 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 28 15:08:03 2016 +0200 Fix issue with gamut alarm default space commit 364d1b3cc873cc3fa5662299405de10f390fb12e Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 28 15:02:21 2016 +0200 Use sRGB for the UI commit 23dcf5d9d0f3ff2b25b7e86d826d48be37b322e2 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 28 14:54:46 2016 +0200 Replace kcolorbutton with new kiscolorbutton in several places. The new dialog is accesible from all these places. There's still several places where they still need to be replaced. Ref T2438 commit c5621355279c211721a74e2d4affa0d322e3de9f Author: Sven Langkamp Date: Sat Aug 27 10:50:40 2016 +0200 Pick color from canvas directly if the cursor is over the canvas commit 1afa4384e84fa5af6f8681545787f81cdd4f183e Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 26 18:29:19 2016 +0200 Use internal visual selector in the Pop-up palette. This means you finally can have your shape of choice inside the pop-up = palette! Needs testing, obviously. Ref T2438 commit 9a07179d79d8ed3333cd772c002a98e27df03138 Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 26 16:10:31 2016 +0200 Fix updating in modal dialog. Also add an extra check for 8bit so we can be a bit more precise in 16b= it and higher. Ref T2438 commit cdd0cd6a54876dbba5c102160e4bf523fec64b39 Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 26 15:15:24 2016 +0200 Fix offset for circular shape. commit 97372d6eef81bd2623e5575013045f73d5f95ed0 Author: Wolthera van Hovell tot Westerflier Date: Thu Aug 25 11:43:14 2016 +0200 Make the custom pattern widget take the selection into account. Now, if you have a selection, it'll use only that area to retreive the = pattern from. I was thinking of whether it needed an extra toggle, but both Scott and= Boud thought it was implicit that having a selection means you want to use= it. This is my first time playing with selection code, so a glance would be= nice. Auditors: dkazakov commit de26f01fcd4544bffc11947b64e08418666135f2 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 19:20:13 2016 +0200 Check for colorspaces with or not and, a cs can't be all at the same ti= me. This fixes floating point from the visual selector shape again. :) Ref T2438 commit 80a8d54ed249a6c65a46db5181a17606a579b693 Merge: 389c2bd da04c19 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 16:22:56 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 389c2bd5123af74918bc26949823dcb75867bafb Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 16:21:23 2016 +0200 Fork KColorButton, make it use internal selector dialog. For now only in the fill layers. Ref T2438 commit c71c0b696915258aae3adad4345005fadb3e561a Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 14:37:50 2016 +0200 Add config struct to kisinternalcolorselector Ref T2438 commit 439cc77b25571338dfc0c23cf3f09023cdd9d344 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 13:54:36 2016 +0200 Add offset to circle and rectangle as well. And more cursor fixes... grrrr. commit fcdc7cd1d153942dde834c5532dfd5816132cd75 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 12:43:06 2016 +0200 Fix errors in HSL formula. Also fix hsx cursor wiggling position _again_... commit ba6dd494ee239ad65d5306aca8c46abee7f04bea Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 11:18:01 2016 +0200 Fix loading on config change. commit 28505a7455211f9448abb880af83b078b3e8fd2c Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 10:33:52 2016 +0200 Fix HSX cursor position on 0 sat, AGAIN. This is the best I can give it. commit 68739e5dc010f830667b3a949963a91656651dd3 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 08:57:09 2016 +0200 Use Advanced Color Selector Configuration to set visual's shape, p.2 The debugging. Probably not all bugs, but the obvious ones are gone now. commit e7d52d68b75edfd09200926567536fec25e9a4e8 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 08:05:58 2016 +0200 Use Advanced Color Selector Configuration to set visual's shape, P3 P2 came before p2. Anyway, this implements resizing. Now left-over debu= gging. commit 6995071af937c32fcb92d8b0c20e42135d427a51 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 24 00:12:25 2016 +0200 Use Advanced Color Selector Configuration to set visual's shape, P1 Now only need p2: the debugging, and p3: the resizening... But happy this is out of the way. Ref T2438 commit 763a373b26cc1d2a3ab57e8982ede68ca727bb32 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 22:15:09 2016 +0200 Add Hex code widget that only outputs and reads sRGB colors. Nothing else understands having hexcode in other spaces anyway. Ref T2438 commit 04707daf21d4201684dc8860151678a276331d76 Author: Boudewijn Rempt Date: Tue Aug 23 18:55:04 2016 +0200 Move KisColorInput to libs/ui/widgets commit fbc74f15121590b10144da71a777709f1c75fab5 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 16:11:21 2016 +0200 Add colorspace locking to the internal selector. So it doesn't flip between colorspaces all the time. Also fixes a crash in KoDualColorButton Ref T2438 commit c33f2ae2939130d8a05b5e6596d07eba95bf87b7 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 15:02:47 2016 +0200 Remove qstring compare in commonly called function. Should speed things up. commit 12799acad033e3825399af81341dcc78f531907e Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 14:44:46 2016 +0200 Make mouse press event select a color too. Also speed up the timers a little bit. commit b97cef85d33eb71fc8ef4057d4c04bdf95edb986 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 13:58:11 2016 +0200 Allow the modal dialog to have ok/cancel buttons as well. According to boud, some desktop enviroments have no close button on dia= logs. Ref T2438 commit 960bde483a5f66918bfb5507b7e15559d5d9cb6e Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 13:56:55 2016 +0200 Make color selector faster. By removing a mask check. Ref T2438 commit e06052e2509701fbe31a1e80fa89dd6237ec8ad0 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 10:52:40 2016 +0200 Turn on tagging for palettes. This was a matter of toggling an option. Beware that tagging with palet= tes will have all the bugs associated with the other tagging options. With the colorname hover-options, this means that this fixes BUG:360453 commit 82d1a1b795f9897e6fb9e86dd21a26eac1cf9814 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 10:40:41 2016 +0200 Make the color names drop down update when you choose a color on the pa= lette itself. Seemed like it should to me. commit e0ed2fd7586e068121e22cbea31a4b7d82379c99 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 23 10:29:40 2016 +0200 Add the ability to let the layer split use color names from a palette. This also implements two 'closest match' functions in kocolorset. One f= or the name, the other only for the index. BUG:348837 commit 73eb12ee2571759c86c8a55c135ec4ecd769e396 Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 22 16:52:10 2016 +0200 Add a little combobox that allows you to search the palette colornames If I was better with regexp it might've been a bit smoother, but at the= least you can now type in a colorname to select it quickly. Ref T2438 commit 68c2c8ed8ca8c6c1d820ed4a6888206a43b58fc1 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 21 14:29:24 2016 +0200 Add some offset to the triangle selector. Also fix some issues with setting hsv and fix and remove some debug. commit 6d3b11f6746652844616b0a52a7e86b5441181b2 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 21 11:46:46 2016 +0200 Make column-count work with colorset widget. Now the palette swatches align :) Ref 2438 commit bc1ad37b974507b203ec64e9e98d30385e2e6d29 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 23:30:51 2016 +0200 Add using the colornames in the approprite colorset widgets. The palette docker doesn't have the ability to give tooltips due being = a slightly different model, so hence the extra label. I also tried setting the kocolorsetwidget the size of the current colum= n count, but this crashes on startup for reasons I cannot understand. commit 22ccd6620964769274e13ea5778b9e7dfe29e1fc Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 21:42:32 2016 +0200 Make prettier and change previous color focus event. Ref 2438 commit 8c2914254e053f314b803b4f064c5534a7aeb4ba Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 19:24:35 2016 +0200 change kodualcolorbutton about to simply code. This doesn't prevent a crash when closing all available documents, sadl= y. commit eb1232be68bae9d71130d4c3a56f4f139b89c4ba Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 18:22:49 2016 +0200 Fix channel-order, hue rortaton and the mirrored circle border commit 0718fb65ab9fb4d9168e2ca76bb2600a754ebb1e Merge: 541b596 bba9f1c Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 16:49:09 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 541b596e74547fcbd8e14857e08685e88e9450cd Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 16:47:42 2016 +0200 Make drawing the image slightly faster. But it's not fast enough yet. Also using QImage everywhere now, it's a = bit more sensible... Ref T2438 commit b440e55a6094128fb6f3a1da0f41045ee4a4edc9 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 14:42:56 2016 +0200 Fix a bunch of minor issues. commit 6655f984354de967f9217787e8e6a3eda3b5bb74 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 14:28:44 2016 +0200 Add display color converters to the KoColorSetWidget/KoColorPatch Ref T2438 commit b5a0d6c36c15f0e9d1d5ba821f623df151122a8a Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 13:30:35 2016 +0200 Fix selector on single-dimension hue wheel, also rotate hue. Ref T2438 commit f8fb2e088596ff430db5d4a74fd18f4fbbd58f82 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 20 12:34:19 2016 +0200 Add cursor position to the triangle. I spent 9+ hours trying to figure out how to make one where the value l= ength fully vertical, but failed, so gave up and copied the kis_color_selec= tor_triangle solution. Ref 2438 commit 36e4b72ceca1f6d7c72372b218decb463cdfd4df Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 19 12:18:40 2016 +0200 Attempt to fix flickering... this doesn't fix it :/ Makes the code simpler though... commit 0442f67e2c9435705ccc5a994af6a9984a0a496d Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 19 12:05:55 2016 +0200 Add anti-aliasing to the shapes. The jaggies were starting to annoy me. Might make the pixmap into a image later just so we can have proper tra= nsparency. commit 8aef9fe603f284572b1c67ca0b5153bf92067023 Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 19 11:23:55 2016 +0200 Fix clamping again. The previous code made not much sense... commit 8737642881dc971e9b1469cae7dd5f9f283787fe Author: Wolthera van Hovell tot Westerflier Date: Fri Aug 19 00:00:28 2016 +0200 Add triangle and elliptical visual selectors and set default to ring+tr= iangle This is a bit finicky still. Also weird bugs with Qt cause flickering w= hen changing widgets, due to having to force them to show. :/ Might need to= think a bit longer about this... Ref T2438 commit fd5f3a2d716b43a4940868f24ea549224391a172 Author: Wolthera van Hovell tot Westerflier Date: Thu Aug 18 12:38:08 2016 +0200 Add mirrored border. This is useful for non-cyclic channels. commit d7a4e7e9175c18de53d89d834ca544f26500517d Author: Wolthera van Hovell tot Westerflier Date: Thu Aug 18 02:19:10 2016 +0200 Implement rectangle border Not too useful and actually a little slow, but good practice. commit 20febd119bea269cca7c58efa6c05f592eee4fcd Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 21:54:38 2016 +0200 Add KoColorSetWidget, and KoColorPatches for current/previous color Also rearranged the widget a lot. The KoColorSetWidget is automatically= filled with the first palette in the list(which is, as always, concept coo= kie), and the palette is saved... right now on leave and accept events, whi= ch might not be the most intuitive, but at the least it is saved and loaded= correctly. Neither widget has the color management from the displayrenderer, as th= at would require me editing those directly. I would like an eye on said save/load code. Auditors: rempt commit d9fc35c32ce0886fbeb43c85249af40b4c254b98 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 17:35:32 2016 +0200 Add anti-cursor resetting measures, and add docs. The cursor won't flip about when desaturated, but saturation itself is still very tricky. Either way, outside updates won't affect a thing. commit d09605cbaefe1d65b92ba843ae75eefc7f76daa0 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 16:07:17 2016 +0200 Fix HSV mode Turns out there was an 'undefined' value... Ref T2438 commit 5282f861e57ed94d9224b993b5a81c1913f5fdc1 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 15:39:40 2016 +0200 Do clamping in color space traits properly. Previous version just didn't work. This fixes the HSL output. Ref T2438 commit c6119f6d061b61afb0d8ff240e86bcc21ce5cf4d Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 15:30:50 2016 +0200 Don't manage non-floating-point spaces commit 589b5c645eb276104d2cf804a4ce6a82741be2b0 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 17 12:59:27 2016 +0200 Fix display configuration updating. That's now fully working :) Ref T2438 commit 553efe20ac7ea8eb2f8865cc00779b9b2b736439 Merge: e4b42d2 ffc4d9c Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 20:52:03 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit e4b42d286eea279a22a26494de059ca8ab474ba1 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 20:48:32 2016 +0200 Fix non-painting space deformation By disabling it... this looks a bit odd, might be changed. Ref T2337 commit 0246b4ba3d7d1948e5de80426ca707c2da583350 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 18:58:22 2016 +0200 Enable High range color picking for the visual selector. It has huge issues when using a color space that isn't the displayrende= rer's but I think that can be fixed. Ref T2337 commit 62a4f7c6aea23277d40acd5700ac28b3dada1174 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 18:57:35 2016 +0200 Fix spinbox updating float. Again, could be prettier. Ref T2337 commit ae0fd531f89f9c2bd000de318de9d3bf05c0f3af Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 18:25:25 2016 +0200 Enable typing hdr values into spinbox. This could probably be a little more elegant... Ref 2337 commit a5c0408ae52c26afcca6298ebf6188a04b2aafe9 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 17:30:01 2016 +0200 Make the display color converter of the dualcolor button get updated. This enables the the display color converter on the internal color sele= ctor too. There are still update and range bugs, the range bugs being tricky and = the update bugs being probably due wrong signal being connect, but I am pre= tty pleased with this. Ref T2337 commit ca0a03338f47890197c65d3f47d46c0b28327505 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 15:09:59 2016 +0200 Add HSI and HSY support to the visual color selector. This was mostly an experiment, which was succesful in proving to me that the HSL and HSV functions have issues with non-chromatic values. HSY an= d HSI are more notably slow, so kept HSL as the RGB default. Ref T2337 commit b7a45b003986014da93a05d7f0b88fade41183ce Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 15:08:45 2016 +0200 Clamp normalised values before pouring into pixel. This should prevent roll-overs, but it doesn't fix the bug I was initia= lly trying to fix, which instead seems to be a bugged HSL function. Ref 2337 commit db436ad7efffe95790be93a182254331df03b197 Merge: 00b8d54 a819895 Author: Wolthera van Hovell tot Westerflier Date: Tue Aug 16 12:22:54 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 00b8d54f9fafcb07b2571faff9b1bf0d533006ae Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 21:33:40 2016 +0200 Attempt to further add displayconverter integration... I can't get much further here due the inability for kodualcolorbutton to have a display renderer, due MVC. Fun times... Ref T2337 commit 0eee33995a4c1535d5388007dc51d4586ccbe15f Merge: 0c201bc d07cdb6 Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 17:05:50 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 0c201bc0b79c2e328f79c26ac1b624990cfbc7a5 Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 17:04:54 2016 +0200 Initial implementation displayrenderer Will need to change it now... commit 9c39f81cc1f21a23d33b5714fecd57f1c90f846e Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 15:25:22 2016 +0200 Fix rounding-error wiggles. By not allowing the thing to update it self... Ref T2337 commit c52ca3f46c8bfd5d53385f84a17d1869e3ae403f Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 14:42:22 2016 +0200 Make moving the cursor around more pleasant Ref T2337 commit 5f1619768e77354adfd60d54d63def27fce280da Author: Wolthera van Hovell tot Westerflier Date: Mon Aug 15 13:23:00 2016 +0200 Fix order of Hue, make single-dimension-cursors nicer. Ref 2337 commit 692d4d261de781aaf6901b984639eeedcc1ad967 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 14 19:28:34 2016 +0200 Fix order-error. Ref 2337 commit 9acd7f1558a323957cb336061e747da73c1a809c Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 14 18:19:32 2016 +0200 Fix HSL and HSV Of course, using HSL and HSV brings back our friend the 'wigglyness', s= o I'll need to do something about that in time. Ref T2337 Ref T2438 commit 31931e3a522e4f58735b17b4547c4719b2cfe6d6 Author: Wolthera van Hovell tot Westerflier Date: Sun Aug 14 17:38:32 2016 +0200 Add visual selector shapes. These now work fully for the channels. They give nice squares. I made a base class that only deals with the events and the classes, an= d added a rectangular subclass. This way we can make our circles and wheels= and whatever easily. Ref T2337 Ref T2438 commit e3f78b79cd77c7e1b1fdaf0b59f1780cc9380628 Merge: 273dd04 ebc8a43 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 13 15:01:25 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 273dd04a1cd989c10642294d26b8a776df665bf0 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 13 14:57:12 2016 +0200 Add screen color picking widget. This is a widget with a button that allows you to select anywhere on th= e screen. It's not smart enough yet to recognise Krita windows and canvases= and to select the color managed value, but it is a nice self contained wid= get, which I find pretty impressive already. Ref T2337, T2838 commit ea086782934840da5fea9f58eb0cbd1572f3a327 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 10 23:41:49 2016 +0200 Give spinboxes names, fix order spinboxes, do cleanup. Ref T2337 T2438 commit 37d1a1cc9f201213c77b896401ce022281c5d02e Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 10 16:46:57 2016 +0200 Change spinboxes to numerical spinboxes. Ref T2337 commit 99feb3b812322c2d926d33a7437e6aab66723d93 Merge: 6f18c4c 92c253a Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 10 16:09:58 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 6f18c4c3272a8b5a7eb85febee6b304a18a99553 Author: Wolthera van Hovell tot Westerflier Date: Wed Aug 10 16:05:58 2016 +0200 Make internal color selector dialog possible to do modal mode. So right now, KoDualColorButton has Non-modal mode on the foreground co= lor and modal mode on the background color. Also contains a lot of cleanup, the UI files for example now working properly. Ref T2337 T2438 commit fbdce997fd703106a33ea4918a39e0db42f9f983 Merge: 3839839 6530b6d Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 6 12:47:42 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 38398393973fb993ae0644ba777c5214ba63a2a0 Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 6 12:42:37 2016 +0200 Remove signal compressor, use block signals instead. This makes the updating of the spinboxes much easier. Might be using this method more commonly. Ref T2337, T2438 commit 55350f021cb559ffe823fa5a1d8d170684a494ba Author: Wolthera van Hovell tot Westerflier Date: Sat Aug 6 01:16:17 2016 +0200 Move KoDualColorButton, attach internal color selector. It doesn't crash, it updates, gets updated, can select colors, wide gam= ut colors, changes configuration based on selected color's color space... It still needs to be cleaned up and = have fluid updating. Also 90% of the rest of the selector, but I first want to get this updating slot signal mess cl= ean. Can I keep using QObject::sender()? It's making my life very easy. Auditors: rempt Ref T2337, T2438 commit 6d336838602b0ad25ebb35ed17d118b6ed38f588 Author: Wolthera van Hovell tot Westerflier Date: Thu Jul 28 18:04:40 2016 +0200 Add very simple 'colorselection' dialog with a widget containing spinbo= xes. Right now the spinbox widget is able to adapt itself to all colorspaces= , and having it as a separate widget makes it into a nice building block for other uses= too. I can't actually connect this to anything, because all our color button= s seem to be K and Ko, so that will be the big task tomorrow... Ref: T2337, T2438 Auditors: rempt commit 7ce94758d0e459a86fd2eb9f75066322a78e98aa Merge: 38c4fc3 9ed50d1 Author: Wolthera van Hovell tot Westerflier Date: Wed Jul 27 22:21:40 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 38c4fc32021af778b9446a05502c885087bc0ff2 Merge: 5477611 e308ed0 Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 28 17:46:16 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 54776118b78a3f32b408de25f9c7b3532630b5df Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 28 17:43:20 2016 +0200 Add rant why per-shot looks won't work after wasting afternoon on it. The tl;dr is that OCIO's documentation is extremely vague. Ref T2337 commit a3b224b6958db0c31a2df4ba47d19d87bf9f9833 Author: Wolthera van Hovell tot Westerflier Date: Fri Jun 24 13:16:01 2016 +0200 Fix loading of default gamut warning color. Always set the color space of the kocolor, kids. ref T2337 commit 652405d3acd67d4e87d788d0b77fb67768a5cc3b Author: Wolthera van Hovell tot Westerflier Date: Fri Jun 24 12:54:17 2016 +0200 Add adaptation state slider. This allows you to set whether or not to adapt the white point, that is, to set the white point to the screen white(full slider) or to convert a= ll whiteson screen to the white point of the profile when using absolute co= lorimetric as intent. This is useful to simulate paper-colour. Ref T2337 commit aea525ca6dc10b6867153da52fcf215a80adc0ba Author: Wolthera van Hovell tot Westerflier Date: Fri Jun 24 10:32:37 2016 +0200 Fix builds on gcc 6 commit 67f4e5a21f873f5a3d08d3bb90250cb5b5806e2b Merge: 519f9c1 159a612 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 22:00:22 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 519f9c1fbe43edd6922b0cc5ef4ed85f17fd6dfc Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 19:49:56 2016 +0200 Add option to set default Proofing Options. These will work for images with no proofing options, so, old loaded ima= ges and new images. With this it is feature complete, and people can start = testing. Ref T2337 Ref T1238 commit 062db74d24fb7e656e8a06cbddde560ab03166b6 Merge: 2e057e7 7625539 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 15:16:54 2016 +0200 Merge branch 'master' into krita-testing-wolthera commit 2e057e7a5339c3e3657fef562bbe716c672805b4 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 15:15:24 2016 +0200 Clean up all the debug messages. It's... quieter in the terminal now. Ref T2337 commit 7ff7e60b5f423cdbeaa4089d8a6e7b2cd33129ca Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 15:01:02 2016 +0200 Cleanup: Make projection color a defined tag. commit 604efc8ddb21d38ad8a040b19ac7fa33cfe2e8d9 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 14:50:20 2016 +0200 Not sure if this isn't the correct code instead... Ref T2337 commit 7c669703ff0c7fdf755d8070537c339bbcb02533 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 14:42:04 2016 +0200 Load embedded proofing profiles if they exist, and add them to the prof= ile registery. Needs testing for obvious reasons. Ref T2337 commit 119906b23bf0e1a3b8acfaf5828cdfcbaa92e77d Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 14:27:07 2016 +0200 Add embedding of the proofing profile. This is so that we can later unembed them. Ref T2337 commit 9ef1dad773605e32d7018ccf7a90c1817d430d89 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 14:15:47 2016 +0200 Load Warning Colors properly from file. Now the out of gamut warning can be written into file as XML and loaded from file as XML. Ref T2337 commit 6a57cf08fb170e4d32341ede0f3733be3ab1f37e Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 13:49:49 2016 +0200 Fix naming conventions. I was using gamut warnings/alarms, and softproofing and soft proofing. The standard is (Out of )Gamut Warnings and Soft Proofing. Ref T2337 commit 4faa8b574da039d9dc86f099841bb901495e19a9 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 23 13:37:49 2016 +0200 Disable softproofing in floating point spaces. There's a bunch of little niggling bugs that crop up when soft proofing in floating point spaces, amongst which the inability of the proofing mechanism to see floating point values higher than 1.0 fall outside of the gamut of the color space, let alone recognising whether it can go inside the gamut of the proofing space. See also http://ninedegreesbelow.com/bug-reports/soft-proofing-problems= .html For now, it's best to disable softproofing on floating point spaces. Might need a more official check, though. Ref 2337 commit 91d7da8c41c4200729e87f98269fdf011422bb07 Author: Wolthera van Hovell tot Westerflier Date: Wed Jun 22 16:26:52 2016 +0200 Make views smart enough to track softproof/gamutcheck-state. Also add a floating message to say when the softproofing or gamutcheck is turned on in the view. Wording may change. Ref T2337 commit 5c48dd2c12e37ff0a75e098368449d260ff524bc Author: Wolthera van Hovell tot Westerflier Date: Wed Jun 22 16:26:35 2016 +0200 Fix Build commit 6bacfcda6005622669a3f4a47da59a759838797c Author: Wolthera van Hovell tot Westerflier Date: Wed Jun 22 14:45:52 2016 +0200 Add attempt at saving color to xml. This fails due to me not being able to load the xml, due object-bonanza. ref T2337 commit 3bbf025b32ae53ff4601f188901541fcb80f63a7 Author: Wolthera van Hovell tot Westerflier Date: Wed Jun 22 12:49:06 2016 +0200 Intitial saving/loading of config.[unstable] Works, but might change later. commit 1f733e28cb7f87fb4bea5a14159e86c5a5dd852f Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 21 20:21:15 2016 +0200 Refactor the proofing transform system for better caching. This now makes the transform separately from the actual transforming, which means it's easier to cache and to update. Softproofing is now gone from usable to user-friendly. Still needs saving/loading and little setting-bugs fixed. ref T2337 commit 8371c4179b1a8025e727528c5b7ce09ee3562ec9 Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 21 18:20:48 2016 +0200 Enable Gamut color and proofing intent. The image now stored proofing intent, and the monitor intent is the gen= eral rendering intent. This also allows us to set the gamut warning color, however, for updati= ng you currently need to switch profiles as well. I'll make a seperate generateSoftProofingTransform function, to cache the transform better, = so it's easier to update. Ref 2337 commit 9d9ce38079c60ed04a63a2985a9c5ecb08652626 Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 21 14:18:05 2016 +0200 Add softproofing section to image properties menu. Now, the proofing in the image can be changed. Also fixes that ugly little square problem with the kocoloractionpopup = button. Ref T1238, T2337 commit 8d7b4418e798978ed5e4c9fbb28509e7b9e098d4 Merge: e2ee9ff d58645e Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 16 13:28:24 2016 +0200 Merge remote-tracking branch 'origin/master' into krita-testing-wolthera commit e2ee9ff5774c80ebb72c02bc02d8ce7a79ace72f Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 14 15:56:50 2016 +0200 Cache the transform unelegantly. This does cause a significant speed-up, but it's a bit fiddly. Regardless, the speed-up is enough to make this usable. commit f643fc7bc2deb9317b6b7ef299f9d76a0c4e2160 Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 14 14:49:16 2016 +0200 Fix softproofing It's slow again :/ commit cbc91c076310188456980563e3c061ca1a47147f Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 14 12:45:43 2016 +0200 Fix setting softproofing and gamutcheck flags. commit 9ae336ed94207bab7885010720647814c9648e9d Author: Wolthera van Hovell tot Westerflier Date: Tue Jun 14 12:44:50 2016 +0200 Cache the color space engine to make it faster It doesn't fix everything, but it fixes quite a bit. Ref T210 commit d43589016b35ea85943c55ff244e83e6bc5cd15a Author: Wolthera van Hovell tot Westerflier Date: Mon Jun 13 17:59:18 2016 +0200 Add base implementation softproofing with toggles. It doesn't really work yet :/ Ref: T210 Ref: T2337 commit 7de0256960a6021591217ea3935dba1b39143b58 Author: Boudewijn Rempt Date: Sun Jun 12 16:10:31 2016 +0200 Create the proofing transform This doesn't use the caching graph stuff, which is too complex to refactor for now. commit 00efd627af23f28555aa33a78a18fdd133934cf3 Author: Boudewijn Rempt Date: Sun Jun 12 16:10:05 2016 +0200 Add a per-image proofing settings class commit d3bd5375b304dfea9282a9ad581130c7ddf8200a Author: Wolthera van Hovell tot Westerflier Date: Sun Jun 12 14:44:50 2016 +0200 Push work-in-progress proofing commit bb97947abc29f76913924de9f1d2cb4a2762cf80 Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 9 16:42:18 2016 +0200 Fix copy-paste error commit 9ed934a8206ea1e11077f9332252b465c0899d1f Author: Wolthera van Hovell tot Westerflier Date: Thu Jun 9 16:30:09 2016 +0200 Add OCIO Look support. The code is based of that of Blender, as I couldn't figure out how else= to apply looks. The OCIO api wasn't clear about it, nor could I find much = information, but it somewhat works and doesn't crash. Auditors: rempt, dkazakov Ref: T210 commit 2819ad66554f33e229729f8d86eb11a01413f23f Author: Wolthera van Hovell tot Westerflier Date: Wed Jun 8 12:21:25 2016 +0200 Add softproofing to the lcms conversion tests I am not fully sure if I understand the softproofing function, but the = alarm works. M +2 -3 libs/pigment/KoColorConversions.cpp M +5 -0 libs/pigment/KoColorDisplayRendererInterface.cpp M +8 -0 libs/pigment/KoColorDisplayRendererInterface.h M +5 -2 libs/pigment/KoColorSpaceTraits.h M +31 -0 libs/pigment/resources/KoColorSet.cpp M +20 -0 libs/pigment/resources/KoColorSet.h M +8 -1 libs/ui/CMakeLists.txt M +1 -0 libs/ui/KisColorsetChooser.cpp M +1 -0 libs/ui/KisViewManager.cpp M +5 -0 libs/ui/KisViewManager.h M +4 -0 libs/ui/canvas/kis_display_color_converter.cpp M +16 -15 libs/ui/dialogs/kis_dlg_image_properties.cc M +0 -4 libs/ui/dialogs/kis_dlg_image_properties.h A +271 -0 libs/ui/dialogs/kis_dlg_internal_color_selector.cpp [Lic= ense: GPL (v2+)] A +171 -0 libs/ui/dialogs/kis_dlg_internal_color_selector.h [Licen= se: GPL (v2+)] M +35 -22 libs/ui/dialogs/kis_dlg_layer_style.cpp M +41 -24 libs/ui/dialogs/kis_dlg_preferences.cc M +1 -4 libs/ui/dialogs/kis_dlg_preferences.h M +4 -5 libs/ui/forms/wdgautogradient.ui M +12 -12 libs/ui/forms/wdgcolorsettings.ui M +19 -17 libs/ui/forms/wdgdisplaysettings.ui A +237 -0 libs/ui/forms/wdgdlginternalcolorselector.ui M +8 -18 libs/ui/forms/wdggeneralsettings.ui M +29 -11 libs/ui/forms/wdgimageproperties.ui M +15 -16 libs/ui/forms/wdgnewimage.ui M +31 -26 libs/ui/forms/wdgpaintactioneditor.ui M +10 -16 libs/ui/kis_autogradient.cc M +2 -2 libs/ui/kis_autogradient.h M +23 -8 libs/ui/kis_control_frame.cpp M +4 -0 libs/ui/kis_control_frame.h M +19 -1 libs/ui/kis_custom_pattern.cc M +22 -5 libs/ui/kis_popup_palette.cpp M +2 -1 libs/ui/kis_popup_palette.h M +8 -9 libs/ui/layerstyles/WdgColorOverlay.ui M +6 -7 libs/ui/layerstyles/WdgSatin.ui M +13 -14 libs/ui/layerstyles/WdgStroke.ui M +7 -8 libs/ui/layerstyles/wdgBevelAndEmboss.ui M +8 -9 libs/ui/layerstyles/wdgInnerGlow.ui M +6 -7 libs/ui/layerstyles/wdgdropshadow.ui M +6 -12 libs/ui/recorder/kis_recorded_paint_action_editor.cc M +0 -2 libs/ui/recorder/kis_recorded_paint_action_editor.h R +63 -12 libs/ui/widgets/KoDualColorButton.cpp [from: libs/widgets/Ko= DualColorButton.cpp - 076% similarity] R +22 -3 libs/ui/widgets/KoDualColorButton.h [from: libs/widgets/KoDu= alColorButton.h - 087% similarity] A +340 -0 libs/ui/widgets/kis_color_button.cpp [License: LGPL (v2+= )] A +124 -0 libs/ui/widgets/kis_color_button.h [License: LGPL (v2+)] R +0 -0 libs/ui/widgets/kis_color_input.cpp [from: plugins/dockers/s= pecificcolorselector/kis_color_input.cc - 100% similarity] R +10 -9 libs/ui/widgets/kis_color_input.h [from: plugins/dockers/spe= cificcolorselector/kis_color_input.h - 077% similarity] M +5 -3 libs/ui/widgets/kis_custom_image_widget.cc A +269 -0 libs/ui/widgets/kis_screen_color_picker.cpp [License: GP= L (v2+)] A +78 -0 libs/ui/widgets/kis_screen_color_picker.h [License: GPL = (v2+)] A +241 -0 libs/ui/widgets/kis_spinbox_color_selector.cpp [License:= GPL (v2+)] A +59 -0 libs/ui/widgets/kis_spinbox_color_selector.h [License: G= PL (v2+)] A +1602 -0 libs/ui/widgets/kis_visual_color_selector.cpp [License: = GPL (v2+)] A +447 -0 libs/ui/widgets/kis_visual_color_selector.h [License: GP= L (v2+)] M +0 -1 libs/widgets/CMakeLists.txt M +30 -3 libs/widgets/KoColorPatch.cpp M +16 -0 libs/widgets/KoColorPatch.h M +50 -3 libs/widgets/KoColorSetWidget.cpp M +9 -0 libs/widgets/KoColorSetWidget.h M +9 -0 libs/widgets/KoColorSetWidget_p.h M +17 -4 libs/widgets/KoEditColorSetDialog.cpp M +10 -6 plugins/dockers/animation/onion_skins_docker.cpp M +9 -14 plugins/dockers/animation/onion_skins_docker.ui M +15 -9 plugins/dockers/digitalmixer/digitalmixer_dock.cc M +2 -1 plugins/dockers/digitalmixer/digitalmixer_dock.h M +1 -0 plugins/dockers/palettedocker/palettedocker_dock.cpp M +46 -21 plugins/dockers/palettedocker/wdgpalettedock.ui M +5 -1 plugins/dockers/specificcolorselector/CMakeLists.txt M +5 -5 plugins/dockers/specificcolorselector/kis_specific_color_sel= ector_widget.cc M +32 -1 plugins/extensions/layersplit/dlg_layersplit.cpp M +6 -1 plugins/extensions/layersplit/dlg_layersplit.h M +5 -1 plugins/extensions/layersplit/layersplit.cpp M +21 -2 plugins/extensions/layersplit/wdg_layersplit.ui M +17 -9 plugins/filters/colors/kis_wdg_color_to_alpha.cpp M +2 -2 plugins/filters/colors/kis_wdg_color_to_alpha.h M +9 -10 plugins/filters/colors/wdgcolortoalphabase.ui M +7 -5 plugins/filters/indexcolors/kiswdgindexcolors.cpp M +2 -2 plugins/filters/indexcolors/kiswdgindexcolors.h M +4 -4 plugins/generators/pattern/wdgpatternoptions.ui M +1 -1 plugins/generators/solid/colorgenerator.cpp M +6 -3 plugins/generators/solid/kis_wdg_color.cpp M +4 -1 plugins/generators/solid/kis_wdg_color.h M +3 -3 plugins/generators/solid/wdgcoloroptions.ui M +7 -3 plugins/impex/jpeg/kis_jpeg_export.cc M +9 -9 plugins/impex/jpeg/kis_wdg_options_jpeg.ui M +7 -3 plugins/impex/png/kis_png_export.cc M +5 -5 plugins/impex/png/kis_wdg_options_png.ui http://commits.kde.org/krita/93ef7c8ef97e3ba5a1349ba38408269205a9d2b8 diff --git a/libs/pigment/KoColorConversions.cpp b/libs/pigment/KoColorConv= ersions.cpp index 0a00c33..085033a 100644 --- a/libs/pigment/KoColorConversions.cpp +++ b/libs/pigment/KoColorConversions.cpp @@ -382,9 +382,7 @@ void RGBToHSL(float r, float g, float b, float *h, floa= t *s, float *l) *h =3D (r =3D=3D m ? 3.0 + g2 : 5.0 - r2); = *h *=3D 60; - if (*h =3D=3D 360.) { - *h =3D 0; - } + *h =3D fmod(*h, 360.0); } = void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b) @@ -403,6 +401,7 @@ void HSLToRGB(float h, float sl, float l, float *r, flo= at *g, float *b) = m =3D l + l - v; sv =3D (v - m) / v; + h =3D fmod(h, 360.0); h /=3D 60.0; sextant =3D static_cast(h); fract =3D h - sextant; diff --git a/libs/pigment/KoColorDisplayRendererInterface.cpp b/libs/pigmen= t/KoColorDisplayRendererInterface.cpp index a0b42b1..fb6b0a9 100644 --- a/libs/pigment/KoColorDisplayRendererInterface.cpp +++ b/libs/pigment/KoColorDisplayRendererInterface.cpp @@ -78,3 +78,8 @@ qreal KoDumbColorDisplayRenderer::maxVisibleFloatValue(co= nst KoChannelInfo *chan Q_ASSERT(chaninfo); return chaninfo->getUIMax(); } + +const KoColorSpace* KoDumbColorDisplayRenderer::getPaintingColorSpace() co= nst +{ + return KoColorSpaceRegistry::instance()->rgb8(); +} diff --git a/libs/pigment/KoColorDisplayRendererInterface.h b/libs/pigment/= KoColorDisplayRendererInterface.h index e52e01f..2e97476 100644 --- a/libs/pigment/KoColorDisplayRendererInterface.h +++ b/libs/pigment/KoColorDisplayRendererInterface.h @@ -80,6 +80,12 @@ public: */ virtual qreal maxVisibleFloatValue(const KoChannelInfo *chaninfo) cons= t =3D 0; = + /** + * @brief getColorSpace + * @return the painting color space, this is useful for determining th= e transform. + */ + virtual const KoColorSpace* getPaintingColorSpace() const =3D 0; + Q_SIGNALS: void displayConfigurationChanged(); = @@ -103,6 +109,8 @@ public: virtual qreal minVisibleFloatValue(const KoChannelInfo *chaninfo) cons= t; virtual qreal maxVisibleFloatValue(const KoChannelInfo *chaninfo) cons= t; = + virtual const KoColorSpace* getPaintingColorSpace() const; + static KoColorDisplayRendererInterface* instance(); }; = diff --git a/libs/pigment/KoColorSpaceTraits.h b/libs/pigment/KoColorSpaceT= raits.h index 1122353..73fec60 100644 --- a/libs/pigment/KoColorSpaceTraits.h +++ b/libs/pigment/KoColorSpaceTraits.h @@ -157,9 +157,12 @@ struct KoColorSpaceTrait { Q_ASSERT((int)values.count() =3D=3D (int)channels_nb); channels_type c; for (uint i =3D 0; i < channels_nb; i++) { - c =3D (channels_type) - ((float)KoColorSpaceMathsTraits::unitVa= lue * values[i]); + float b =3D qBound((float)KoColorSpaceMathsTraits::min, + (float)KoColorSpaceMathsTraits= ::unitValue * values[i], + (float)KoColorSpaceMathsTraits= ::max); + c =3D (channels_type)b; nativeArray(pixel)[i] =3D c; + } } inline static void multiplyAlpha(quint8 * pixels, quint8 alpha, qint32= nPixels) { diff --git a/libs/pigment/resources/KoColorSet.cpp b/libs/pigment/resources= /KoColorSet.cpp index d4747e3..524e348 100644 --- a/libs/pigment/resources/KoColorSet.cpp +++ b/libs/pigment/resources/KoColorSet.cpp @@ -137,6 +137,37 @@ qint32 KoColorSet::nColors() return m_colors.count(); } = +qint32 KoColorSet::getIndexClosestColor(KoColor color, bool useGivenColorS= pace) +{ + qint32 closestIndex =3D 0; + quint8 highestPercentage =3D 0; + quint8 testPercentage =3D 0; + KoColor compare =3D color; + for (qint32 i=3D0; idifference(compare= .data(), entry.data())); + if (testPercentage>highestPercentage) + { + closestIndex =3D i; + highestPercentage =3D testPercentage; + } + } + return closestIndex; +} + +QString KoColorSet::closestColorName(KoColor color, bool useGivenColorSpac= e) +{ + int i =3D getIndexClosestColor(color, useGivenColorSpace); + QString name =3D m_colors.at(i).name; + return name; +} + bool KoColorSet::saveToDevice(QIODevice *dev) const { QTextStream stream(dev); diff --git a/libs/pigment/resources/KoColorSet.h b/libs/pigment/resources/K= oColorSet.h index a87d104..af9f436 100644 --- a/libs/pigment/resources/KoColorSet.h +++ b/libs/pigment/resources/KoColorSet.h @@ -85,6 +85,26 @@ public: KoColorSetEntry getColor(quint32 index); qint32 nColors(); = + /** + * @brief getIndexClosestColor + * function that matches the color to all colors in the colorset, and = returns the index + * of the closest match. + * @param color the color you wish to compare. + * @param useGivenColorSpace whether to use the color space of the col= or given + * when the two colors' colorspaces don't match. Else it'll use the en= try's colorspace. + * @return returns the int of the closest match. + */ + qint32 getIndexClosestColor(KoColor color, bool useGivenColorSpace =3D= true); + + /** + * @brief closestColorName + * convenience function to get the name of the closest match. + * @param color + * @param useGivenColorSpace + * @return + */ + QString closestColorName(KoColor color, bool useGivenColorSpace =3D tr= ue); + private: = = diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index 0cb23da..76df00d 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -66,6 +66,7 @@ set(kritaui_LIB_SRCS dialogs/kis_dlg_png_import.cpp dialogs/kis_dlg_import_image_sequence.cpp dialogs/kis_delayed_save_dialog.cpp + dialogs/kis_dlg_internal_color_selector.cpp flake/kis_node_dummies_graph.cpp flake/kis_dummies_facade_base.cpp flake/kis_dummies_facade.cpp @@ -253,7 +254,12 @@ set(kritaui_LIB_SRCS widgets/kis_color_label_selector_widget.cpp widgets/kis_color_filter_combo.cpp widgets/kis_elided_label.cpp - + widgets/kis_spinbox_color_selector.cpp + widgets/kis_screen_color_picker.cpp + widgets/kis_visual_color_selector.cpp + widgets/KoDualColorButton.cpp + widgets/kis_color_input.cpp + widgets/kis_color_button.cpp input/kis_input_manager.cpp input/kis_input_manager_p.cpp input/kis_extended_modifiers_mapper.cpp @@ -455,6 +461,7 @@ ki18n_wrap_ui(kritaui_LIB_SRCS forms/KisDetailsPaneBase.ui forms/KisOpenPaneBase.ui brushhud/kis_dlg_brush_hud_config.ui + forms/wdgdlginternalcolorselector.ui dialogs/kis_delayed_save_dialog.ui input/config/kis_input_configuration_page.ui input/config/kis_edit_profiles_dialog.ui diff --git a/libs/ui/KisColorsetChooser.cpp b/libs/ui/KisColorsetChooser.cpp index 2f730f9..621ffa7 100644 --- a/libs/ui/KisColorsetChooser.cpp +++ b/libs/ui/KisColorsetChooser.cpp @@ -90,6 +90,7 @@ KisColorsetChooser::KisColorsetChooser(QWidget* parent): = QWidget(parent) QSharedPointer adapter(new KoResource= ServerAdapter(rserver)); m_itemChooser =3D new KoResourceItemChooser(adapter, this); m_itemChooser->setItemDelegate(new ColorSetDelegate(this)); + m_itemChooser->showTaggingBar(true); m_itemChooser->setFixedSize(250, 250); m_itemChooser->setRowHeight(30); m_itemChooser->setColumnCount(1); diff --git a/libs/ui/KisViewManager.cpp b/libs/ui/KisViewManager.cpp index 4cfc936..b737b7a 100644 --- a/libs/ui/KisViewManager.cpp +++ b/libs/ui/KisViewManager.cpp @@ -440,6 +440,7 @@ void KisViewManager::setCurrentView(KisView *view) = resourceProvider()->slotImageSizeChanged(); resourceProvider()->slotOnScreenResolutionChanged(); + Q_EMIT viewChanged(); } = = diff --git a/libs/ui/KisViewManager.h b/libs/ui/KisViewManager.h index add5dc8..8657548 100644 --- a/libs/ui/KisViewManager.h +++ b/libs/ui/KisViewManager.h @@ -212,6 +212,11 @@ public Q_SLOTS: Q_SIGNALS: = void floatingMessageRequested(const QString &message, const QString &i= conName); + /** + * @brief viewChanged + * sent out when the view has changed. + */ + void viewChanged(); = private Q_SLOTS: = diff --git a/libs/ui/canvas/kis_display_color_converter.cpp b/libs/ui/canva= s/kis_display_color_converter.cpp index 5fd4b32..a9188d3 100644 --- a/libs/ui/canvas/kis_display_color_converter.cpp +++ b/libs/ui/canvas/kis_display_color_converter.cpp @@ -141,6 +141,10 @@ struct KisDisplayColorConverter::Private return maxValue; } = + virtual const KoColorSpace* getPaintingColorSpace() const { + return m_parent->paintingColorSpace(); + } + private: KisDisplayColorConverter *m_parent; QPointer m_resourceManager; diff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/= kis_dlg_image_properties.cc index 244cb97..ab3b110 100644 --- a/libs/ui/dialogs/kis_dlg_image_properties.cc +++ b/libs/ui/dialogs/kis_dlg_image_properties.cc @@ -68,18 +68,19 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWS= P image, QWidget *parent, = m_page->lblResolutionValue->setText(QLocale().toString(image->xRes()*7= 2, 2)); // XXX: separate values for x & y? = - //Set the canvas projection color: - m_defaultColorAction =3D new KoColorPopupAction(this); - m_defaultColorAction->setCurrentColor(m_image->defaultProjectionColor(= )); - m_defaultColorAction->setToolTip(i18n("Change the background color of = the image")); - m_page->bnBackgroundColor->setDefaultAction(m_defaultColorAction); + //Set the canvas projection color: backgroundColor + KoColor background =3D m_image->defaultProjectionColor(); + background.setOpacity(1.0); + m_page->bnBackgroundColor->setColor(background); + m_page->sldBackgroundColor->setRange(0.0,1.0,2); + m_page->sldBackgroundColor->setSingleStep(0.05); + m_page->sldBackgroundColor->setValue(m_image->defaultProjectionColor()= .opacityF()); = KisSignalCompressor *compressor =3D new KisSignalCompressor(500 /* ms = */, KisSignalCompressor::POSTPONE, this); - connect(m_defaultColorAction, SIGNAL(colorChanged(const KoColor&)), co= mpressor, SLOT(start())); + connect(m_page->bnBackgroundColor, SIGNAL(changed(KoColor)), compresso= r, SLOT(start())); + connect(m_page->sldBackgroundColor, SIGNAL(valueChanged(qreal)), compr= essor, SLOT(start())); connect(compressor, SIGNAL(timeout()), this, SLOT(setCurrentColor())); = - connect(m_defaultColorAction, SIGNAL(colorChanged(const KoColor&)), th= is, SLOT(setCurrentColor())); - //Set the color space m_page->colorSpaceSelector->setCurrentColorSpace(image->colorSpace()); = @@ -91,17 +92,15 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWS= P image, QWidget *parent, = m_page->ckbBlackPointComp->setChecked(m_proofingConfig->conversionFlag= s.testFlag(KoColorConversionTransformation::BlackpointCompensation)); = - m_gamutWarning =3D new KoColorPopupAction(this); - m_gamutWarning->setCurrentColor(m_proofingConfig->warningColor); - m_gamutWarning->setToolTip(i18n("Set color used for warning")); - m_page->gamutAlarm->setDefaultAction(m_gamutWarning); + m_page->gamutAlarm->setColor(m_proofingConfig->warningColor); + m_page->gamutAlarm->setToolTip(i18n("Set color used for warning")); m_page->sldAdaptationState->setMaximum(20); m_page->sldAdaptationState->setMinimum(0); m_page->sldAdaptationState->setValue((int)m_proofingConfig->adaptation= State*20); = KisSignalCompressor *softProofConfigCompressor =3D new KisSignalCompre= ssor(500, KisSignalCompressor::POSTPONE,this); = - connect(m_gamutWarning, SIGNAL(colorChanged(KoColor)), softProofConfig= Compressor, SLOT(start())); + connect(m_page->gamutAlarm, SIGNAL(changed(KoColor)), softProofConfigC= ompressor, SLOT(start())); connect(m_page->proofSpaceSelector, SIGNAL(colorSpaceChanged(const KoC= olorSpace*)), softProofConfigCompressor, SLOT(start())); connect(m_page->cmbIntent, SIGNAL(currentIndexChanged(int)), softProof= ConfigCompressor, SLOT(start())); connect(m_page->ckbBlackPointComp, SIGNAL(stateChanged(int)), softProo= fConfigCompressor, SLOT(start())); @@ -142,7 +141,9 @@ const KoColorSpace * KisDlgImageProperties::colorSpace() = void KisDlgImageProperties::setCurrentColor() { - KisLayerUtils::changeImageDefaultProjectionColor(m_image, m_defaultCol= orAction->currentKoColor()); + KoColor background =3D m_page->bnBackgroundColor->color(); + background.setOpacity(m_page->sldBackgroundColor->value()); + KisLayerUtils::changeImageDefaultProjectionColor(m_image, background); } = void KisDlgImageProperties::setProofingConfig() @@ -153,7 +154,7 @@ void KisDlgImageProperties::setProofingConfig() m_proofingConfig->proofingProfile =3D m_page->proofSpaceSelector->curr= entColorSpace()->profile()->name(); m_proofingConfig->proofingModel =3D m_page->proofSpaceSelector->curren= tColorSpace()->colorModelId().id(); m_proofingConfig->proofingDepth =3D "U8";//default to this - m_proofingConfig->warningColor =3D m_gamutWarning->currentKoColor(); + m_proofingConfig->warningColor =3D m_page->gamutAlarm->color(); m_proofingConfig->adaptationState =3D (double)m_page->sldAdaptationSta= te->value()/20.0; qDebug()<<"set proofing config in properties: "<pro= ofingProfile; m_image->setProofingConfiguration(m_proofingConfig); diff --git a/libs/ui/dialogs/kis_dlg_image_properties.h b/libs/ui/dialogs/k= is_dlg_image_properties.h index 22b0dbb..4c35e89 100644 --- a/libs/ui/dialogs/kis_dlg_image_properties.h +++ b/libs/ui/dialogs/kis_dlg_image_properties.h @@ -24,8 +24,6 @@ #include "ui_wdgimageproperties.h" = class KoColorSpace; -class KoColorPopupAction; - class WdgImageProperties : public QWidget, public Ui::WdgImageProperties { Q_OBJECT @@ -58,8 +56,6 @@ private: = WdgImageProperties * m_page; KisImageWSP m_image; - KoColorPopupAction *m_defaultColorAction; - KoColorPopupAction *m_gamutWarning; KisProofingConfigurationSP m_proofingConfig; }; = diff --git a/libs/ui/dialogs/kis_dlg_internal_color_selector.cpp b/libs/ui/= dialogs/kis_dlg_internal_color_selector.cpp new file mode 100644 index 0000000..8af2254 --- /dev/null +++ b/libs/ui/dialogs/kis_dlg_internal_color_selector.cpp @@ -0,0 +1,271 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ + +#include +#include +#include +#include +#include + +#include "KoColorSpaceRegistry.h" +#include +#include +#include + +#include "kis_signal_compressor.h" +#include "KisViewManager.h" +#include "KoColorDisplayRendererInterface.h" + +#include "kis_spinbox_color_selector.h" + +#include "kis_dlg_internal_color_selector.h" +#include "ui_wdgdlginternalcolorselector.h" +#include "kis_config.h" +#include "kis_config_notifier.h" +#include "kis_color_input.h" + +struct KisDlgInternalColorSelector::Private +{ + bool allowUpdates =3D true; + KoColor currentColor; + KoColor previousColor; + KoColor sRGB =3D KoColor(KoColorSpaceRegistry::instance()->rgb8()); + const KoColorSpace *currentColorSpace; + bool lockUsedCS =3D false; + bool chooseAlpha =3D false; + KisSignalCompressor *compressColorChanges; + const KoColorDisplayRendererInterface *displayRenderer; + KisHexColorInput *hexColorInput; +}; + +KisDlgInternalColorSelector::KisDlgInternalColorSelector(QWidget *parent, = KoColor color, Config config, const QString &caption, const KoColorDisplayR= endererInterface *displayRenderer) + : QDialog(parent) + ,m_d(new Private) +{ + setModal(config.modal); + this->setFocusPolicy(Qt::ClickFocus); + m_ui =3D new Ui_WdgDlgInternalColorSelector(); + m_ui->setupUi(this); + + setWindowTitle(caption); + + m_d->currentColor =3D color; + m_d->currentColorSpace =3D m_d->currentColor.colorSpace(); + m_d->displayRenderer =3D displayRenderer; + + m_ui->spinboxselector->slotSetColor(color); + connect(m_ui->spinboxselector, SIGNAL(sigNewColor(KoColor)), this, SLO= T(slotColorUpdated(KoColor))); + + m_ui->visualSelector->slotSetColor(color); + m_ui->visualSelector->setDisplayRenderer(displayRenderer); + m_ui->visualSelector->setConfig(false, config.modal); + if (config.visualColorSelector) { + connect(m_ui->visualSelector, SIGNAL(sigNewColor(KoColor)), this, = SLOT(slotColorUpdated(KoColor))); + connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_= ui->visualSelector, SLOT(ConfigurationChanged())); + } else { + m_ui->visualSelector->hide(); + } + if (config.screenColorPicker) { + connect(m_ui->screenColorPicker, SIGNAL(sigNewColorPicked(KoColor)= ),this, SLOT(slotColorUpdated(KoColor))); + } else { + m_ui->screenColorPicker->hide(); + } + //TODO: Add disable signal as well. Might be not necessary...? + KisConfig cfg; + QString paletteName =3D cfg.readEntry("internal_selector_active_color_= set", QString()); + KoResourceServer* rServer =3D KoResourceServerProvider::in= stance()->paletteServer(false); + KoColorSet *savedPal =3D rServer->resourceByName(paletteName); + if (savedPal) { + m_ui->paletteBox->setColorSet(savedPal); + } else { + savedPal =3D rServer->resources().first(); + if (savedPal) { + m_ui->paletteBox->setColorSet(savedPal); + } + } + if (config.paletteBox) { + connect(m_ui->paletteBox, SIGNAL(colorChanged(KoColor,bool)), this= , SLOT(slotColorUpdated(KoColor))); + m_ui->paletteBox->setDisplayRenderer(displayRenderer); + } else { + m_ui->paletteBox->hide(); + } + + if (config.prevNextButtons) { + m_ui->currentColor->setColor(m_d->currentColor); + m_ui->currentColor->setDisplayRenderer(displayRenderer); + m_ui->previousColor->setColor(m_d->currentColor); + m_ui->previousColor->setDisplayRenderer(displayRenderer); + connect(this, SIGNAL(accepted()), this, SLOT(setPreviousColor())); + connect(m_ui->previousColor, SIGNAL(triggered(KoColorPatch*)), SLO= T(slotSetColorFromPatch(KoColorPatch*))); + } else { + m_ui->currentColor->hide(); + m_ui->previousColor->hide(); + } + + if (config.hexInput) { + m_d->sRGB.fromKoColor(m_d->currentColor); + m_d->hexColorInput =3D new KisHexColorInput(this, &m_d->sRGB); + m_d->hexColorInput->update(); + connect(m_d->hexColorInput, SIGNAL(updated()), SLOT(slotSetColorFr= omHex())); + m_ui->rightPane->addWidget(m_d->hexColorInput); + m_d->hexColorInput->setToolTip(i18n("This is a hexcode input, for = webcolors. It can only get colors in the sRGB space.")); + } + + connect(this, SIGNAL(signalForegroundColorChosen(KoColor)), this, SLOT= (slotLockSelector())); + m_d->compressColorChanges =3D new KisSignalCompressor(100 /* ms */, Ki= sSignalCompressor::POSTPONE, this); + connect(m_d->compressColorChanges, SIGNAL(timeout()), this, SLOT(endUp= dateWithNewColor())); + + connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +} + +KisDlgInternalColorSelector::~KisDlgInternalColorSelector() +{ + delete m_ui; + //TODO: Does the scoped pointer also need to be deleted??? +} + +void KisDlgInternalColorSelector::slotColorUpdated(KoColor newColor) +{ + //if the update did not come from this selector... + if (m_d->allowUpdates || QObject::sender() =3D=3D this->parent()) { + if (m_d->lockUsedCS){ + newColor.convertTo(m_d->currentColorSpace); + m_d->currentColor =3D newColor; + } else { + m_d->currentColor =3D newColor; + } + updateAllElements(QObject::sender()); + } +} + +void KisDlgInternalColorSelector::colorSpaceChanged(const KoColorSpace *cs) +{ + if (cs =3D=3D m_d->currentColorSpace) { + return; + } + + m_d->currentColorSpace =3D KoColorSpaceRegistry::instance()->colorSpac= e(cs->colorModelId().id(), cs->colorDepthId().id(), cs->profile()); + m_ui->spinboxselector->slotSetColorSpace(m_d->currentColorSpace); + m_ui->visualSelector->slotsetColorSpace(m_d->currentColorSpace); + +} + +void KisDlgInternalColorSelector::lockUsedColorSpace(const KoColorSpace *c= s) +{ + colorSpaceChanged(cs); + m_d->lockUsedCS =3D true; +} + +void KisDlgInternalColorSelector::setDisplayRenderer(const KoColorDisplayR= endererInterface *displayRenderer) +{ + if (displayRenderer) { + m_d->displayRenderer =3D displayRenderer; + m_ui->visualSelector->setDisplayRenderer(displayRenderer); + m_ui->currentColor->setDisplayRenderer(displayRenderer); + m_ui->previousColor->setDisplayRenderer(displayRenderer); + m_ui->paletteBox->setDisplayRenderer(displayRenderer); + } else { + m_d->displayRenderer =3D KoDumbColorDisplayRenderer::instance(); + } +} + +KoColor KisDlgInternalColorSelector::getModalColorDialog(const KoColor col= or, QWidget* parent, QString caption) +{ + Config config =3D Config(); + KisDlgInternalColorSelector dialog(parent, color, config, caption); + dialog.exec(); + return dialog.getCurrentColor(); +} + +KoColor KisDlgInternalColorSelector::getCurrentColor() +{ + return m_d->currentColor; +} + +void KisDlgInternalColorSelector::chooseAlpha(bool chooseAlpha) +{ + m_d->chooseAlpha =3D chooseAlpha; +} + +void KisDlgInternalColorSelector::slotConfigurationChanged() +{ + //m_d->canvas->displayColorConverter()-> + //slotColorSpaceChanged(m_d->canvas->image()->colorSpace()); +} + +void KisDlgInternalColorSelector::slotLockSelector() +{ + m_d->allowUpdates =3D false; +} + +void KisDlgInternalColorSelector::setPreviousColor() +{ + m_d->previousColor =3D m_d->currentColor; + KisConfig cfg; + if (m_ui->paletteBox->colorSet()) { + cfg.writeEntry("internal_selector_active_color_set", m_ui->palette= Box->colorSet()->name()); + } +} + +void KisDlgInternalColorSelector::updateAllElements(QObject *source) +{ + //update everything!!! + if (source !=3D m_ui->spinboxselector) { + m_ui->spinboxselector->slotSetColor(m_d->currentColor); + } + if (source !=3D m_ui->visualSelector) { + m_ui->visualSelector->slotSetColor(m_d->currentColor); + } + + if (source !=3D m_d->hexColorInput) { + m_d->sRGB.fromKoColor(m_d->currentColor); + m_d->hexColorInput->update(); + } + + m_ui->previousColor->setColor(m_d->previousColor); + + m_ui->currentColor->setColor(m_d->currentColor); + + if (source !=3D this->parent()) { + emit(signalForegroundColorChosen(m_d->currentColor)); + m_d->compressColorChanges->start(); + } +} + + +void KisDlgInternalColorSelector::endUpdateWithNewColor() +{ + m_d->allowUpdates =3D true; +} + +void KisDlgInternalColorSelector::focusInEvent(QFocusEvent *) +{ + //setPreviousColor(); +} + +void KisDlgInternalColorSelector::slotSetColorFromPatch(KoColorPatch* patc= h) +{ + slotColorUpdated(patch->color()); +} + +void KisDlgInternalColorSelector::slotSetColorFromHex() +{ + slotColorUpdated(m_d->sRGB); +} + diff --git a/libs/ui/dialogs/kis_dlg_internal_color_selector.h b/libs/ui/di= alogs/kis_dlg_internal_color_selector.h new file mode 100644 index 0000000..07fc5f4 --- /dev/null +++ b/libs/ui/dialogs/kis_dlg_internal_color_selector.h @@ -0,0 +1,171 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ + +#ifndef KISINTERNALCOLORSELECTOR_H +#define KISINTERNALCOLORSELECTOR_H + +#include "kritaui_export.h" +#include "KoColor.h" +#include "KoColorSpace.h" +#include "KoColorDisplayRendererInterface.h" + +#include + +#include "ui_wdgdlginternalcolorselector.h" + +/** + * @brief The KisInternalColorSelector class + * + * A non-modal color selector dialog that is not a plugin and can thus be = used for filters. + */ +class KRITAUI_EXPORT KisDlgInternalColorSelector : public QDialog +{ + Q_OBJECT +public: + struct Config + { + Config() : + modal(true), + visualColorSelector(true), + paletteBox(true), + screenColorPicker(true), + prevNextButtons(true), + hexInput(true), + useAlpha(false){} + bool modal; + bool visualColorSelector; + bool paletteBox; + bool screenColorPicker; + bool prevNextButtons; + bool hexInput; + bool useAlpha; + }; + + KisDlgInternalColorSelector(QWidget* parent, KoColor color, Config con= fig, const QString &caption, const KoColorDisplayRendererInterface *display= Renderer =3D KoDumbColorDisplayRenderer::instance()); + ~KisDlgInternalColorSelector(); + + /** + * @brief slotColorSpaceChanged + * Color space has changed, use this dialog to change the colorspace. + */ + void colorSpaceChanged(const KoColorSpace *cs); + + /** + * @brief lockUsedColorSpace + * Lock the used colorspace of this selector. + * @param cs + */ + void lockUsedColorSpace(const KoColorSpace *cs); + + /** + * @brief setDisplayRenderer + * Set the display renderer. This is necessary for HDR color manage su= pport. + * @param displayRenderer + */ + void setDisplayRenderer(const KoColorDisplayRendererInterface *display= Renderer); + + /** + * @brief getModalColorDialog + * Excecute this dialog modally. The function returns + * the KoColor you want. + * @param color - The current color. Make sure this is in the color sp= ace you want your + * end color to be in. + * @param chooseAlpha - Whether or not the alpha-choosing functionalit= y should be used. + */ + static KoColor getModalColorDialog(const KoColor color, QWidget* paren= t =3D Q_NULLPTR, QString caption =3D QString()); + + /** + * @brief getCurrentColor + * @return gives currently active color; + */ + KoColor getCurrentColor(); + + void chooseAlpha(bool chooseAlpha); + +Q_SIGNALS: + /** + * @brief signalForegroundColorChosen + * The most important signal. This will sent out when a color has been= picked from the selector. + * There will be a small delay to make sure that the selector causes t= oo many updates. + * + * Do not connect this to slotColorUpdated. + * @param color The new color chosen + */ + + void signalForegroundColorChosen(KoColor color); +public Q_SLOTS: + /** + * @brief slotColorUpdated + * Very important slot. Is connected to krita's resources to make sure= it has + * the currently active color. It's very important that this function = is able to understand + * when the signal came from itself. + * @param newColor This is the new color. + */ + void slotColorUpdated(KoColor newColor); +private Q_SLOTS: + + /** + * @brief slotLockSelector + * This slot will prevent the color from being updated. + */ + void slotLockSelector(); + + /** + * @brief slotConfigurationChanged + * Wrapper slot for changes to the colorspace. + */ + void slotConfigurationChanged(); + + void endUpdateWithNewColor(); + + /** + * @brief setPreviousColor + * triggered when the dialog is either accepted or hidden. + */ + void setPreviousColor(); + + /** + * @brief slotSetColorFromPatch + * update current color from kocolorpatch. + * @param patch + */ + void slotSetColorFromPatch(KoColorPatch* patch); + + /** + * @brief slotSetColorFromHex + * Update from the hex color input. + */ + void slotSetColorFromHex(); + + +private: + Ui_WdgDlgInternalColorSelector *m_ui; //the UI + struct Private; //The private struct + const QScopedPointer m_d; //the private pointer + + /** + * @brief updateAllElements + * Updates each widget with the new element, and if it's responsible f= or the update sents + * a signal out that there's a new color. + */ + void updateAllElements(QObject *source); + + virtual void focusInEvent(QFocusEvent *); +}; + +#endif // KISINTERNALCOLORSELECTOR_H diff --git a/libs/ui/dialogs/kis_dlg_layer_style.cpp b/libs/ui/dialogs/kis_= dlg_layer_style.cpp index 9de074c..c7bd978 100644 --- a/libs/ui/dialogs/kis_dlg_layer_style.cpp +++ b/libs/ui/dialogs/kis_dlg_layer_style.cpp @@ -31,6 +31,7 @@ = = #include +#include #include = #include "kis_config.h" @@ -619,10 +620,10 @@ BevelAndEmboss::BevelAndEmboss(Contour *contour, Text= ure *texture, QWidget *pare connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(config= Changed())); connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged= ())); connect(ui.cmbHighlightMode, SIGNAL(currentIndexChanged(int)), SIGNAL(= configChanged())); - connect(ui.bnHighlightColor, SIGNAL(changed(QColor)), SIGNAL(configCha= nged())); + connect(ui.bnHighlightColor, SIGNAL(changed(KoColor)), SIGNAL(configCh= anged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged= ())); connect(ui.cmbShadowMode, SIGNAL(currentIndexChanged(int)), SIGNAL(con= figChanged())); - connect(ui.bnShadowColor, SIGNAL(changed(QColor)), SIGNAL(configChange= d())); + connect(ui.bnShadowColor, SIGNAL(changed(KoColor)), SIGNAL(configChang= ed())); connect(ui.intOpacity2, SIGNAL(valueChanged(int)), SIGNAL(configChange= d()));; = // Contour @@ -664,10 +665,13 @@ void BevelAndEmboss::setBevelAndEmboss(const psd_laye= r_effects_bevel_emboss *bev // ui.cmbContour; ui.chkAntiAliased->setChecked(bevelAndEmboss->glossAntiAliased()); ui.cmbHighlightMode->selectCompositeOp(KoID(bevelAndEmboss->highlightB= lendMode())); - ui.bnHighlightColor->setColor(bevelAndEmboss->highlightColor()); + KoColor highlightshadow(KoColorSpaceRegistry::instance()->rgb8()); + highlightshadow.fromQColor(bevelAndEmboss->highlightColor()); + ui.bnHighlightColor->setColor(highlightshadow); ui.intOpacity->setValue(bevelAndEmboss->highlightOpacity()); ui.cmbShadowMode->selectCompositeOp(KoID(bevelAndEmboss->shadowBlendMo= de())); - ui.bnShadowColor->setColor(bevelAndEmboss->shadowColor()); + highlightshadow.fromQColor(bevelAndEmboss->shadowColor()); + ui.bnShadowColor->setColor(highlightshadow); ui.intOpacity2->setValue(bevelAndEmboss->shadowOpacity()); = // FIXME: curve editing @@ -696,10 +700,10 @@ void BevelAndEmboss::fetchBevelAndEmboss(psd_layer_ef= fects_bevel_emboss *bevelAn bevelAndEmboss->setAltitude(ui.intAltitude->value()); bevelAndEmboss->setGlossAntiAliased(ui.chkAntiAliased->isChecked()); bevelAndEmboss->setHighlightBlendMode(ui.cmbHighlightMode->selectedCom= positeOp().id()); - bevelAndEmboss->setHighlightColor(ui.bnHighlightColor->color()); + bevelAndEmboss->setHighlightColor(ui.bnHighlightColor->color().toQColo= r()); bevelAndEmboss->setHighlightOpacity(ui.intOpacity->value()); bevelAndEmboss->setShadowBlendMode(ui.cmbShadowMode->selectedComposite= Op().id()); - bevelAndEmboss->setShadowColor(ui.bnShadowColor->color()); + bevelAndEmboss->setShadowColor(ui.bnShadowColor->color().toQColor()); bevelAndEmboss->setShadowOpacity(ui.intOpacity2->value()); = // FIXME: curve editing @@ -792,21 +796,23 @@ ColorOverlay::ColorOverlay(QWidget *parent) = connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(co= nfigChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged= ())); - connect(ui.bnColor, SIGNAL(changed(QColor)), SIGNAL(configChanged())); + connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); } = void ColorOverlay::setColorOverlay(const psd_layer_effects_color_overlay *= colorOverlay) { ui.cmbCompositeOp->selectCompositeOp(KoID(colorOverlay->blendMode())); ui.intOpacity->setValue(colorOverlay->opacity()); - ui.bnColor->setColor(colorOverlay->color()); + KoColor color(KoColorSpaceRegistry::instance()->rgb8()); + color.fromQColor(colorOverlay->color()); + ui.bnColor->setColor(color); } = void ColorOverlay::fetchColorOverlay(psd_layer_effects_color_overlay *colo= rOverlay) const { colorOverlay->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id= ()); colorOverlay->setOpacity(ui.intOpacity->value()); - colorOverlay->setColor(ui.bnColor->color()); + colorOverlay->setColor(ui.bnColor->color().toQColor()); } = = @@ -843,7 +849,7 @@ DropShadow::DropShadow(Mode mode, QWidget *parent) // connect everything to configChanged() signal connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(co= nfigChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged= ())); - connect(ui.bnColor, SIGNAL(changed(QColor)), SIGNAL(configChanged())); + connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); = connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged(= ))); connect(ui.intAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged()= )); @@ -897,7 +903,9 @@ void DropShadow::setShadow(const psd_layer_effects_shad= ow_common *shadow) { ui.cmbCompositeOp->selectCompositeOp(KoID(shadow->blendMode())); ui.intOpacity->setValue(shadow->opacity()); - ui.bnColor->setColor(shadow->color()); + KoColor color(KoColorSpaceRegistry::instance()->rgb8()); + color.fromQColor(shadow->color()); + ui.bnColor->setColor(color); = ui.dialAngle->setValue(shadow->angle()); ui.intAngle->setValue(shadow->angle()); @@ -925,7 +933,7 @@ void DropShadow::fetchShadow(psd_layer_effects_shadow_c= ommon *shadow) const { shadow->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id()); shadow->setOpacity(ui.intOpacity->value()); - shadow->setColor(ui.bnColor->color()); + shadow->setColor(ui.bnColor->color().toQColor()); = shadow->setAngle(ui.dialAngle->value()); shadow->setUseGlobalLight(ui.chkUseGlobalLight->isChecked()); @@ -1092,7 +1100,7 @@ InnerGlow::InnerGlow(Mode mode, KisCanvasResourceProv= ider *resourceProvider, QWi connect(ui.intNoise, SIGNAL(valueChanged(int)), SIGNAL(configChanged()= )); = connect(ui.radioColor, SIGNAL(toggled(bool)), SIGNAL(configChanged())); - connect(ui.bnColor, SIGNAL(changed(QColor)), SIGNAL(configChanged())); + connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); connect(ui.radioGradient, SIGNAL(toggled(bool)), SIGNAL(configChanged(= ))); connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradient*)), = SIGNAL(configChanged())); = @@ -1121,7 +1129,9 @@ void InnerGlow::setConfig(const psd_layer_effects_glo= w_common *config) ui.intNoise->setValue(config->noise()); = ui.radioColor->setChecked(config->fillType() =3D=3D psd_fill_solid_col= or); - ui.bnColor->setColor(config->color()); + KoColor color(KoColorSpaceRegistry::instance()->rgb8()); + color.fromQColor(config->color()); + ui.bnColor->setColor(color); ui.radioGradient->setChecked(config->fillType() =3D=3D psd_fill_gradie= nt); = KoAbstractGradient *gradient =3D fetchGradientLazy( @@ -1164,7 +1174,7 @@ void InnerGlow::fetchConfig(psd_layer_effects_glow_co= mmon *config) const config->setFillType(psd_fill_gradient); } = - config->setColor(ui.bnColor->color()); + config->setColor(ui.bnColor->color().toQColor()); config->setGradient(GradientPointerConverter::resourceToStyle(ui.cmbGr= adient->gradient())); config->setTechnique((psd_technique_type)ui.cmbTechnique->currentIndex= ()); config->setSpread(ui.intChoke->value()); @@ -1251,7 +1261,7 @@ Satin::Satin(QWidget *parent) connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChang= ed(int))); = connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(co= nfigChanged())); - connect(ui.bnColor, SIGNAL(changed(QColor)), SIGNAL(configChanged())); + connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged= ())); = connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged(= ))); @@ -1280,7 +1290,9 @@ void Satin::slotIntAngleChanged(int value) void Satin::setSatin(const psd_layer_effects_satin *satin) { ui.cmbCompositeOp->selectCompositeOp(KoID(satin->blendMode())); - ui.bnColor->setColor(satin->color()); + KoColor color(KoColorSpaceRegistry::instance()->rgb8()); + color.fromQColor(satin->color()); + ui.bnColor->setColor(color); ui.intOpacity->setValue(satin->opacity()); = ui.dialAngle->setValue(satin->angle()); @@ -1301,7 +1313,7 @@ void Satin::fetchSatin(psd_layer_effects_satin *satin= ) const { satin->setBlendMode(ui.cmbCompositeOp->selectedCompositeOp().id()); satin->setOpacity(ui.intOpacity->value()); - satin->setColor(ui.bnColor->color()); + satin->setColor(ui.bnColor->color().toQColor()); = satin->setAngle(ui.dialAngle->value()); = @@ -1345,7 +1357,7 @@ Stroke::Stroke(KisCanvasResourceProvider *resourcePro= vider, QWidget *parent) = connect(ui.cmbFillType, SIGNAL(currentIndexChanged(int)), SIGNAL(confi= gChanged())); = - connect(ui.bnColor, SIGNAL(changed(QColor)), SIGNAL(configChanged())); + connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); = connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradient*)), = SIGNAL(configChanged())); connect(ui.chkReverse, SIGNAL(toggled(bool)), SIGNAL(configChanged())); @@ -1385,8 +1397,9 @@ void Stroke::setStroke(const psd_layer_effects_stroke= *stroke) ui.intOpacity->setValue(stroke->opacity()); = ui.cmbFillType->setCurrentIndex((int)stroke->fillType()); - - ui.bnColor->setColor(stroke->color()); + KoColor color(KoColorSpaceRegistry::instance()->rgb8()); + color.fromQColor(stroke->color()); + ui.bnColor->setColor(color); = KoAbstractGradient *gradient =3D fetchGradientLazy(GradientPointerConverter::styleToResource(stroke= ->gradient()), m_resourceProvider); @@ -1417,7 +1430,7 @@ void Stroke::fetchStroke(psd_layer_effects_stroke *st= roke) const = stroke->setFillType((psd_fill_type)ui.cmbFillType->currentIndex()); = - stroke->setColor(ui.bnColor->color()); + stroke->setColor(ui.bnColor->color().toQColor()); = stroke->setGradient(GradientPointerConverter::resourceToStyle(ui.cmbGr= adient->gradient())); stroke->setReverse(ui.chkReverse->isChecked()); diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_d= lg_preferences.cc index 8c1ceab..f97411e 100644 --- a/libs/ui/dialogs/kis_dlg_preferences.cc +++ b/libs/ui/dialogs/kis_dlg_preferences.cc @@ -117,7 +117,9 @@ GeneralTab::GeneralTab(QWidget *_parent, const char *_n= ame) m_cmbMDIType->setCurrentIndex(cfg.readEntry("mdi_viewmode", (int)= QMdiArea::TabbedView)); m_chkRubberBand->setChecked(cfg.readEntry("mdi_rubberband", cfg.u= seOpenGL())); m_favoritePresetsSpinBox->setValue(cfg.favoritePresets()); - m_mdiColor->setColor(cfg.getMDIBackgroundColor()); + KoColor mdiColor; + mdiColor.fromQColor(cfg.getMDIBackgroundColor()); + m_mdiColor->setColor(mdiColor); m_backgroundimage->setText(cfg.getMDIBackgroundImage()); m_chkCanvasMessages->setChecked(cfg.showCanvasMessages()); m_chkCompressKra->setChecked(cfg.compressKra()); @@ -146,7 +148,9 @@ void GeneralTab::setDefault() m_cmbMDIType->setCurrentIndex((int)QMdiArea::TabbedView); m_chkRubberBand->setChecked(cfg.useOpenGL(true)); m_favoritePresetsSpinBox->setValue(cfg.favoritePresets(true)); - m_mdiColor->setColor(cfg.getMDIBackgroundColor(true)); + KoColor mdiColor; + mdiColor.fromQColor(cfg.getMDIBackgroundColor(true)); + m_mdiColor->setColor(mdiColor); m_backgroundimage->setText(cfg.getMDIBackgroundImage(true)); m_chkCanvasMessages->setChecked(cfg.showCanvasMessages(true)); m_chkCompressKra->setChecked(cfg.compressKra(true)); @@ -339,10 +343,6 @@ ColorSettingsTab::ColorSettingsTab(QWidget *parent, co= nst char *name) KisImageConfig cfgImage; = KisProofingConfigurationSP proofingConfig =3D cfgImage.defaultProofing= configuration(); - m_gamutWarning =3D new KoColorPopupAction(this); - m_gamutWarning->setToolTip(i18n("Set default color used for out of Gam= ut Warning")); - m_gamutWarning->setCurrentColor(proofingConfig->warningColor); - m_page->gamutAlarm->setDefaultAction(m_gamutWarning); m_page->sldAdaptationState->setMaximum(20); m_page->sldAdaptationState->setMinimum(0); m_page->sldAdaptationState->setValue((int)proofingConfig->adaptationSt= ate*20); @@ -450,7 +450,10 @@ void ColorSettingsTab::setDefault() m_page->ckbProofBlackPoint->setChecked(proofingConfig->conversionFlags= .testFlag(KoColorConversionTransformation::BlackpointCompensation)); m_page->sldAdaptationState->setValue(0); = - m_gamutWarning->setCurrentColor(proofingConfig->warningColor); + //probably this should become the screenprofile? + KoColor ga(KoColorSpaceRegistry::instance()->rgb8()); + ga.fromKoColor(proofingConfig->warningColor); + m_page->gamutAlarm->setColor(ga); = m_page->chkBlackpoint->setChecked(cfg.useBlackPointCompensation(true)); m_page->chkAllowLCMSOptimization->setChecked(cfg.allowLCMSOptimization= (true)); @@ -665,7 +668,6 @@ void PerformanceTab::selectSwapDir() //------------------------------------------------------------------------= --------------------------- = #include "KoColor.h" -#include "KoColorPopupAction.h" = DisplaySettingsTab::DisplaySettingsTab(QWidget *parent, const char *name) : WdgDisplaySettings(parent, name) @@ -700,16 +702,23 @@ DisplaySettingsTab::DisplaySettingsTab(QWidget *paren= t, const char *name) = KoColor c; c.fromQColor(cfg.selectionOverlayMaskColor()); - m_selectionOverlayColorAction =3D new KoColorPopupAction(this); - m_selectionOverlayColorAction->setCurrentColor(c); - m_selectionOverlayColorAction->setToolTip(i18n("Change the background = color of the image")); - btnSelectionOverlayColor->setDefaultAction(m_selectionOverlayColorActi= on); + c.setOpacity(1.0); + btnSelectionOverlayColor->setColor(c); + sldSelectionOverlayOpacity->setRange(0.0, 1.0, 2); + sldSelectionOverlayOpacity->setSingleStep(0.05); + sldSelectionOverlayOpacity->setValue(cfg.selectionOverlayMaskColor().a= lphaF()); = intCheckSize->setValue(cfg.checkSize()); chkMoving->setChecked(cfg.scrollCheckers()); - colorChecks1->setColor(cfg.checkersColor1()); - colorChecks2->setColor(cfg.checkersColor2()); - canvasBorder->setColor(cfg.canvasBorderColor()); + KoColor ck1(KoColorSpaceRegistry::instance()->rgb8()); + ck1.fromQColor(cfg.checkersColor1()); + colorChecks1->setColor(ck1); + KoColor ck2(KoColorSpaceRegistry::instance()->rgb8()); + ck2.fromQColor(cfg.checkersColor2()); + colorChecks2->setColor(ck2); + KoColor cb(KoColorSpaceRegistry::instance()->rgb8()); + cb.fromQColor(cfg.canvasBorderColor()); + canvasBorder->setColor(cb); hideScrollbars->setChecked(cfg.hideScrollbars()); chkCurveAntialiasing->setChecked(cfg.antialiasCurves()); chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutl= ine()); @@ -742,9 +751,15 @@ void DisplaySettingsTab::setDefault() = chkMoving->setChecked(cfg.scrollCheckers(true)); intCheckSize->setValue(cfg.checkSize(true)); - colorChecks1->setColor(cfg.checkersColor1(true)); - colorChecks2->setColor(cfg.checkersColor2(true)); - canvasBorder->setColor(cfg.canvasBorderColor(true)); + KoColor ck1(KoColorSpaceRegistry::instance()->rgb8()); + ck1.fromQColor(cfg.checkersColor1(true)); + colorChecks1->setColor(ck1); + KoColor ck2(KoColorSpaceRegistry::instance()->rgb8()); + ck2.fromQColor(cfg.checkersColor2(true)); + colorChecks2->setColor(ck2); + KoColor cvb(KoColorSpaceRegistry::instance()->rgb8()); + cvb.fromQColor(cfg.canvasBorderColor(true)); + canvasBorder->setColor(cvb); hideScrollbars->setChecked(cfg.hideScrollbars(true)); chkCurveAntialiasing->setChecked(cfg.antialiasCurves(true)); chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutl= ine(true)); @@ -950,7 +965,7 @@ bool KisDlgPreferences::editPreferences() cfg.setShowOutlineWhilePainting(dialog->m_general->showOutlineWhil= ePainting()); cfg.setHideSplashScreen(dialog->m_general->hideSplashScreen()); cfg.writeEntry("mdi_viewmode", dialog->m_general->mdiMode()); - cfg.setMDIBackgroundColor(dialog->m_general->m_mdiColor->color()); + cfg.setMDIBackgroundColor(dialog->m_general->m_mdiColor->color().t= oQColor()); cfg.setMDIBackgroundImage(dialog->m_general->m_backgroundimage->te= xt()); cfg.setAutoSaveInterval(dialog->m_general->autoSaveInterval()); cfg.setBackupFile(dialog->m_general->m_backupFileCheckBox->isCheck= ed()); @@ -990,7 +1005,7 @@ bool KisDlgPreferences::editPreferences() cfg.setWorkingColorSpace(dialog->m_colorSettings->m_page->cmbWorki= ngColorSpace->currentItem().id()); = KisImageConfig cfgImage; - cfgImage.setDefaultProofingConfig(dialog->m_colorSettings->m_page-= >proofingSpaceSelector->currentColorSpace(), dialog->m_colorSettings->m_pag= e->cmbProofingIntent->currentIndex(), dialog->m_colorSettings->m_page->ckbP= roofBlackPoint->isChecked(), dialog->m_colorSettings->m_gamutWarning->curre= ntKoColor(), (double)dialog->m_colorSettings->m_page->sldAdaptationState->v= alue()/20); + cfgImage.setDefaultProofingConfig(dialog->m_colorSettings->m_page-= >proofingSpaceSelector->currentColorSpace(), dialog->m_colorSettings->m_pag= e->cmbProofingIntent->currentIndex(), dialog->m_colorSettings->m_page->ckbP= roofBlackPoint->isChecked(), dialog->m_colorSettings->m_page->gamutAlarm->c= olor(), (double)dialog->m_colorSettings->m_page->sldAdaptationState->value(= )/20); cfg.setUseBlackPointCompensation(dialog->m_colorSettings->m_page->= chkBlackpoint->isChecked()); cfg.setAllowLCMSOptimization(dialog->m_colorSettings->m_page->chkA= llowLCMSOptimization->isChecked()); cfg.setPasteBehaviour(dialog->m_colorSettings->m_pasteBehaviourGro= up.checkedId()); @@ -1010,11 +1025,13 @@ bool KisDlgPreferences::editPreferences() = cfg.setCheckSize(dialog->m_displaySettings->intCheckSize->value()); cfg.setScrollingCheckers(dialog->m_displaySettings->chkMoving->isC= hecked()); - cfg.setCheckersColor1(dialog->m_displaySettings->colorChecks1->col= or()); - cfg.setCheckersColor2(dialog->m_displaySettings->colorChecks2->col= or()); - cfg.setCanvasBorderColor(dialog->m_displaySettings->canvasBorder->= color()); + cfg.setCheckersColor1(dialog->m_displaySettings->colorChecks1->col= or().toQColor()); + cfg.setCheckersColor2(dialog->m_displaySettings->colorChecks2->col= or().toQColor()); + cfg.setCanvasBorderColor(dialog->m_displaySettings->canvasBorder->= color().toQColor()); cfg.setHideScrollbars(dialog->m_displaySettings->hideScrollbars->i= sChecked()); - cfg.setSelectionOverlayMaskColor(dialog->m_displaySettings->m_sele= ctionOverlayColorAction->currentKoColor().toQColor()); + KoColor c =3D dialog->m_displaySettings->btnSelectionOverlayColor-= >color(); + c.setOpacity(dialog->m_displaySettings->sldSelectionOverlayOpacity= ->value()); + cfg.setSelectionOverlayMaskColor(c.toQColor()); cfg.setAntialiasCurves(dialog->m_displaySettings->chkCurveAntialia= sing->isChecked()); cfg.setAntialiasSelectionOutline(dialog->m_displaySettings->chkSel= ectionOutlineAntialiasing->isChecked()); cfg.setShowSingleChannelAsColor(dialog->m_displaySettings->chkChan= nelsAsColor->isChecked()); diff --git a/libs/ui/dialogs/kis_dlg_preferences.h b/libs/ui/dialogs/kis_dl= g_preferences.h index ea04494..1fdcccb 100644 --- a/libs/ui/dialogs/kis_dlg_preferences.h +++ b/libs/ui/dialogs/kis_dlg_preferences.h @@ -25,9 +25,9 @@ #include = #include -#include "KoColorPopupAction.h" = #include "kis_global.h" +#include "widgets/squeezedcombobox.h" = #include "ui_wdggeneralsettings.h" #include "ui_wdgdisplaysettings.h" @@ -156,7 +156,6 @@ private Q_SLOTS: public: void setDefault(); WdgColorSettings *m_page; - KoColorPopupAction *m_gamutWarning; QButtonGroup m_pasteBehaviourGroup; QList m_monitorProfileLabels; QList m_monitorProfileWidgets; @@ -244,7 +243,6 @@ public: * Display settings tab for preferences dialog */ = -class KoColorPopupAction; = class DisplaySettingsTab : public WdgDisplaySettings { @@ -259,7 +257,6 @@ protected Q_SLOTS: void slotUseOpenGLToggled(bool isChecked); = public: - KoColorPopupAction *m_selectionOverlayColorAction; }; = //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/libs/ui/forms/wdgautogradient.ui b/libs/ui/forms/wdgautogradie= nt.ui index e6c2ee7..cb25376 100644 --- a/libs/ui/forms/wdgautogradient.ui +++ b/libs/ui/forms/wdgautogradient.ui @@ -104,7 +104,7 @@ - + 0 @@ -185,7 +185,7 @@ - + 0 @@ -374,10 +374,9 @@
kis_int_parse_spin_box.h
- KColorButton + KisColorButton QPushButton -
kcolorbutton.h
- 1 +
kis_color_button.h
KisGradientSliderWidget diff --git a/libs/ui/forms/wdgcolorsettings.ui b/libs/ui/forms/wdgcolorsett= ings.ui index e06a24f..c51dc04 100644 --- a/libs/ui/forms/wdgcolorsettings.ui +++ b/libs/ui/forms/wdgcolorsettings.ui @@ -189,13 +189,6 @@ Soft Proof Options
- - - - ... - - - @@ -264,6 +257,13 @@ + + + + + + +
@@ -363,6 +363,11 @@ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisColorSpaceSelector QWidget
widgets/kis_color_space_selector.h
@@ -378,11 +383,6 @@ QComboBox
widgets/kis_cmb_idlist.h
- - SqueezedComboBox - QComboBox -
widgets/squeezedcombobox.h
-
diff --git a/libs/ui/forms/wdgdisplaysettings.ui b/libs/ui/forms/wdgdisplay= settings.ui index 0bbd7ed..deb5017 100644 --- a/libs/ui/forms/wdgdisplaysettings.ui +++ b/libs/ui/forms/wdgdisplaysettings.ui @@ -116,10 +116,10 @@ - + - + @@ -276,7 +276,7 @@ - + @@ -318,24 +318,21 @@ - + - ... + - - - Qt::Horizontal - - - - 358 - 20 - + + + + 0 + 0 + - + @@ -349,9 +346,14 @@
kis_int_parse_spin_box.h
- KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h
+
+ + KisDoubleSliderSpinBox + QWidget +
kis_slider_spin_box.h
1
diff --git a/libs/ui/forms/wdgdlginternalcolorselector.ui b/libs/ui/forms/w= dgdlginternalcolorselector.ui new file mode 100644 index 0000000..4ad1fb8 --- /dev/null +++ b/libs/ui/forms/wdgdlginternalcolorselector.ui @@ -0,0 +1,237 @@ + + + WdgDlgInternalColorSelector + + + + 0 + 0 + 505 + 483 + + + + Dialog + + + + + + + + + + + 0 + 0 + + + + + 90 + 90 + + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 2 + + + 2 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 50 + 70 + + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + + + + + + + + + + + + 0 + 0 + + + + + 225 + 50 + + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + KisSpinboxColorSelector + QWidget +
kis_spinbox_color_selector.h
+ 1 +
+ + KisScreenColorPicker + QWidget +
kis_screen_color_picker.h
+ 1 +
+ + KisVisualColorSelector + QWidget +
kis_visual_color_selector.h
+ 1 +
+ + KoColorPatch + QWidget +
KoColorPatch.h
+ 1 +
+ + KoColorSetWidget + QFrame +
KoColorSetWidget.h
+ 1 +
+
+ + + + buttonBox + accepted() + WdgDlgInternalColorSelector + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + WdgDlgInternalColorSelector + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/libs/ui/forms/wdggeneralsettings.ui b/libs/ui/forms/wdggeneral= settings.ui index f27eed6..aaa37d1 100644 --- a/libs/ui/forms/wdggeneralsettings.ui +++ b/libs/ui/forms/wdggeneralsettings.ui @@ -248,7 +248,7 @@ - + 0 @@ -258,20 +258,6 @@ - - - 0 - 0 - 0 - - - - - 0 - 0 - 0 - - @@ -699,10 +685,14 @@ - KColorButton + KisIntParseSpinBox + QSpinBox +
kis_int_parse_spin_box.h
+
+ + KisColorButton QPushButton -
kcolorbutton.h
- 1 +
kis_color_button.h
KisIntParseSpinBox diff --git a/libs/ui/forms/wdgimageproperties.ui b/libs/ui/forms/wdgimagepr= operties.ui index 8a03c54..eb1196f 100644 --- a/libs/ui/forms/wdgimageproperties.ui +++ b/libs/ui/forms/wdgimageproperties.ui @@ -108,12 +108,19 @@
- + - ... + - - QToolButton::InstantPopup + + + + + + + 0 + 20 + @@ -227,13 +234,6 @@ Softproofing - - - - ... - - - @@ -313,6 +313,13 @@ + + + + + + + @@ -321,6 +328,17 @@ + KisDoubleSliderSpinBox + QWidget +
kis_slider_spin_box.h
+ 1 +
+ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisColorSpaceSelector QWidget
widgets/kis_color_space_selector.h
diff --git a/libs/ui/forms/wdgnewimage.ui b/libs/ui/forms/wdgnewimage.ui index 4d5ee82..c4841f5 100644 --- a/libs/ui/forms/wdgnewimage.ui +++ b/libs/ui/forms/wdgnewimage.ui @@ -507,7 +507,7 @@ - + 0 @@ -645,21 +645,14 @@ - KisColorSpaceSelector - QWidget -
widgets/kis_color_space_selector.h
- 1 -
- - KisDoubleParseSpinBox - QDoubleSpinBox -
kis_double_parse_spin_box.h
+ KisIntParseSpinBox + QSpinBox +
kis_int_parse_spin_box.h
- KColorButton + KisColorButton QPushButton -
kcolorbutton.h
- 1 +
kis_color_button.h
KisDoubleSliderSpinBox @@ -668,9 +661,15 @@ 1 - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
+ KisColorSpaceSelector + QWidget +
widgets/kis_color_space_selector.h
+ 1 +
+ + KisDoubleParseSpinBox + QDoubleSpinBox +
kis_double_parse_spin_box.h
diff --git a/libs/ui/forms/wdgpaintactioneditor.ui b/libs/ui/forms/wdgpaint= actioneditor.ui index 5e82cc6..deac79f 100644 --- a/libs/ui/forms/wdgpaintactioneditor.ui +++ b/libs/ui/forms/wdgpaintactioneditor.ui @@ -34,19 +34,6 @@
- - - - - 0 - 0 - - - - ... - - - @@ -57,19 +44,6 @@ - - - - - 0 - 0 - - - - ... - - - @@ -112,6 +86,32 @@ + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + @@ -180,6 +180,11 @@ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisIntParseSpinBox QSpinBox
kis_int_parse_spin_box.h
diff --git a/libs/ui/kis_autogradient.cc b/libs/ui/kis_autogradient.cc index 733a8ce..8786ee5 100644 --- a/libs/ui/kis_autogradient.cc +++ b/libs/ui/kis_autogradient.cc @@ -50,8 +50,8 @@ KisAutogradient::KisAutogradient(KoSegmentGradient* gradi= ent, QWidget *parent, c connect(gradientSlider, SIGNAL(sigChangedSegment(KoGradientSegment*)),= SLOT(slotChangedSegment(KoGradientSegment*))); connect(comboBoxColorInterpolationType, SIGNAL(activated(int)), SLOT(s= lotChangedColorInterpolation(int))); connect(comboBoxInterpolationType, SIGNAL(activated(int)), SLOT(slotCh= angedInterpolation(int))); - connect(leftColorButton, SIGNAL(changed(const QColor&)), SLOT(slotChan= gedLeftColor(const QColor&))); - connect(rightColorButton, SIGNAL(changed(const QColor&)), SLOT(slotCha= ngedRightColor(const QColor&))); + connect(leftColorButton, SIGNAL(changed(const KoColor&)), SLOT(slotCha= ngedLeftColor(const KoColor&))); + connect(rightColorButton, SIGNAL(changed(const KoColor&)), SLOT(slotCh= angedRightColor(const KoColor&))); = connect(intNumInputLeftOpacity, SIGNAL(valueChanged(int)), SLOT(slotCh= angedLeftOpacity(int))); connect(intNumInputRightOpacity, SIGNAL(valueChanged(int)), SLOT(slotC= hangedRightOpacity(int))); @@ -65,22 +65,17 @@ void KisAutogradient::activate() = void KisAutogradient::slotSelectedSegment(KoGradientSegment* segment) { - QColor startColor; - QColor endColor; = - segment->startColor().toQColor(&startColor); - segment->endColor().toQColor(&endColor); - - leftColorButton->setColor(startColor); - rightColorButton->setColor(endColor); + leftColorButton->setColor(segment->startColor()); + rightColorButton->setColor(segment->endColor()); comboBoxColorInterpolationType->setCurrentIndex(segment->colorInterpol= ation()); comboBoxInterpolationType->setCurrentIndex(segment->interpolation()); = - int leftOpacity =3D (startColor.alpha() * 100) / OPACITY_OPAQUE_U8; + int leftOpacity =3D segment->startColor().opacityF(); intNumInputLeftOpacity->setValue(leftOpacity); intNumInputLeftOpacity->setSuffix(i18n(" %")); = - int rightOpacity =3D (endColor.alpha() * 100) / OPACITY_OPAQUE_U8; + int rightOpacity =3D segment->endColor().opacityF(); intNumInputRightOpacity->setValue(rightOpacity); intNumInputRightOpacity->setSuffix(i18n(" %")); = @@ -112,7 +107,7 @@ void KisAutogradient::slotChangedColorInterpolation(int= type) paramChanged(); } = -void KisAutogradient::slotChangedLeftColor(const QColor& color) +void KisAutogradient::slotChangedLeftColor(const KoColor& color) { KoGradientSegment* segment =3D gradientSlider->selectedSegment(); if (segment) { @@ -125,11 +120,10 @@ void KisAutogradient::slotChangedLeftColor(const QCol= or& color) paramChanged(); } = -void KisAutogradient::slotChangedRightColor(const QColor& color) +void KisAutogradient::slotChangedRightColor(const KoColor& color) { KoGradientSegment* segment =3D gradientSlider->selectedSegment(); if (segment) { - QColor unused; KoColor c(color, segment->endColor().colorSpace()); c.setOpacity(segment->endColor().opacityU8()); segment->setEndColor(c); @@ -143,7 +137,7 @@ void KisAutogradient::slotChangedLeftOpacity(int value) { KoGradientSegment* segment =3D gradientSlider->selectedSegment(); if (segment) { - KoColor c(segment->startColor().toQColor(), segment->startColor().= colorSpace()); + KoColor c(segment->startColor(), segment->startColor().colorSpace(= )); c.setOpacity(qreal(value) / qreal(100.0)); segment->setStartColor(c); } @@ -156,7 +150,7 @@ void KisAutogradient::slotChangedRightOpacity(int value) { KoGradientSegment* segment =3D gradientSlider->selectedSegment(); if (segment) { - KoColor c(segment->endColor().toQColor(), segment->endColor().colo= rSpace()); + KoColor c(segment->endColor(), segment->endColor().colorSpace()); c.setOpacity(quint8((value *OPACITY_OPAQUE_U8) / 100)); segment->setEndColor(c); } diff --git a/libs/ui/kis_autogradient.h b/libs/ui/kis_autogradient.h index 2228fdc..0684fe7 100644 --- a/libs/ui/kis_autogradient.h +++ b/libs/ui/kis_autogradient.h @@ -39,8 +39,8 @@ private Q_SLOTS: void slotChangedSegment(KoGradientSegment* segment); void slotChangedInterpolation(int type); void slotChangedColorInterpolation(int type); - void slotChangedLeftColor(const QColor& color); - void slotChangedRightColor(const QColor& color); + void slotChangedLeftColor(const KoColor& color); + void slotChangedRightColor(const KoColor& color); void slotChangedLeftOpacity(int value); void slotChangedRightOpacity(int value); void slotChangedName(); diff --git a/libs/ui/kis_control_frame.cpp b/libs/ui/kis_control_frame.cpp index e55ed00..f4c1818 100644 --- a/libs/ui/kis_control_frame.cpp +++ b/libs/ui/kis_control_frame.cpp @@ -46,6 +46,7 @@ #include #include #include +#include = #include #include "kis_resource_server_provider.h" @@ -62,6 +63,7 @@ #include "kis_favorite_resource_manager.h" #include "kis_display_color_converter.h" #include +#include = = KisControlFrame::KisControlFrame(KisViewManager *view, QWidget *parent, co= nst char* name) @@ -109,21 +111,22 @@ void KisControlFrame::setup(QWidget *parent) // XXX: KOMVC we don't have a canvas here yet, needs a setImageView const KoColorDisplayRendererInterface *displayRenderer =3D \ KisDisplayColorConverter::dumbConverterInstance()->displayRenderer= Interface(); - KoDualColorButton * dual =3D new KoDualColorButton(m_viewManager->reso= urceProvider()->fgColor(), + m_dual =3D new KoDualColorButton(m_viewManager->resourceProvider()->fg= Color(), m_viewManager->resour= ceProvider()->bgColor(), displayRenderer, m_viewManager->mainWi= ndow(), m_viewManager->mainWindow()); - dual->setPopDialog(true); + m_dual->setPopDialog(true); action =3D new QWidgetAction(this); action->setText(i18n("&Color")); m_viewManager->actionCollection()->addAction("dual", action); - action->setDefaultWidget(dual); - connect(dual, SIGNAL(foregroundColorChanged(KoColor)), m_viewManager->= resourceProvider(), SLOT(slotSetFGColor(KoColor))); - connect(dual, SIGNAL(backgroundColorChanged(KoColor)), m_viewManager->= resourceProvider(), SLOT(slotSetBGColor(KoColor))); - connect(m_viewManager->resourceProvider(), SIGNAL(sigFGColorChanged(Ko= Color)), dual, SLOT(setForegroundColor(KoColor))); - connect(m_viewManager->resourceProvider(), SIGNAL(sigBGColorChanged(Ko= Color)), dual, SLOT(setBackgroundColor(KoColor))); + action->setDefaultWidget(m_dual); + connect(m_dual, SIGNAL(foregroundColorChanged(KoColor)), m_viewManager= ->resourceProvider(), SLOT(slotSetFGColor(KoColor))); + connect(m_dual, SIGNAL(backgroundColorChanged(KoColor)), m_viewManager= ->resourceProvider(), SLOT(slotSetBGColor(KoColor))); + connect(m_viewManager->resourceProvider(), SIGNAL(sigFGColorChanged(Ko= Color)), m_dual, SLOT(setForegroundColor(KoColor))); + connect(m_viewManager->resourceProvider(), SIGNAL(sigBGColorChanged(Ko= Color)), m_dual, SLOT(setBackgroundColor(KoColor))); connect(m_viewManager->resourceProvider(), SIGNAL(sigFGColorChanged(Ko= Color)), m_gradientWidget, SLOT(update())); connect(m_viewManager->resourceProvider(), SIGNAL(sigBGColorChanged(Ko= Color)), m_gradientWidget, SLOT(update())); - dual->setFixedSize(28, 28); + m_dual->setFixedSize(28, 28); + connect(m_viewManager, SIGNAL(viewChanged()), SLOT(slotUpdateDisplayRe= nderer())); = m_paintopBox =3D new KisPaintopBox(m_viewManager, parent, "paintopbox"= ); = @@ -133,6 +136,18 @@ void KisControlFrame::setup(QWidget *parent) action->setDefaultWidget(m_paintopBox); } = +void KisControlFrame::slotUpdateDisplayRenderer() +{ + if (m_viewManager->canvasBase()){ + m_dual->setDisplayRenderer(m_viewManager->canvasBase()->displayCol= orConverter()->displayRendererInterface()); + m_dual->setColorSpace(m_viewManager->canvasBase()->image()->colorS= pace()); + m_viewManager->canvasBase()->image()->disconnect(m_dual); + connect(m_viewManager->canvasBase()->image(), SIGNAL(sigColorSpace= Changed(const KoColorSpace*)), m_dual, SLOT(setColorSpace(const KoColorSpac= e*)), Qt::UniqueConnection); + } else if (m_viewManager->viewCount()=3D=3D0) { + m_dual->setDisplayRenderer(); + } +} + void KisControlFrame::slotSetPattern(KoPattern * pattern) { m_patternWidget->slotSetItem(pattern); diff --git a/libs/ui/kis_control_frame.h b/libs/ui/kis_control_frame.h index dea70f7..f07c724 100644 --- a/libs/ui/kis_control_frame.h +++ b/libs/ui/kis_control_frame.h @@ -37,6 +37,7 @@ class KisPaintopBox; class KisViewManager; class KisIconWidget; class KoPattern; +class KoDualColorButton; = /** * Control Frame - status display with access to @@ -60,6 +61,7 @@ private Q_SLOTS: = void slotSetPattern(KoPattern * pattern); void slotSetGradient(KoAbstractGradient * gradient); + void slotUpdateDisplayRenderer(); = private: = @@ -85,6 +87,8 @@ private: = KisPaintopBox *m_paintopBox; = + KoDualColorButton *m_dual; + }; = #endif diff --git a/libs/ui/kis_custom_pattern.cc b/libs/ui/kis_custom_pattern.cc index 2ff6689..dc0e15a 100644 --- a/libs/ui/kis_custom_pattern.cc +++ b/libs/ui/kis_custom_pattern.cc @@ -36,6 +36,8 @@ #include "kis_image.h" #include "kis_layer.h" #include "kis_paint_device.h" +#include "kis_selection.h" +#include "kis_painter.h" = #include #include "kis_resource_server_provider.h" @@ -139,6 +141,7 @@ void KisCustomPattern::createPattern() if (!m_view) return; = KisPaintDeviceSP dev; + KisPaintDeviceSP cache; QString name; KisImageWSP image =3D m_view->image(); if (!image) return; @@ -157,6 +160,21 @@ void KisCustomPattern::createPattern() name =3D image->objectName(); } if (!dev) return; + + if(m_view->selection()) { + KisSelectionSP selection =3D m_view->selection(); + QRect selectionRect =3D selection->selectedExactRect(); + cache =3D dev->createCompositionSourceDevice(); + KisPainter gc(cache); + gc.setSelection(selection); + gc.bitBlt(selectionRect.topLeft(), dev, selectionRect); + rc =3D selectionRect; + } else { + cache =3D dev; + } + if (!cache) return; + + // warn when creating large patterns = QSize size =3D rc.size(); @@ -167,7 +185,7 @@ void KisCustomPattern::createPattern() } = QString dir =3D KoResourceServerProvider::instance()->patternServer()-= >saveLocation(); - m_pattern =3D new KoPattern(dev->createThumbnail(size.width(), size.he= ight(), rc, /*oversample*/ 1, + m_pattern =3D new KoPattern(cache->createThumbnail(size.width(), size.= height(), rc, /*oversample*/ 1, KoColorConversionTrans= formation::internalRenderingIntent(), KoColorConversionTrans= formation::internalConversionFlags()), name, dir); } diff --git a/libs/ui/kis_popup_palette.cpp b/libs/ui/kis_popup_palette.cpp index e7c8988..98db88b 100644 --- a/libs/ui/kis_popup_palette.cpp +++ b/libs/ui/kis_popup_palette.cpp @@ -26,6 +26,8 @@ #include #include "kis_resource_server_provider.h" #include +#include +#include #include "KoColorSpaceRegistry.h" #include #include @@ -106,21 +108,27 @@ KisPopupPalette::KisPopupPalette(KisFavoriteResourceM= anager* manager, const KoCo { = const int borderWidth =3D 3; - m_triangleColorSelector =3D new PopupColorTriangle(displayRenderer, t= his); + //m_triangleColorSelector =3D new PopupColorTriangle(displayRenderer,= this); + m_triangleColorSelector =3D new KisVisualColorSelector(this); + m_triangleColorSelector->setDisplayRenderer(displayRenderer); + m_triangleColorSelector->setConfig(true,false); m_triangleColorSelector->move(widgetSize/2-colorInnerRadius+borderWidt= h, widgetSize/2-colorInnerRadius+borderWidth); m_triangleColorSelector->resize(colorInnerRadius*2-borderWidth*2, colo= rInnerRadius*2-borderWidth*2); m_triangleColorSelector->setVisible(true); + m_triangleColorSelector->slotSetColor(KoColor()); = QRegion maskedRegion(0, 0, m_triangleColorSelector->width(), m_triangl= eColorSelector->height(), QRegion::Ellipse ); m_triangleColorSelector->setMask(maskedRegion); = //setAttribute(Qt::WA_TranslucentBackground, true); = - connect(m_triangleColorSelector, SIGNAL(realColorChanged(KoColor)), + connect(m_triangleColorSelector, SIGNAL(sigNewColor(KoColor)), m_colorChangeCompressor.data(), SLOT(start())); connect(m_colorChangeCompressor.data(), SIGNAL(timeout()), SLOT(slotEmitColorChanged())); = + connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_tria= ngleColorSelector, SLOT(ConfigurationChanged())); + connect(m_resourceManager, SIGNAL(sigChangeFGColorSelector(KoColor)), SLOT(slotExternalFgColorChanged(KoColor))); connect(this, SIGNAL(sigChangefGColor(KoColor)), @@ -179,14 +187,23 @@ KisPopupPalette::KisPopupPalette(KisFavoriteResourceM= anager* manager, const KoCo = void KisPopupPalette::slotExternalFgColorChanged(const KoColor &color) { - m_triangleColorSelector->setRealColor(color); + //m_triangleColorSelector->setRealColor(color); + //hack to get around cmyk for now. + if (color.colorSpace()->colorChannelCount()>3) { + KoColor c(KoColorSpaceRegistry::instance()->rgb8()); + c.fromKoColor(color); + m_triangleColorSelector->slotSetColor(c); + } else { + m_triangleColorSelector->slotSetColor(color); + } + } = void KisPopupPalette::slotEmitColorChanged() { if (isVisible()) { update(); - emit sigChangefGColor(m_triangleColorSelector->realColor()); + emit sigChangefGColor(m_triangleColorSelector->getCurrentColor()); } } = @@ -325,7 +342,7 @@ void KisPopupPalette::paintEvent(QPaintEvent* e) //painting foreground color QPainterPath fgColor; fgColor.addEllipse(QPoint(-width() / 2 + 50, -height() / 2 + 32), 30, = 30); - painter.fillPath(fgColor, m_displayRenderer->toQColor(m_triangleColorS= elector->realColor())); + painter.fillPath(fgColor, m_displayRenderer->toQColor(m_triangleColorS= elector->getCurrentColor())); painter.drawPath(fgColor); = // create an ellipse for the background that is slightly diff --git a/libs/ui/kis_popup_palette.h b/libs/ui/kis_popup_palette.h index 0c6f73f..a45e375 100644 --- a/libs/ui/kis_popup_palette.h +++ b/libs/ui/kis_popup_palette.h @@ -33,6 +33,7 @@ class KisSignalCompressor; class KisBrushHud; class KisRoundHudButton; class KisCanvasResourceProvider; +class KisVisualColorSelector; = class KisPopupPalette : public QWidget { @@ -98,7 +99,7 @@ private: int m_hoveredColor; int m_selectedColor; KisFavoriteResourceManager* m_resourceManager; - KoTriangleColorSelector* m_triangleColorSelector; + KisVisualColorSelector* m_triangleColorSelector; = QTimer* m_timer; = diff --git a/libs/ui/layerstyles/WdgColorOverlay.ui b/libs/ui/layerstyles/W= dgColorOverlay.ui index cc49103..8c71bf7 100644 --- a/libs/ui/layerstyles/WdgColorOverlay.ui +++ b/libs/ui/layerstyles/WdgColorOverlay.ui @@ -52,7 +52,7 @@ - + ... @@ -115,15 +115,9 @@ - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
- 1 -
- - KisCompositeOpComboBox - QComboBox -
kis_cmb_composite.h
+
kis_color_button.h
KisSliderSpinBox @@ -131,6 +125,11 @@
kis_slider_spin_box.h
1
+ + KisCompositeOpComboBox + QComboBox +
kis_cmb_composite.h
+
diff --git a/libs/ui/layerstyles/WdgSatin.ui b/libs/ui/layerstyles/WdgSatin= .ui index d40f0c8..31d2567 100644 --- a/libs/ui/layerstyles/WdgSatin.ui +++ b/libs/ui/layerstyles/WdgSatin.ui @@ -49,7 +49,7 @@
- + ... @@ -247,6 +247,11 @@ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisIntParseSpinBox QSpinBox
kis_int_parse_spin_box.h
@@ -258,12 +263,6 @@ 1
- KColorButton - QPushButton -
kcolorbutton.h
- 1 -
- KisCompositeOpComboBox QComboBox
kis_cmb_composite.h
diff --git a/libs/ui/layerstyles/WdgStroke.ui b/libs/ui/layerstyles/WdgStro= ke.ui index 513eff7..bc7a553 100644 --- a/libs/ui/layerstyles/WdgStroke.ui +++ b/libs/ui/layerstyles/WdgStroke.ui @@ -6,7 +6,7 @@ 0 0 - 401 + 406 642 @@ -149,7 +149,7 @@ - 1 + 0 @@ -161,7 +161,7 @@ - + ... @@ -403,15 +403,14 @@ - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
- 1 +
kis_color_button.h
- KisCompositeOpComboBox - QComboBox -
kis_cmb_composite.h
+ KisIntParseSpinBox + QSpinBox +
kis_int_parse_spin_box.h
KisSliderSpinBox @@ -420,6 +419,11 @@ 1 + KisCompositeOpComboBox + QComboBox +
kis_cmb_composite.h
+
+ KisCmbGradient QToolButton
kis_cmb_gradient.h
@@ -430,11 +434,6 @@
kis_pattern_chooser.h
1
- - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
-
diff --git a/libs/ui/layerstyles/wdgBevelAndEmboss.ui b/libs/ui/layerstyles= /wdgBevelAndEmboss.ui index 1f918c0..1bd4462 100644 --- a/libs/ui/layerstyles/wdgBevelAndEmboss.ui +++ b/libs/ui/layerstyles/wdgBevelAndEmboss.ui @@ -313,7 +313,7 @@
- + ... @@ -366,7 +366,7 @@ - + ... @@ -455,6 +455,11 @@ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisIntParseSpinBox QSpinBox
kis_int_parse_spin_box.h
@@ -466,12 +471,6 @@ 1
- KColorButton - QPushButton -
kcolorbutton.h
- 1 -
- KisCompositeOpComboBox QComboBox
kis_cmb_composite.h
diff --git a/libs/ui/layerstyles/wdgInnerGlow.ui b/libs/ui/layerstyles/wdgI= nnerGlow.ui index fcf6601..ce23fc6 100644 --- a/libs/ui/layerstyles/wdgInnerGlow.ui +++ b/libs/ui/layerstyles/wdgInnerGlow.ui @@ -120,7 +120,7 @@
- + ... @@ -374,15 +374,9 @@ - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
- 1 -
- - KisCompositeOpComboBox - QComboBox -
kis_cmb_composite.h
+
kis_color_button.h
KisSliderSpinBox @@ -391,6 +385,11 @@ 1 + KisCompositeOpComboBox + QComboBox +
kis_cmb_composite.h
+
+ KisCmbContour QWidget
kis_cmb_contour.h
diff --git a/libs/ui/layerstyles/wdgdropshadow.ui b/libs/ui/layerstyles/wdg= dropshadow.ui index d1f81dc..3074d05 100644 --- a/libs/ui/layerstyles/wdgdropshadow.ui +++ b/libs/ui/layerstyles/wdgdropshadow.ui @@ -120,7 +120,7 @@
- + @@ -287,6 +287,11 @@ + KisColorButton + QPushButton +
kis_color_button.h
+
+ KisIntParseSpinBox QSpinBox
kis_int_parse_spin_box.h
@@ -298,12 +303,6 @@ 1
- KColorButton - QPushButton -
kcolorbutton.h
- 1 -
- KisCompositeOpComboBox QComboBox
kis_cmb_composite.h
diff --git a/libs/ui/recorder/kis_recorded_paint_action_editor.cc b/libs/ui= /recorder/kis_recorded_paint_action_editor.cc index 00816b3..f9e29ff 100644 --- a/libs/ui/recorder/kis_recorded_paint_action_editor.cc +++ b/libs/ui/recorder/kis_recorded_paint_action_editor.cc @@ -22,8 +22,6 @@ #include = #include -#include - = #include "recorder/kis_recorded_paint_action.h" #include @@ -45,17 +43,13 @@ KisRecordedPaintActionEditor::KisRecordedPaintActionEdi= tor(QWidget* parent, KisR m_actionEditor->setupUi(this); = // Setup paint color editor - m_paintColorPopup =3D new KoColorPopupAction(this); - m_paintColorPopup->setCurrentColor(m_action->paintColor()); - m_actionEditor->paintColor->setDefaultAction(m_paintColorPopup); - connect(m_paintColorPopup, SIGNAL(colorChanged(const KoColor &)), + m_actionEditor->paintColor->setColor(m_action->paintColor()); + connect(m_actionEditor->paintColor, SIGNAL(changed(KoColor)), this, SLOT(configurationUpdated())); = // Setup background color editor - m_backgroundColorPopup =3D new KoColorPopupAction(this); - m_backgroundColorPopup->setCurrentColor(m_action->backgroundColor()); - m_actionEditor->backgroundColor->setDefaultAction(m_backgroundColorPop= up); - connect(m_backgroundColorPopup, SIGNAL(colorChanged(const KoColor &)), + m_actionEditor->backgroundColor->setColor(m_action->backgroundColor()); + connect(m_actionEditor->backgroundColor, SIGNAL(changed(KoColor)), this, SLOT(configurationUpdated())); = // Setup opacity @@ -107,8 +101,8 @@ void KisRecordedPaintActionEditor::configurationUpdated= () { m_configWidget->writeConfigurationSafe(const_cast= (m_action->paintOpPreset()->settings().data())); = - m_action->setPaintColor(m_paintColorPopup->currentKoColor()); - m_action->setBackgroundColor(m_backgroundColorPopup->currentKoColor()); + m_action->setPaintColor(m_actionEditor->paintColor->color()); + m_action->setBackgroundColor(m_actionEditor->backgroundColor->color()); m_action->setOpacity(m_actionEditor->opacity->value() / qreal(100.0)); = emit(actionEdited()); diff --git a/libs/ui/recorder/kis_recorded_paint_action_editor.h b/libs/ui/= recorder/kis_recorded_paint_action_editor.h index 2b55c27..50f907a 100644 --- a/libs/ui/recorder/kis_recorded_paint_action_editor.h +++ b/libs/ui/recorder/kis_recorded_paint_action_editor.h @@ -51,8 +51,6 @@ private: KisRecordedPaintAction* m_action; Ui_WdgPaintActionEditor* m_actionEditor; KisPaintOpConfigWidget* m_configWidget; - KoColorPopupAction* m_paintColorPopup; - KoColorPopupAction* m_backgroundColorPopup; QGridLayout* m_gridLayout; QList m_paintops; QMap m_paintOpsToPreset; diff --git a/libs/widgets/KoDualColorButton.cpp b/libs/ui/widgets/KoDualCol= orButton.cpp similarity index 76% rename from libs/widgets/KoDualColorButton.cpp rename to libs/ui/widgets/KoDualColorButton.cpp index 9913419..ad7fb11 100644 --- a/libs/widgets/KoDualColorButton.cpp +++ b/libs/ui/widgets/KoDualColorButton.cpp @@ -25,6 +25,7 @@ #include "dcolorreset.xpm" = #include +#include "dialogs/kis_dlg_internal_color_selector.h" = #include #include @@ -80,6 +81,7 @@ class Q_DECL_HIDDEN KoDualColorButton::Private bool dragFlag, miniCtlFlag; KoColor foregroundColor; KoColor backgroundColor; + KisDlgInternalColorSelector *colorSelectorDialog; QPoint dragPosition; Selection tmpSelection; bool popDialog; @@ -94,6 +96,12 @@ void KoDualColorButton::Private::init(KoDualColorButton = *q) q->setMinimumSize( q->sizeHint() ); = q->setAcceptDrops( true ); + QString caption =3D i18n("Select a color"); + KisDlgInternalColorSelector::Config config =3D KisDlgInternalColorSele= ctor::Config(); + config.modal =3D false; + colorSelectorDialog =3D new KisDlgInternalColorSelector(q, foregroundC= olor, config, caption, displayRenderer); + connect(colorSelectorDialog, SIGNAL(signalForegroundColorChosen(KoColo= r)), q, SLOT(slotSetForeGroundColorFromDialog(KoColor))); + connect(q, SIGNAL(foregroundColorChanged(KoColor)), colorSelectorDialo= g, SLOT(slotColorUpdated(KoColor))); } = KoDualColorButton::KoDualColorButton(const KoColor &foregroundColor, const= KoColor &backgroundColor, QWidget *parent, QWidget* dialogParent ) @@ -144,6 +152,7 @@ QSize KoDualColorButton::sizeHint() const void KoDualColorButton::setForegroundColor( const KoColor &color ) { d->foregroundColor =3D color; + d->colorSelectorDialog->slotColorUpdated(color); repaint(); } = @@ -153,6 +162,34 @@ void KoDualColorButton::setBackgroundColor( const KoCo= lor &color ) repaint(); } = +void KoDualColorButton::setDisplayRenderer(const KoColorDisplayRendererInt= erface *displayRenderer) +{ + if (displayRenderer) { + d->displayRenderer =3D displayRenderer; + d->colorSelectorDialog->setDisplayRenderer(displayRenderer); + connect(d->displayRenderer, SIGNAL(destroyed()), this, SLOT(setDis= playRenderer()), Qt::UniqueConnection); + } else { + d->displayRenderer =3D KoDumbColorDisplayRenderer::instance(); + } +} + +void KoDualColorButton::setColorSpace(const KoColorSpace *cs) +{ + d->colorSelectorDialog->lockUsedColorSpace(cs); +} + +QColor KoDualColorButton::getColorFromDisplayRenderer(KoColor c) +{ + QColor col; + if (d->displayRenderer) { + c.convertTo(d->displayRenderer->getPaintingColorSpace()); + col =3D d->displayRenderer->toQColor(c); + } else { + col =3D c.toQColor(); + } + return col; +} + void KoDualColorButton::setPopDialog( bool popDialog ) { d->popDialog =3D popDialog; @@ -174,8 +211,8 @@ void KoDualColorButton::paintEvent(QPaintEvent *) metrics( foregroundRect, backgroundRect ); = QBrush defBrush =3D palette().brush( QPalette::Button ); - QBrush foregroundBrush( d->displayRenderer->toQColor(d->foregroundColor)= , Qt::SolidPattern ); - QBrush backgroundBrush( d->displayRenderer->toQColor(d->backgroundColor)= , Qt::SolidPattern ); + QBrush foregroundBrush( getColorFromDisplayRenderer(d->foregroundColor),= Qt::SolidPattern ); + QBrush backgroundBrush( getColorFromDisplayRenderer(d->backgroundColor),= Qt::SolidPattern ); = qDrawShadeRect( &painter, backgroundRect, palette(), false, 1, 0, isEnabled() ? &backgroundBrush : &defBrush ); @@ -213,6 +250,13 @@ void KoDualColorButton::dropEvent( QDropEvent *event ) */ } = +void KoDualColorButton::slotSetForeGroundColorFromDialog(const KoColor col= or) +{ + d->foregroundColor =3D color; + repaint(); + emit foregroundColorChanged(d->foregroundColor); +} + void KoDualColorButton::mousePressEvent( QMouseEvent *event ) { QRect foregroundRect; @@ -263,8 +307,8 @@ void KoDualColorButton::mouseMoveEvent( QMouseEvent *ev= ent ) if ( event->x() >=3D d->dragPosition.x() + delay || event->x() <=3D d-= >dragPosition.x() - delay || event->y() >=3D d->dragPosition.y() + delay || event->y() <=3D d-= >dragPosition.y() - delay ) { KColorMimeData::createDrag( d->tmpSelection =3D=3D Foreground ? - d->displayRenderer->toQColor(d->foregrou= ndColor) : - d->displayRenderer->toQColor(d->backgrou= ndColor), + getColorFromDisplayRenderer(d->foregroun= dColor) : + getColorFromDisplayRenderer(d->backgroun= dColor), this )->start(); d->dragFlag =3D true; } @@ -287,12 +331,15 @@ void KoDualColorButton::mouseReleaseEvent( QMouseEven= t *event ) if ( foregroundRect.contains( event->pos() )) { if(d->tmpSelection =3D=3D Foreground ) { if( d->popDialog) { - QColor c =3D d->displayRenderer->toQColor(d->foregroundCol= or); - c =3D QColorDialog::getColor(c, this) ; - if (c.isValid()) { - d->foregroundColor =3D d->displayRenderer->approximate= FromRenderedQColor(c); - emit foregroundColorChanged(d->foregroundColor); - } + d->colorSelectorDialog->show(); + + //QColor c =3D d->displayRenderer->toQColor(d->foregroundC= olor); + //c =3D QColorDialog::getColor(c, this) ; + + //if (c.isValid()) { + // d->foregroundColor =3D d->displayRenderer->approxima= teFromRenderedQColor(c); + // emit foregroundColorChanged(d->foregroundColor); + //} } else emit pleasePopDialog( d->foregroundColor); @@ -304,12 +351,16 @@ void KoDualColorButton::mouseReleaseEvent( QMouseEven= t *event ) } else if ( backgroundRect.contains( event->pos() )) { if(d->tmpSelection =3D=3D Background ) { if( d->popDialog) { - QColor c =3D d->displayRenderer->toQColor(d->backgroundCol= or); + KoColor c =3D d->backgroundColor; + c =3D KisDlgInternalColorSelector::getModalColorDialog(c, = this); + d->backgroundColor =3D c; + emit backgroundColorChanged(d->backgroundColor); + /*QColor c =3D d->displayRenderer->toQColor(d->backgroundC= olor); c =3D QColorDialog::getColor(c, this); if (c.isValid()) { d->backgroundColor =3D d->displayRenderer->approximate= FromRenderedQColor(c); emit backgroundColorChanged(d->backgroundColor); - } + }*/ } else emit pleasePopDialog( d->backgroundColor); diff --git a/libs/widgets/KoDualColorButton.h b/libs/ui/widgets/KoDualColor= Button.h similarity index 87% rename from libs/widgets/KoDualColorButton.h rename to libs/ui/widgets/KoDualColorButton.h index be53059..dada703 100644 --- a/libs/widgets/KoDualColorButton.h +++ b/libs/ui/widgets/KoDualColorButton.h @@ -22,12 +22,11 @@ #define KODUALCOLORBUTTON_H = #include "kritawidgets_export.h" - +#include #include = class KoColor; -class KoColorDisplayRendererInterface; - +class KoColorSpace; /** * @short A widget for selecting two related colors. * @@ -115,6 +114,26 @@ class KRITAWIDGETS_EXPORT KoDualColorButton : public Q= Widget */ void setBackgroundColor( const KoColor &color ); = + void slotSetForeGroundColorFromDialog (const KoColor color); + + void setDisplayRenderer(const KoColorDisplayRendererInterface *display= Renderer =3D KoDumbColorDisplayRenderer::instance()); + + /** + * @brief setColorSpace + * set ColorSpace so we can lock the selector. Right now this'll be ch= anged per view-change. + * @param cs + */ + void setColorSpace(const KoColorSpace *cs); + + /** + * @brief getColorFromDisplayRenderer + * convenience function to get the right qcolor from the display rende= rer, including checking + * whether the display renderer actually exists. + * @param c the kocolor to convert. + * @return the qcolor to use for display. + */ + QColor getColorFromDisplayRenderer(KoColor c); + /** * Sets if a dialog with a color chooser should be popped up when clic= king * If you set this to false then you could connect to the pleasePopDia= log signal diff --git a/libs/ui/widgets/kis_color_button.cpp b/libs/ui/widgets/kis_col= or_button.cpp new file mode 100644 index 0000000..d6b0777 --- /dev/null +++ b/libs/ui/widgets/kis_color_button.cpp @@ -0,0 +1,340 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones (mjones@kde.org) + Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kis_color_button.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +class KisColorButton::KisColorButtonPrivate +{ +public: + KisColorButtonPrivate(KisColorButton *q); + + void _k_chooseColor(); + void _k_colorChosen(); + + KisColorButton *q; + KoColor m_defaultColor; + bool m_bdefaultColor : 1; + bool m_alphaChannel : 1; + + KoColor col; + QPoint mPos; + + QPointer dialogPtr; + + void initStyleOption(QStyleOptionButton *opt) const; +}; + +///////////////////////////////////////////////////////////////////// +// Functions duplicated from KColorMimeData +// Should be kept in sync +void _k_populateMimeData(QMimeData *mimeData, const KoColor &color) +{ + mimeData->setColorData(color.toQColor()); + mimeData->setText(color.toQColor().name()); +} + +bool _k_canDecode(const QMimeData *mimeData) +{ + if (mimeData->hasColor()) { + return true; + } + if (mimeData->hasText()) { + const QString colorName =3D mimeData->text(); + if ((colorName.length() >=3D 4) && (colorName[0] =3D=3D QLatin1Cha= r('#'))) { + return true; + } + } + return false; +} + +QColor _k_fromMimeData(const QMimeData *mimeData) +{ + if (mimeData->hasColor()) { + return mimeData->colorData().value(); + } + if (_k_canDecode(mimeData)) { + return QColor(mimeData->text()); + } + return QColor(); +} + +QDrag *_k_createDrag(const KoColor &color, QObject *dragsource) +{ + QDrag *drag =3D new QDrag(dragsource); + QMimeData *mime =3D new QMimeData; + _k_populateMimeData(mime, color); + drag->setMimeData(mime); + QPixmap colorpix(25, 20); + colorpix.fill(color.toQColor()); + QPainter p(&colorpix); + p.setPen(Qt::black); + p.drawRect(0, 0, 24, 19); + p.end(); + drag->setPixmap(colorpix); + drag->setHotSpot(QPoint(-5, -7)); + return drag; +} +///////////////////////////////////////////////////////////////////// + +KisColorButton::KisColorButtonPrivate::KisColorButtonPrivate(KisColorButto= n *q) + : q(q) +{ + m_bdefaultColor =3D false; + m_alphaChannel =3D false; + q->setAcceptDrops(true); + + connect(q, SIGNAL(clicked()), q, SLOT(_k_chooseColor())); +} + +KisColorButton::KisColorButton(QWidget *parent) + : QPushButton(parent) + , d(new KisColorButtonPrivate(this)) +{ +} + +KisColorButton::KisColorButton(const KoColor &c, QWidget *parent) + : QPushButton(parent) + , d(new KisColorButtonPrivate(this)) +{ + d->col =3D c; +} + +KisColorButton::KisColorButton(const KoColor &c, const KoColor &defaultCol= or, QWidget *parent) + : QPushButton(parent) + , d(new KisColorButtonPrivate(this)) +{ + d->col =3D c; + setDefaultColor(defaultColor); +} + +KisColorButton::~KisColorButton() +{ + delete d; +} + +KoColor KisColorButton::color() const +{ + return d->col; +} + +void KisColorButton::setColor(const KoColor &c) +{ + d->col =3D c; + update(); + emit changed(d->col); +} + +void KisColorButton::setAlphaChannelEnabled(bool alpha) +{ + d->m_alphaChannel =3D alpha; +} + +bool KisColorButton::isAlphaChannelEnabled() const +{ + return d->m_alphaChannel; +} + +KoColor KisColorButton::defaultColor() const +{ + return d->m_defaultColor; +} + +void KisColorButton::setDefaultColor(const KoColor &c) +{ + d->m_bdefaultColor =3D true; + d->m_defaultColor =3D c; +} + +void KisColorButton::KisColorButtonPrivate::initStyleOption(QStyleOptionBu= tton *opt) const +{ + opt->initFrom(q); + opt->state |=3D q->isDown() ? QStyle::State_Sunken : QStyle::State_Rai= sed; + opt->features =3D QStyleOptionButton::None; + if (q->isDefault()) { + opt->features |=3D QStyleOptionButton::DefaultButton; + } + opt->text.clear(); + opt->icon =3D QIcon(); +} + +void KisColorButton::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QStyle *style =3D QWidget::style(); + + //First, we need to draw the bevel. + QStyleOptionButton butOpt; + d->initStyleOption(&butOpt); + style->drawControl(QStyle::CE_PushButtonBevel, &butOpt, &painter, this= ); + + //OK, now we can muck around with drawing out pretty little color box + //First, sort out where it goes + QRect labelRect =3D style->subElementRect(QStyle::SE_PushButtonContent= s, + &butOpt, this); + int shift =3D style->pixelMetric(QStyle::PM_ButtonMargin, &butOpt, thi= s) / 2; + labelRect.adjust(shift, shift, -shift, -shift); + int x, y, w, h; + labelRect.getRect(&x, &y, &w, &h); + + if (isChecked() || isDown()) { + x +=3D style->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &butOp= t, this); + y +=3D style->pixelMetric(QStyle::PM_ButtonShiftVertical, &butOpt,= this); + } + + QColor fillCol =3D isEnabled() ? d->col.toQColor() : palette().color(b= ackgroundRole()); + qDrawShadePanel(&painter, x, y, w, h, palette(), true, 1, NULL); + if (fillCol.isValid()) { + const QRect rect(x + 1, y + 1, w - 2, h - 2); + if (fillCol.alpha() < 255) { + QPixmap chessboardPattern(16, 16); + QPainter patternPainter(&chessboardPattern); + patternPainter.fillRect(0, 0, 8, 8, Qt::black); + patternPainter.fillRect(8, 8, 8, 8, Qt::black); + patternPainter.fillRect(0, 8, 8, 8, Qt::white); + patternPainter.fillRect(8, 0, 8, 8, Qt::white); + patternPainter.end(); + painter.fillRect(rect, QBrush(chessboardPattern)); + } + painter.fillRect(rect, fillCol); + } + + if (hasFocus()) { + QRect focusRect =3D style->subElementRect(QStyle::SE_PushButtonFoc= usRect, &butOpt, this); + QStyleOptionFocusRect focusOpt; + focusOpt.init(this); + focusOpt.rect =3D focusRect; + focusOpt.backgroundColor =3D palette().background().color(); + style->drawPrimitive(QStyle::PE_FrameFocusRect, &focusOpt, &painte= r, this); + } +} + +QSize KisColorButton::sizeHint() const +{ + QStyleOptionButton opt; + d->initStyleOption(&opt); + return style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(40= , 15), this). + expandedTo(QApplication::globalStrut()); +} + +QSize KisColorButton::minimumSizeHint() const +{ + QStyleOptionButton opt; + d->initStyleOption(&opt); + return style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(3,= 3), this). + expandedTo(QApplication::globalStrut()); +} + +void KisColorButton::dragEnterEvent(QDragEnterEvent *event) +{ + event->setAccepted(_k_canDecode(event->mimeData()) && isEnabled()); +} + +void KisColorButton::dropEvent(QDropEvent *event) +{ + QColor c =3D _k_fromMimeData(event->mimeData()); + if (c.isValid()) { + KoColor col; + col.fromQColor(c); + setColor(col); + } +} + +void KisColorButton::keyPressEvent(QKeyEvent *e) +{ + int key =3D e->key() | e->modifiers(); + + if (QKeySequence::keyBindings(QKeySequence::Copy).contains(key)) { + QMimeData *mime =3D new QMimeData; + _k_populateMimeData(mime, color()); + QApplication::clipboard()->setMimeData(mime, QClipboard::Clipboard= ); + } else if (QKeySequence::keyBindings(QKeySequence::Paste).contains(key= )) { + QColor color =3D _k_fromMimeData(QApplication::clipboard()->mimeDa= ta(QClipboard::Clipboard)); + KoColor col; + col.fromQColor(color); + setColor(col); + } else { + QPushButton::keyPressEvent(e); + } +} + +void KisColorButton::mousePressEvent(QMouseEvent *e) +{ + d->mPos =3D e->pos(); + QPushButton::mousePressEvent(e); +} + +void KisColorButton::mouseMoveEvent(QMouseEvent *e) +{ + if ((e->buttons() & Qt::LeftButton) && + (e->pos() - d->mPos).manhattanLength() > QApplication::startDr= agDistance()) { + _k_createDrag(color(), this)->start(); + setDown(false); + } +} + +void KisColorButton::KisColorButtonPrivate::_k_chooseColor() +{ + KisDlgInternalColorSelector *dialog =3D dialogPtr.data(); + if (dialog) { + dialog->show(); + dialog->raise(); + dialog->activateWindow(); + return; + } + + KisDlgInternalColorSelector::Config cfg; + + dialog =3D new KisDlgInternalColorSelector(q, + q->color(), + cfg, + i18n("Choose a color")); + //dialog->setOption(QColorDialog::ShowAlphaChannel, m_alphaChannel); + dialog->setAttribute(Qt::WA_DeleteOnClose); + connect(dialog, SIGNAL(accepted()), q, SLOT(_k_colorChosen())); + dialogPtr =3D dialog; + dialog->show(); +} + +void KisColorButton::KisColorButtonPrivate::_k_colorChosen() +{ + KisDlgInternalColorSelector *dialog =3D dialogPtr.data(); + if (!dialog) { + return; + } + + q->setColor(dialog->getCurrentColor()); +} + +#include "moc_kis_color_button.cpp" diff --git a/libs/ui/widgets/kis_color_button.h b/libs/ui/widgets/kis_color= _button.h new file mode 100644 index 0000000..5c974a3 --- /dev/null +++ b/libs/ui/widgets/kis_color_button.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * This file is forked from the KF5 KColorButton + Copyright (C) 1997 Martin Jones (mjones@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KisColorButton_H +#define KisColorButton_H +#include + +#include +#include + +class KisColorButtonPrivate; +/** +* @short A pushbutton to display or allow user selection of a color. +* +* This widget can be used to display or allow user selection of a color. +* +* @see QColorDialog +* +* \image html KisColorButton.png "KDE Color Button" +*/ +class KRITAUI_EXPORT KisColorButton : public QPushButton +{ + Q_OBJECT + Q_PROPERTY(KoColor color READ color WRITE setColor NOTIFY changed USER= true) + Q_PROPERTY(KoColor defaultColor READ defaultColor WRITE setDefaultColo= r) + Q_PROPERTY(bool alphaChannelEnabled READ isAlphaChannelEnabled WRITE s= etAlphaChannelEnabled) + +public: + /** + * Creates a color button. + */ + explicit KisColorButton(QWidget *parent =3D 0); + + /** + * Creates a color button with an initial color @p c. + */ + explicit KisColorButton(const KoColor &c, QWidget *parent =3D 0); + + /** + * Creates a color button with an initial color @p c and default color= @p defaultColor. + */ + KisColorButton(const KoColor &c, const KoColor &defaultColor, QWidget = *parent =3D 0); + + virtual ~KisColorButton(); + + /** + * Returns the currently chosen color. + */ + KoColor color() const; + + /** + * Sets the current color to @p c. + */ + void setColor(const KoColor &c); + + /** + * When set to true, allow the user to change the alpha component + * of the color. The default value is false. + * @since 4.5 + */ + void setAlphaChannelEnabled(bool alpha); + + /** + * Returns true if the user is allowed to change the alpha component. + * @since 4.5 + */ + bool isAlphaChannelEnabled() const; + + /** + * Returns the default color or an invalid color + * if no default color is set. + */ + KoColor defaultColor() const; + + /** + * Sets the default color to @p c. + */ + void setDefaultColor(const KoColor &c); + + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + +Q_SIGNALS: + /** + * Emitted when the color of the widget + * is changed, either with setColor() or via user selection. + */ + void changed(const KoColor &newColor); + +protected: + void paintEvent(QPaintEvent *pe) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + +private: + class KisColorButtonPrivate; + KisColorButtonPrivate *const d; + + Q_PRIVATE_SLOT(d, void _k_chooseColor()) + Q_PRIVATE_SLOT(d, void _k_colorChosen()) +}; + +#endif diff --git a/plugins/dockers/specificcolorselector/kis_color_input.cc b/lib= s/ui/widgets/kis_color_input.cpp similarity index 100% rename from plugins/dockers/specificcolorselector/kis_color_input.cc rename to libs/ui/widgets/kis_color_input.cpp diff --git a/plugins/dockers/specificcolorselector/kis_color_input.h b/libs= /ui/widgets/kis_color_input.h similarity index 77% rename from plugins/dockers/specificcolorselector/kis_color_input.h rename to libs/ui/widgets/kis_color_input.h index 45a3267..412b500 100644 --- a/plugins/dockers/specificcolorselector/kis_color_input.h +++ b/libs/ui/widgets/kis_color_input.h @@ -29,14 +29,15 @@ class KisIntParseSpinBox; class KisDoubleParseSpinBox; class KoColorSlider; class QLineEdit; -#include "KoColorDisplayRendererInterface.h" = +#include +#include "kritaui_export.h" = -class KisColorInput : public QWidget +class KRITAUI_EXPORT KisColorInput : public QWidget { Q_OBJECT public: - KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, K= oColorDisplayRendererInterface *displayRenderer); + KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, K= oColorDisplayRendererInterface *displayRenderer =3D KoDumbColorDisplayRende= rer::instance()); protected: void init(); virtual QWidget* createInput() =3D 0; @@ -49,11 +50,11 @@ protected: KoColorDisplayRendererInterface *m_displayRenderer; }; = -class KisIntegerColorInput : public KisColorInput +class KRITAUI_EXPORT KisIntegerColorInput : public KisColorInput { Q_OBJECT public: - KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* c= olor, KoColorDisplayRendererInterface *displayRenderer); + KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* c= olor, KoColorDisplayRendererInterface *displayRenderer =3D KoDumbColorDispl= ayRenderer::instance()); protected: virtual QWidget* createInput(); public Q_SLOTS: @@ -64,11 +65,11 @@ private: }; = = -class KisFloatColorInput : public KisColorInput +class KRITAUI_EXPORT KisFloatColorInput : public KisColorInput { Q_OBJECT public: - KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* col= or, KoColorDisplayRendererInterface *displayRenderer); + KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* col= or, KoColorDisplayRendererInterface *displayRenderer =3D KoDumbColorDisplay= Renderer::instance()); protected: virtual QWidget* createInput(); public Q_SLOTS: @@ -81,11 +82,11 @@ private: qreal m_maxValue; }; = -class KisHexColorInput : public KisColorInput +class KRITAUI_EXPORT KisHexColorInput : public KisColorInput { Q_OBJECT public: - KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRender= erInterface *displayRenderer); + KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRender= erInterface *displayRenderer =3D KoDumbColorDisplayRenderer::instance()); protected: virtual QWidget* createInput(); public Q_SLOTS: diff --git a/libs/ui/widgets/kis_custom_image_widget.cc b/libs/ui/widgets/k= is_custom_image_widget.cc index cd63954..2269c8a 100644 --- a/libs/ui/widgets/kis_custom_image_widget.cc +++ b/libs/ui/widgets/kis_custom_image_widget.cc @@ -129,7 +129,9 @@ KisCustomImageWidget::KisCustomImageWidget(QWidget* par= ent, qint32 defWidth, qin = KisConfig cfg; intNumLayers->setValue(cfg.numDefaultLayers()); - cmbColor->setColor(cfg.defaultBackgroundColor()); + KoColor bcol(KoColorSpaceRegistry::instance()->rgb8()); + bcol.fromQColor(cfg.defaultBackgroundColor()); + cmbColor->setColor(bcol); setBackgroundOpacity(cfg.defaultBackgroundOpacity()); = KisConfig::BackgroundStyle bgStyle =3D cfg.defaultBackgroundStyle(); @@ -277,7 +279,7 @@ KisDocument* KisCustomImageWidget::createNewImage() width =3D static_cast(0.5 + KoUnit::ptToUnit(m_width, KoUnit(= KoUnit::Pixel, resolution))); height =3D static_cast(0.5 + KoUnit::ptToUnit(m_height, KoUnit= (KoUnit::Pixel, resolution))); = - QColor qc =3D cmbColor->color(); + QColor qc =3D cmbColor->color().toQColor(); qc.setAlpha(backgroundOpacity()); KoColor bgColor(qc, cs); = @@ -288,7 +290,7 @@ KisDocument* KisCustomImageWidget::createNewImage() KisConfig cfg; cfg.setNumDefaultLayers(intNumLayers->value()); cfg.setDefaultBackgroundOpacity(backgroundOpacity()); - cfg.setDefaultBackgroundColor(cmbColor->color()); + cfg.setDefaultBackgroundColor(cmbColor->color().toQColor()); cfg.setDefaultBackgroundStyle(backgroundAsLayer ? KisConfig::LAYER : K= isConfig::PROJECTION); = return doc; diff --git a/libs/ui/widgets/kis_screen_color_picker.cpp b/libs/ui/widgets/= kis_screen_color_picker.cpp new file mode 100644 index 0000000..975bddb --- /dev/null +++ b/libs/ui/widgets/kis_screen_color_picker.cpp @@ -0,0 +1,269 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_icon.h" +#include "kis_screen_color_picker.h" +#include "KisMainWindow.h" +#include +#include "kis_wrapped_rect.h" +#include "KisPart.h" + +struct KisScreenColorPicker::Private +{ + + QPushButton *screenColorPickerButton =3D 0; + QLabel *lblScreenColorInfo =3D 0; + + KoColor currentColor =3D KoColor(); + KoColor beforeScreenColorPicking =3D KoColor(); + + KisScreenColorPickingEventFilter *colorPickingEventFilter =3D 0; + +#ifdef Q_OS_WIN32 + QTimer *updateTimer =3D 0; + QWindow dummyTransparentWindow; +#endif +}; + +KisScreenColorPicker::KisScreenColorPicker(QWidget *parent) : QWidget(pare= nt), m_d(new Private) +{ + QVBoxLayout *layout =3D new QVBoxLayout(); + this->setLayout(layout); + m_d->screenColorPickerButton =3D new QPushButton(); + m_d->screenColorPickerButton->setIcon(kisIcon("krita_tool_color_picker= ")); + m_d->screenColorPickerButton->setMinimumHeight(25); + this->layout()->addWidget(m_d->screenColorPickerButton); + m_d->lblScreenColorInfo =3D new QLabel(QLatin1String("\n")); + this->layout()->addWidget(m_d->lblScreenColorInfo); + connect(m_d->screenColorPickerButton, SIGNAL(clicked()), SLOT(pickScre= enColor())); +#ifdef Q_OS_WIN32 + m_d->updateTimer =3D new QTimer(q); + m_d->dummyTransparentWindow.resize(1, 1); + m_d->dummyTransparentWindow.setFlags(Qt::Tool | Qt::FramelessWindowHin= t); + connect(m_d->updateTimer, SIGNAL(timeout()), SLOT(updateColorPicking()= )); +#endif +} + +KisScreenColorPicker::~KisScreenColorPicker() +{ +} + +KoColor KisScreenColorPicker::currentColor() +{ + return m_d->currentColor; +} + +void KisScreenColorPicker::pickScreenColor() +{ + if (!m_d->colorPickingEventFilter) + m_d->colorPickingEventFilter =3D new KisScreenColorPickingEventFil= ter(this); + this->installEventFilter(m_d->colorPickingEventFilter); + // If user pushes Escape, the last color before picking will be restor= ed. + m_d->beforeScreenColorPicking =3D currentColor(); +#ifndef QT_NO_CURSOR + grabMouse(Qt::CrossCursor); +#else + grabMouse(); +#endif + +#ifdef Q_OS_WIN32 // excludes WinCE and WinRT + // On Windows mouse tracking doesn't work over other processes's windo= ws + m_d->updateTimer->start(30); + + // HACK: Because mouse grabbing doesn't work across processes, we have= to have a dummy, + // invisible window to catch the mouse click, otherwise we will click = whatever we clicked + // and loose focus. + m_d->dummyTransparentWindow.show(); +#endif + grabKeyboard(); + /* With setMouseTracking(true) the desired color can be more precisely= picked up, + * and continuously pushing the mouse button is not necessary. + */ + setMouseTracking(true); + + //emit to the rest of the dialog to disable. + Q_EMIT sigPleaseDisableEverything(true); + m_d->screenColorPickerButton->setDisabled(true); + + const QPoint globalPos =3D QCursor::pos(); + setCurrentColor(grabScreenColor(globalPos)); + updateColorLabelText(globalPos); +} + +void KisScreenColorPicker::setCurrentColor(KoColor c) +{ + m_d->currentColor =3D c; +} + +KoColor KisScreenColorPicker::grabScreenColor(const QPoint &p) +{ + // First check whether we're clicking on a Krita window for some real = color picking + Q_FOREACH(KisView *view, KisPart::instance()->views()) { + QWidget *canvasWidget =3D view->canvasBase()->canvasWidget(); + QPoint widgetPoint =3D canvasWidget->mapFromGlobal(p); + + if (canvasWidget->rect().contains(widgetPoint)) { + QPointF imagePoint =3D view->canvasBase()->coordinatesConverte= r()->widgetToImage(widgetPoint); + KisImageWSP image =3D view->image(); + + if (image) { + if (image->wrapAroundModePermitted()) { + imagePoint =3D KisWrappedRect::ptToWrappedPt(imagePoin= t.toPoint(), image->bounds()); + } + KoColor pickedColor =3D KoColor(); + image->projection()->pixel(imagePoint.x(), imagePoint.y(),= &pickedColor); + return pickedColor; + } + } + } + + // And otherwise, we'll check the desktop + const QDesktopWidget *desktop =3D QApplication::desktop(); + const QPixmap pixmap =3D QGuiApplication::screens().at(desktop->screen= Number())->grabWindow(desktop->winId(), + = p.x(), p.y(), 1, 1); + QImage i =3D pixmap.toImage(); + KoColor col =3D KoColor(); + col.fromQColor(QColor::fromRgb(i.pixel(0, 0))); + return col; +} + +void KisScreenColorPicker::updateColorLabelText(const QPoint &globalPos) +{ + KoColor col =3D grabScreenColor(globalPos); + QString colname =3D KoColor::toQString(col); + QString location =3D QString::number(globalPos.x())+QString(", ")+QStr= ing::number(globalPos.y()); + m_d->lblScreenColorInfo->setWordWrap(true); + m_d->lblScreenColorInfo->setText(location+QString(": ")+colname); +} + +bool KisScreenColorPicker::handleColorPickingMouseMove(QMouseEvent *e) +{ + // If the cross is visible the grabbed color will be black most of the= times + //cp->setCrossVisible(!cp->geometry().contains(e->pos())); + + + continueUpdateColorPicking(e->globalPos()); + return true; +} + +bool KisScreenColorPicker::handleColorPickingMouseButtonRelease(QMouseEven= t *e) +{ + setCurrentColor(grabScreenColor(e->globalPos())); + Q_EMIT sigNewColorPicked(currentColor()); + releaseColorPicking(); + return true; +} + +bool KisScreenColorPicker::handleColorPickingKeyPress(QKeyEvent *e) +{ + //Q_Q(QColorDialog); + if (e->matches(QKeySequence::Cancel)) { + releaseColorPicking(); + setCurrentColor(m_d->beforeScreenColorPicking); + } else if (e->key() =3D=3D Qt::Key_Return || e->key() =3D=3D Qt::Key_E= nter) { + setCurrentColor(grabScreenColor(QCursor::pos())); + releaseColorPicking(); + } + e->accept(); + return true; +} + +void KisScreenColorPicker::releaseColorPicking() +{ + //Q_Q(QColorDialog); + //cp->setCrossVisible(true); + removeEventFilter(m_d->colorPickingEventFilter); + releaseMouse(); +#ifdef Q_OS_WIN32 + m_d->updateTimer->stop(); + m_d->dummyTransparentWindow.setVisible(false); +#endif + releaseKeyboard(); + setMouseTracking(false); + m_d->lblScreenColorInfo->setText(QLatin1String("\n")); + //emit enable signal + Q_EMIT sigPleaseDisableEverything(false); + m_d->screenColorPickerButton->setDisabled(false); +} + +void KisScreenColorPicker::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); +} + +void KisScreenColorPicker::updateColorPicking() +{ +#ifndef QT_NO_CURSOR + //Q_Q(QColorDialog); + static QPoint lastGlobalPos; + QPoint newGlobalPos =3D QCursor::pos(); + if (lastGlobalPos =3D=3D newGlobalPos) + return; + lastGlobalPos =3D newGlobalPos; + + if (!rect().contains(mapFromGlobal(newGlobalPos))) { // Inside the dia= log mouse tracking works, handleColorPickingMouseMove will be called + continueUpdateColorPicking(newGlobalPos); +#ifdef Q_OS_WIN32 + m_dummyTransparentWindow.setPosition(newGlobalPos); +#endif + } +#endif // ! QT_NO_CURSOR +} + +void KisScreenColorPicker::continueUpdateColorPicking(const QPoint &global= Pos) +{ + const KoColor color =3D grabScreenColor(globalPos); + // QTBUG-39792, do not change standard, custom color selectors while m= oving as + // otherwise it is not possible to pre-select a custom cell for assign= ment. + setCurrentColor(color); + updateColorLabelText(globalPos); + +} + +// Event filter to be installed on the dialog while in color-picking mode. +KisScreenColorPickingEventFilter::KisScreenColorPickingEventFilter(KisScre= enColorPicker *w, QObject *parent) : QObject(parent), m_w(w) +{} + +bool KisScreenColorPickingEventFilter::eventFilter(QObject *, QEvent *even= t) +{ + switch (event->type()) { + case QEvent::MouseMove: + return m_w->handleColorPickingMouseMove(static_cast= (event)); + case QEvent::MouseButtonRelease: + return m_w->handleColorPickingMouseButtonRelease(static_cast(event)); + case QEvent::KeyPress: + return m_w->handleColorPickingKeyPress(static_cast(ev= ent)); + default: + break; + } + return false; +} + + +#include "kis_screen_color_picker.moc" diff --git a/libs/ui/widgets/kis_screen_color_picker.h b/libs/ui/widgets/ki= s_screen_color_picker.h new file mode 100644 index 0000000..3fdb6a7 --- /dev/null +++ b/libs/ui/widgets/kis_screen_color_picker.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ +#ifndef KISSCREENCOLORPICKER_H +#define KISSCREENCOLORPICKER_H + +#include +#include +#include + +#include "KoColor.h" + +#include "kritaui_export.h" + +/** + * @brief The KisScreenColorPicker class + * Based on the original QColorDialog's screen color picker, this class pr= ovides a button + * that can be used to activate a colorpicker that can pick from anywhere = on the screen. + */ +class KRITAUI_EXPORT KisScreenColorPicker : public QWidget +{ + Q_OBJECT +public: + explicit KisScreenColorPicker(QWidget *parent =3D 0); + ~KisScreenColorPicker(); + + KoColor currentColor(); + + bool handleColorPickingMouseMove(QMouseEvent *e); + bool handleColorPickingMouseButtonRelease(QMouseEvent *e); + bool handleColorPickingKeyPress(QKeyEvent *e); + +Q_SIGNALS: + void sigNewColorPicked(KoColor c); + void sigPleaseDisableEverything(bool disable); + +public Q_SLOTS: + void pickScreenColor(); + +private Q_SLOTS: + void updateColorPicking(); +protected: + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; +private: + struct Private; //The private struct + const QScopedPointer m_d; //the private pointer + + void setCurrentColor(KoColor c); + KoColor grabScreenColor(const QPoint &p); + void updateColorLabelText(const QPoint &globalPos); + void releaseColorPicking(); + void continueUpdateColorPicking(const QPoint &globalPos); +}; + +class KisScreenColorPickingEventFilter : public QObject { +public: + explicit KisScreenColorPickingEventFilter(KisScreenColorPicker *w, QOb= ject *parent =3D 0); + + bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE; +private: + KisScreenColorPicker *m_w; +}; + +#endif // KISSCREENCOLORPICKER_H diff --git a/libs/ui/widgets/kis_spinbox_color_selector.cpp b/libs/ui/widge= ts/kis_spinbox_color_selector.cpp new file mode 100644 index 0000000..1d8f211 --- /dev/null +++ b/libs/ui/widgets/kis_spinbox_color_selector.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ +#include "kis_spinbox_color_selector.h" +#include +#include +#include "kis_double_parse_spin_box.h" +#include "kis_int_parse_spin_box.h" +#include "kis_signal_compressor.h" + +#include "KoChannelInfo.h" +#include "KoColorSpaceTraits.h" +#include "KoColorSpaceMaths.h" +#include "KoColorSpaceRegistry.h" + +struct KisSpinboxColorSelector::Private +{ + QList spinBoxList; + QList doubleSpinBoxList; + KoColor color; + const KoColorSpace *cs; + bool chooseAlpha =3D false; +}; + +KisSpinboxColorSelector::KisSpinboxColorSelector(QWidget *parent) : QWidge= t(parent) , m_d(new Private) +{ + this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + + KoColor color =3D KoColor(); + m_d->color =3D color; + slotSetColorSpace(m_d->color.colorSpace()); +} +KisSpinboxColorSelector::~KisSpinboxColorSelector() +{ + +} + +void KisSpinboxColorSelector::slotSetColor(KoColor color) +{ + m_d->color =3D color; + if (m_d->color.colorSpace() !=3D m_d->cs) { + slotSetColorSpace(m_d->color.colorSpace()); + } + updateSpinboxesWithNewValues(); +} + +void KisSpinboxColorSelector::slotSetColorSpace(const KoColorSpace *cs) +{ + if (cs =3D=3D m_d->cs) { + return; + } + + m_d->cs =3D KoColorSpaceRegistry::instance()->colorSpace(cs->colorMode= lId().id(), cs->colorDepthId().id(), cs->profile()); + + //remake spinboxes + if (this->layout()) { + qDeleteAll(this->children()); + } + m_d->spinBoxList.clear(); + m_d->doubleSpinBoxList.clear(); + + QFormLayout *layout =3D new QFormLayout(this); + QList channels =3D KoChannelInfo::displayOrderSorted(= m_d->cs->channels()); + Q_FOREACH (KoChannelInfo* channel, channels) { + QString inputLabel =3D channel->name(); + switch (channel->channelValueType()) { + case KoChannelInfo::UINT8: { + KisIntParseSpinBox *input =3D new KisIntParseSpinBox(this); + input->setMinimum(0); + input->setMaximum(0xFF); + m_d->spinBoxList.append(input); + layout->addRow(inputLabel,input); + if (input) { + connect(input, SIGNAL(valueChanged(int)), this, SLOT(slot= UpdateFromSpinBoxes())); + } + if (channel->channelType()=3D=3DKoChannelInfo::ALPHA && m_d->c= hooseAlpha =3D=3D false) { + input->setEnabled(false); + input->blockSignals(true); + } + } + break; + case KoChannelInfo::UINT16: { + KisIntParseSpinBox *input =3D new KisIntParseSpinBox(this); + input->setMinimum(0); + input->setMaximum(0xFFFF); + m_d->spinBoxList.append(input); + layout->addRow(inputLabel,input); + if (input) { + connect(input, SIGNAL(valueChanged(int)), this, SLOT(slot= UpdateFromSpinBoxes())); + } + if (channel->channelType()=3D=3DKoChannelInfo::ALPHA && m_d->c= hooseAlpha =3D=3D false) { + input->setEnabled(false); + input->blockSignals(true); + } + } + break; + case KoChannelInfo::UINT32: { + KisIntParseSpinBox *input =3D new KisIntParseSpinBox(this); + input->setMinimum(0); + input->setMaximum(0xFFFFFFFF); + m_d->spinBoxList.append(input); + layout->addRow(inputLabel,input); + if (input) { + connect(input, SIGNAL(valueChanged(int)), this, SLOT(slot= UpdateFromSpinBoxes())); + } + if (channel->channelType()=3D=3DKoChannelInfo::ALPHA && m_d->c= hooseAlpha =3D=3D false) { + input->setEnabled(false); + input->blockSignals(true); + } + } + break; + case KoChannelInfo::FLOAT16: + case KoChannelInfo::FLOAT32: { + KisDoubleParseSpinBox *input =3D new KisDoubleParseSpinBox(thi= s); + input->setMinimum(0); + input->setMaximum(KoColorSpaceMathsTraits::max); + input->setSingleStep(0.1); + m_d->doubleSpinBoxList.append(input); + qDebug()<<"add "<name()<<"doubleSpinBoxList "<= doubleSpinBoxList.size(); + layout->addRow(inputLabel,input); + if (input) { + connect(input, SIGNAL(valueChanged(double)), this, SLOT(s= lotUpdateFromSpinBoxes())); + } + if (channel->channelType()=3D=3DKoChannelInfo::ALPHA && m_d->c= hooseAlpha =3D=3D false) { + input->setEnabled(false); + input->blockSignals(true); + } + } + break; + default: + Q_ASSERT(false); + } + + } + this->setLayout(layout); +} + +void KisSpinboxColorSelector::createColorFromSpinboxValues() +{ + KoColor newColor; + int channelcount =3D m_d->cs->channelCount(); + quint8 *data =3D new quint8[m_d->cs->pixelSize()]; + QVector channelValues(channelcount); + channelValues.fill(1.0); + QList channels =3D KoChannelInfo::displayOrderSorted(= m_d->cs->channels()); + + for (int i=3D0; ics->colorChannelCount()); i++) { + int channelposition =3D KoChannelInfo::displayPositionToChannelInd= ex(i, m_d->cs->channels()); + + if (channels.at(i)->channelValueType()=3D=3DKoChannelInfo::UINT8 &= & m_d->spinBoxList.at(i)){ + + int value =3D m_d->spinBoxList.at(i)->value(); + channelValues[channelposition] =3D KoColorSpaceMaths::scaleToA(value); + + } else if (channels.at(i)->channelValueType()=3D=3DKoChannelInfo::= UINT16 && m_d->spinBoxList.at(i)){ + + channelValues[channelposition] =3D KoColorSpaceMaths::scaleToA(m_d->spinBoxList.at(i)->value()); + + } else if ((channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT16 || + channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT32 || + channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT64) && m_d->doubleSpinBoxList.at(i)) { + + channelValues[channelposition] =3D m_d->doubleSpinBoxList.at(i= )->value(); + + } + } + + m_d->cs->fromNormalisedChannelsValue(data, channelValues); + newColor.setColor(data, m_d->cs); + newColor.setOpacity(m_d->color.opacityU8()); + + m_d->color =3D newColor; +} + +void KisSpinboxColorSelector::slotUpdateFromSpinBoxes() +{ + createColorFromSpinboxValues(); + emit sigNewColor(m_d->color); +} + +void KisSpinboxColorSelector::updateSpinboxesWithNewValues() +{ + int channelcount =3D m_d->cs->channelCount(); + QVector channelValues(channelcount); + channelValues.fill(1.0); + m_d->cs->normalisedChannelsValue(m_d->color.data(), channelValues); + QList channels =3D KoChannelInfo::displayOrderSorted(= m_d->cs->channels()); + + int i; + /*while (QLayoutItem *item =3D this->layout()->takeAt(0)) + { + item->widget()->blockSignals(true); + }*/ + for (i=3D0; ispinBoxList.size(); i++) { + m_d->spinBoxList.at(i)->blockSignals(true); + } + for (i=3D0; idoubleSpinBoxList.size(); i++) { + m_d->doubleSpinBoxList.at(i)->blockSignals(true); + } + + for (i=3D0; ics->colorChannelCount()); i++) { + int channelposition =3D KoChannelInfo::displayPositionToChannelInd= ex(i, m_d->cs->channels()); + if (channels.at(i)->channelValueType() =3D=3D KoChannelInfo::UINT8= && m_d->spinBoxList.at(i)) { + int value =3D KoColorSpaceMaths::scaleToA(chann= elValues[channelposition]); + m_d->spinBoxList.at(i)->setValue(value); + } else if (channels.at(i)->channelValueType() =3D=3D KoChannelInfo= ::UINT16 && m_d->spinBoxList.at(i)) { + m_d->spinBoxList.at(i)->setValue(KoColorSpaceMaths::scaleToA(channelValues[channelposition])); + } else if ((channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT16 || + channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT32 || + channels.at(i)->channelValueType()=3D=3DKoChannelInfo:= :FLOAT64) && m_d->doubleSpinBoxList.at(i)) { + m_d->doubleSpinBoxList.at(i)->setValue(channelValues[channelpo= sition]); + } + } + + for (i=3D0; ispinBoxList.size(); i++) { + m_d->spinBoxList.at(i)->blockSignals(false); + } + for (i=3D0; idoubleSpinBoxList.size(); i++) { + m_d->doubleSpinBoxList.at(i)->blockSignals(false); + } + /*while (QLayoutItem *item =3D this->layout()->takeAt(0)) + { + item->widget()->blockSignals(false); + }*/ +} + + diff --git a/libs/ui/widgets/kis_spinbox_color_selector.h b/libs/ui/widgets= /kis_spinbox_color_selector.h new file mode 100644 index 0000000..7c3106f --- /dev/null +++ b/libs/ui/widgets/kis_spinbox_color_selector.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ + +#ifndef KISSPINBOXCOLORSELECTOR_H +#define KISSPINBOXCOLORSELECTOR_H + +#include +#include "kritaui_export.h" +#include +#include "KoColor.h" +#include "KoColorSpace.h" + +/** + * @brief The KisSpinboxColorSelector class + * This will give a widget with spinboxes depending on the color space + * Take responsibility for changing the color space. + */ +class KRITAUI_EXPORT KisSpinboxColorSelector : public QWidget +{ + Q_OBJECT +public: + explicit KisSpinboxColorSelector(QWidget *parent); + ~KisSpinboxColorSelector(); + + void chooseAlpha(bool chooseAlpha); + +Q_SIGNALS: + + void sigNewColor(KoColor color); + +public Q_SLOTS: + + void slotSetColorSpace(const KoColorSpace *cs); + void slotSetColor(KoColor color); +private Q_SLOTS: + void slotUpdateFromSpinBoxes(); +private: + struct Private; + const QScopedPointer m_d; + void createColorFromSpinboxValues(); + void updateSpinboxesWithNewValues(); +}; + +#endif // KISSPINBOXCOLORSELECTOR_H diff --git a/libs/ui/widgets/kis_visual_color_selector.cpp b/libs/ui/widget= s/kis_visual_color_selector.cpp new file mode 100644 index 0000000..ab01388 --- /dev/null +++ b/libs/ui/widgets/kis_visual_color_selector.cpp @@ -0,0 +1,1602 @@ +/* + * Copyright (C) Wolthera van Hovell tot Westerflier , (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ +#include "kis_visual_color_selector.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "KoColorConversions.h" +#include "KoColorDisplayRendererInterface.h" +#include "KoChannelInfo.h" +#include +#include +#include "kis_signal_compressor.h" + +struct KisVisualColorSelector::Private +{ + KoColor currentcolor; + const KoColorSpace *currentCS; + QList widgetlist; + bool updateSelf =3D false; + bool updateLonesome =3D false; //for Modal dialogs. + bool circular =3D false; + const KoColorDisplayRendererInterface *displayRenderer =3D 0; + KisVisualColorSelector::Configuration acs_config; + //Current coordinates. + KisSignalCompressor *updateTimer =3D 0; + QVector currentCoordinates; +}; + +KisVisualColorSelector::KisVisualColorSelector(QWidget *parent) : QWidget(= parent), m_d(new Private) +{ + this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + QVBoxLayout *layout =3D new QVBoxLayout; + this->setLayout(layout); + + KConfigGroup cfg =3D KSharedConfig::openConfig()->group("advancedColo= rSelector"); + m_d->acs_config =3D Configuration::fromString(cfg.readEntry("colorSele= ctorConfiguration", KisVisualColorSelector::Configuration().toString())); + +} + +KisVisualColorSelector::~KisVisualColorSelector() +{ + +} + +void KisVisualColorSelector::slotSetColor(KoColor c) +{ + if (m_d->updateSelf=3D=3Dfalse) { + m_d->currentcolor =3D c; + if (m_d->currentCS !=3D c.colorSpace()) { + slotsetColorSpace(c.colorSpace()); + } + } + updateSelectorElements(QObject::sender()); +} + +void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) +{ + if (m_d->currentCS !=3D cs) + { + m_d->currentCS =3D cs; + slotRebuildSelectors(); + } + +} + +void KisVisualColorSelector::setConfig(bool forceCircular, bool forceSelfU= pdate) +{ + m_d->updateLonesome =3D forceSelfUpdate; + m_d->circular =3D forceCircular; +} + +KoColor KisVisualColorSelector::getCurrentColor() +{ + return m_d->currentcolor; +} + +void KisVisualColorSelector::ConfigurationChanged() +{ + m_d->updateTimer =3D new KisSignalCompressor(100 /* ms */, KisSignalC= ompressor::POSTPONE, this); + m_d->updateTimer->start(); + connect(m_d->updateTimer, SIGNAL(timeout()), SLOT(slotRebuildSelectors= ()), Qt::UniqueConnection); +} + +void KisVisualColorSelector::slotRebuildSelectors() +{ + KConfigGroup cfg =3D KSharedConfig::openConfig()->group("advancedColo= rSelector"); + m_d->acs_config =3D Configuration::fromString(cfg.readEntry("colorSele= ctorConfiguration", KisVisualColorSelector::Configuration().toString())); + + if (this->children().at(0)) { + qDeleteAll(this->children()); + } + m_d->widgetlist.clear(); + QLayout *layout =3D new QHBoxLayout; + //redraw all the widgets. + int sizeValue =3D qMin(width(), height()); + int borderWidth =3D qMax(sizeValue*0.1, 20.0); + + if (m_d->currentCS->colorChannelCount() =3D=3D 1) { + KisVisualColorSelectorShape *bar; + if (m_d->circular=3D=3Dfalse) { + bar =3D new KisVisualRectangleSelectorShape(this, KisVisualCo= lorSelectorShape::onedimensional,KisVisualColorSelectorShape::Channel, m_d-= >currentCS, 0, 0,m_d->displayRenderer, borderWidth); + bar->setMaximumWidth(width()*0.1); + bar->setMaximumHeight(height()); + + } else { + bar=3D new KisVisualEllipticalSelectorShape(this, KisVisualCo= lorSelectorShape::onedimensional,KisVisualColorSelectorShape::Channel, m_d-= >currentCS, 0, 0,m_d->displayRenderer, borderWidth, KisVisualEllipticalSele= ctorShape::borderMirrored); + layout->setMargin(0); + } + connect (bar, SIGNAL(sigNewColor(KoColor)), this, SLOT(updateFromW= idgets(KoColor))); + layout->addWidget(bar); + m_d->widgetlist.append(bar); + } else if (m_d->currentCS->colorChannelCount() =3D=3D 3) { + QRect newrect(0,0, this->geometry().width(), this->geometry().heig= ht()); + + + KisVisualColorSelectorShape::ColorModel modelS =3D KisVisualColorS= electorShape::HSV; + int channel1 =3D 0; + int channel2 =3D 1; + int channel3 =3D 2; + + switch(m_d->acs_config.subTypeParameter) + { + case H: + channel1 =3D 0; break; + case hsyS: + case hsiS: + case hslS: + case hsvS: + channel1 =3D 1; break; + case V: + case L: + case I: + case Y: + channel1 =3D 2; break; + } + + switch(m_d->acs_config.mainTypeParameter) + { + case hsySH: + modelS =3D KisVisualColorSelectorShape::HSY; + channel2 =3D 0; + channel3 =3D 1; + break; + case hsiSH: + modelS =3D KisVisualColorSelectorShape::HSI; + channel2 =3D 0; + channel3 =3D 1; + break; + case hslSH: + modelS =3D KisVisualColorSelectorShape::HSL; + channel2 =3D 0; + channel3 =3D 1; + break; + case hsvSH: + modelS =3D KisVisualColorSelectorShape::HSV; + channel2 =3D 0; + channel3 =3D 1; + break; + case YH: + modelS =3D KisVisualColorSelectorShape::HSY; + channel2 =3D 0; + channel3 =3D 2; + break; + case LH: + modelS =3D KisVisualColorSelectorShape::HSL; + channel2 =3D 0; + channel3 =3D 2; + break; + case IH: + modelS =3D KisVisualColorSelectorShape::HSL; + channel2 =3D 0; + channel3 =3D 2; + break; + case VH: + modelS =3D KisVisualColorSelectorShape::HSV; + channel2 =3D 0; + channel3 =3D 2; + break; + case SY: + modelS =3D KisVisualColorSelectorShape::HSY; + channel2 =3D 1; + channel3 =3D 2; + break; + case SI: + modelS =3D KisVisualColorSelectorShape::HSI; + channel2 =3D 1; + channel3 =3D 2; + break; + case SL: + modelS =3D KisVisualColorSelectorShape::HSL; + channel2 =3D 1; + channel3 =3D 2; + break; + case SV: + case SV2: + modelS =3D KisVisualColorSelectorShape::HSV; + channel2 =3D 1; + channel3 =3D 2; + break; + } + if (m_d->acs_config.mainType=3D=3DTriangle) { + modelS =3D KisVisualColorSelectorShape::HSV; + //Triangle only really works in HSV mode. + } + KisVisualColorSelectorShape *bar; + if (m_d->acs_config.subType=3D=3DRing) { + bar =3D new KisVisualEllipticalSelectorShape(this, + KisVisualColorSele= ctorShape::onedimensional, + modelS, + m_d->currentCS, ch= annel1, channel1, + m_d->displayRender= er, borderWidth,KisVisualEllipticalSelectorShape::border); + bar->resize(sizeValue, sizeValue); + } else if (m_d->acs_config.subType=3D=3DSlider && m_d->circular=3D= =3Dfalse) { + bar =3D new KisVisualRectangleSelectorShape(this, + KisVisualColorSelec= torShape::onedimensional, + modelS, + m_d->currentCS, cha= nnel1, channel1, + m_d->displayRendere= r, borderWidth); + bar->setMaximumWidth(borderWidth); + bar->setMinimumWidth(borderWidth); + bar->setMinimumHeight(sizeValue); + } else if (m_d->acs_config.subType=3D=3DSlider && m_d->circular=3D= =3Dtrue) { + bar =3D new KisVisualEllipticalSelectorShape(this, + KisVisualColorSelec= torShape::onedimensional, + modelS, + m_d->currentCS, cha= nnel1, channel1, + m_d->displayRendere= r, borderWidth, KisVisualEllipticalSelectorShape::borderMirrored); + bar->resize(sizeValue, sizeValue); + } + + bar->setColor(m_d->currentcolor); + m_d->widgetlist.append(bar); + + KisVisualColorSelectorShape *block; + if (m_d->acs_config.mainType=3D=3DTriangle) { + block =3D new KisVisualTriangleSelectorShape(this, KisVisualC= olorSelectorShape::twodimensional, + modelS, + m_d->currentCS, ch= annel2, channel3, + m_d->displayRender= er); + block->setGeometry(bar->getSpaceForTriangle(newrect)); + } else if (m_d->acs_config.mainType=3D=3DSquare) { + block =3D new KisVisualRectangleSelectorShape(this, KisVisual= ColorSelectorShape::twodimensional, + modelS, + m_d->currentCS, c= hannel2, channel3, + m_d->displayRende= rer); + block->setGeometry(bar->getSpaceForSquare(newrect)); + } else { + block =3D new KisVisualEllipticalSelectorShape(this, KisVisua= lColorSelectorShape::twodimensional, + modelS, + m_d->currentCS, = channel2, channel3, + m_d->displayRend= erer); + block->setGeometry(bar->getSpaceForCircle(newrect)); + + } + + block->setColor(m_d->currentcolor); + connect (bar, SIGNAL(sigNewColor(KoColor)), block, SLOT(setColorFr= omSibling(KoColor))); + connect (block, SIGNAL(sigNewColor(KoColor)), SLOT(updateFromWidge= ts(KoColor))); + connect (bar, SIGNAL(sigHSXchange()), SLOT(HSXwrangler())); + connect (block, SIGNAL(sigHSXchange()), SLOT(HSXwrangler())); + m_d->widgetlist.append(block); + + + } else if (m_d->currentCS->colorChannelCount() =3D=3D 4) { + KisVisualRectangleSelectorShape *block =3D new KisVisualRectangle= SelectorShape(this, KisVisualRectangleSelectorShape::twodimensional,KisVisu= alColorSelectorShape::Channel, m_d->currentCS, 0, 1); + KisVisualRectangleSelectorShape *block2 =3D new KisVisualRectangl= eSelectorShape(this, KisVisualRectangleSelectorShape::twodimensional,KisVis= ualColorSelectorShape::Channel, m_d->currentCS, 2, 3); + block->setMaximumWidth(width()*0.5); + block->setMaximumHeight(height()); + block2->setMaximumWidth(width()*0.5); + block2->setMaximumHeight(height()); + block->setColor(m_d->currentcolor); + block2->setColor(m_d->currentcolor); + connect (block, SIGNAL(sigNewColor(KoColor)), block2, SLOT(setColo= rFromSibling(KoColor))); + connect (block2, SIGNAL(sigNewColor(KoColor)), SLOT(updateFromWidg= ets(KoColor))); + layout->addWidget(block); + layout->addWidget(block2); + m_d->widgetlist.append(block); + m_d->widgetlist.append(block2); + } + this->setLayout(layout); +} + +void KisVisualColorSelector::setDisplayRenderer (const KoColorDisplayRende= rerInterface *displayRenderer) { + m_d->displayRenderer =3D displayRenderer; + if (m_d->widgetlist.size()>0) { + Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { + shape->setDisplayRenderer(displayRenderer); + } + } +} + +void KisVisualColorSelector::updateSelectorElements(QObject *source) +{ + //first lock all elements from sending updates, then update all elemen= ts. + Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { + shape->blockSignals(true); + } + + Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { + if (shape!=3Dsource) { + if (m_d->updateSelf) { + shape->setColorFromSibling(m_d->currentcolor); + } else { + shape->setColor(m_d->currentcolor); + } + } + } + Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { + shape->blockSignals(false); + } + +} + +void KisVisualColorSelector::updateFromWidgets(KoColor c) +{ + m_d->currentcolor =3D c; + m_d->updateSelf =3D true; + if (m_d->updateLonesome) { + slotSetColor(c); + } else { + Q_EMIT sigNewColor(c); + } +} + +void KisVisualColorSelector::leaveEvent(QEvent *) +{ + m_d->updateSelf =3D false; +} + +void KisVisualColorSelector::resizeEvent(QResizeEvent *) { + int sizeValue =3D qMin(width(), height()); + int borderWidth =3D qMax(sizeValue*0.1, 20.0); + QRect newrect(0,0, this->geometry().width(), this->geometry().height()= ); + if (!m_d->currentCS) { + slotsetColorSpace(m_d->currentcolor.colorSpace()); + } + if (m_d->currentCS->colorChannelCount()=3D=3D3) { + if (m_d->acs_config.subType=3D=3DRing) { + m_d->widgetlist.at(0)->resize(sizeValue,sizeValue); + } else if (m_d->acs_config.subType=3D=3DSlider && m_d->circular=3D= =3Dfalse) { + m_d->widgetlist.at(0)->setMaximumWidth(borderWidth); + m_d->widgetlist.at(0)->setMinimumWidth(borderWidth); + m_d->widgetlist.at(0)->setMinimumHeight(sizeValue); + m_d->widgetlist.at(0)->setMaximumHeight(sizeValue); + } else if (m_d->acs_config.subType=3D=3DSlider && m_d->circular=3D= =3Dtrue) { + m_d->widgetlist.at(0)->resize(sizeValue,sizeValue); + } + m_d->widgetlist.at(0)->setBorderWidth(borderWidth); + + if (m_d->acs_config.mainType=3D=3DTriangle) { + m_d->widgetlist.at(1)->setGeometry(m_d->widgetlist.at(0)->getS= paceForTriangle(newrect)); + } else if (m_d->acs_config.mainType=3D=3DSquare) { + m_d->widgetlist.at(1)->setGeometry(m_d->widgetlist.at(0)->getS= paceForSquare(newrect)); + } else if (m_d->acs_config.mainType=3D=3DWheel) { + m_d->widgetlist.at(1)->setGeometry(m_d->widgetlist.at(0)->getS= paceForCircle(newrect)); + } + } + Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { + shape->update(); + } +} + +void KisVisualColorSelector::HSXwrangler() +{ + m_d->currentCoordinates =3D QVector (3); + + QVector w1 =3D m_d->widgetlist.at(0)->getHSX(m_d->currentCoord= inates, true); + QVector w2 =3D m_d->widgetlist.at(1)->getHSX(m_d->currentCoord= inates, true); + QVector ch(3); + + ch[0] =3D m_d->widgetlist.at(0)->getChannels().at(0); + ch[1] =3D m_d->widgetlist.at(1)->getChannels().at(0); + ch[2] =3D m_d->widgetlist.at(1)->getChannels().at(1); + + m_d->currentCoordinates[ch[0]] =3D w1[ch[0]]; + m_d->currentCoordinates[ch[1]] =3D w2[ch[1]]; + m_d->currentCoordinates[ch[2]] =3D w2[ch[2]]; + + m_d->widgetlist.at(0)->setHSX(m_d->currentCoordinates, true); + m_d->widgetlist.at(1)->setHSX(m_d->currentCoordinates, true); +} + +/*------------Selector shape------------*/ +struct KisVisualColorSelectorShape::Private +{ + QImage gradient; + QImage fullSelector; + bool imagesNeedUpdate=3D true; + QPointF currentCoordinates; + Dimensions dimension; + ColorModel model; + const KoColorSpace *cs; + KoColor currentColor; + int channel1; + int channel2; + KisSignalCompressor *updateTimer; + KisSignalCompressor *siblingTimer; + bool mousePressActive =3D false; + const KoColorDisplayRendererInterface *displayRenderer =3D 0; + qreal hue =3D 0.0; + qreal sat =3D 0.0; + qreal tone =3D 0.0; + +}; + +KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, + KisVisualColorSel= ectorShape::Dimensions dimension, + KisVisualColorSel= ectorShape::ColorModel model, + const KoColorSpac= e *cs, + int channel1, + int channel2, + const KoColorDisp= layRendererInterface *displayRenderer): QWidget(parent), m_d(new Private) +{ + m_d->dimension =3D dimension; + m_d->model =3D model; + m_d->cs =3D cs; + m_d->currentColor =3D KoColor(); + m_d->currentColor.setOpacity(1.0); + m_d->currentColor.convertTo(cs); + int maxchannel =3D m_d->cs->colorChannelCount()-1; + m_d->channel1 =3D qBound(0, channel1, maxchannel); + m_d->channel2 =3D qBound(0, channel2, maxchannel); + this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_d->updateTimer =3D new KisSignalCompressor(100 /* ms */, KisSignalCo= mpressor::POSTPONE, this); + m_d->siblingTimer =3D new KisSignalCompressor(30 /* ms */, KisSignalCo= mpressor::POSTPONE, this); + setDisplayRenderer(displayRenderer); + show(); + +} + +KisVisualColorSelectorShape::~KisVisualColorSelectorShape() +{ + +} + +void KisVisualColorSelectorShape::updateCursor() +{ + QPointF point1 =3D convertKoColorToShapeCoordinate(m_d->currentColor); + if (point1 !=3D m_d->currentCoordinates) { + m_d->currentCoordinates =3D point1; + } +} + +QPointF KisVisualColorSelectorShape::getCursorPosition() { + return m_d->currentCoordinates; +} + +void KisVisualColorSelectorShape::setColor(KoColor c) +{ + if (c.colorSpace() !=3D m_d->cs) { + c.convertTo(m_d->cs); + } + m_d->currentColor =3D c; + updateCursor(); + m_d->imagesNeedUpdate =3D true; + update(); +} + +void KisVisualColorSelectorShape::setColorFromSibling(KoColor c) +{ + if (c.colorSpace() !=3D m_d->cs) { + c.convertTo(m_d->cs); + } + m_d->currentColor =3D c; + Q_EMIT sigNewColor(c); + m_d->imagesNeedUpdate =3D true; + update(); +} + +void KisVisualColorSelectorShape::setDisplayRenderer (const KoColorDisplay= RendererInterface *displayRenderer) +{ + if (displayRenderer) { + if (m_d->displayRenderer) { + m_d->displayRenderer->disconnect(this); + } + m_d->displayRenderer =3D displayRenderer; + } else { + m_d->displayRenderer =3D KoDumbColorDisplayRenderer::instance(); + } + connect(m_d->displayRenderer, SIGNAL(displayConfigurationChanged()), + SLOT(updateFromChangedDisplayRenderer()), Qt::UniqueConnection= ); + +} + +void KisVisualColorSelectorShape::updateFromChangedDisplayRenderer() +{ + m_d->imagesNeedUpdate =3D true; + updateCursor(); + //m_d->currentColor =3D convertShapeCoordinateToKoColor(getCursorPosit= ion()); + update(); +} + +void KisVisualColorSelectorShape::forceImageUpdate() +{ + m_d->imagesNeedUpdate =3D true; +} + +QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){ + QColor col; + KoColor color =3D c; + if (m_d->displayRenderer) { + color.convertTo(m_d->displayRenderer->getPaintingColorSpace()); + col =3D m_d->displayRenderer->toQColor(c); + } else { + col =3D c.toQColor(); + } + return col; +} + +void KisVisualColorSelectorShape::slotSetActiveChannels(int channel1, int = channel2) +{ + int maxchannel =3D m_d->cs->colorChannelCount()-1; + m_d->channel1 =3D qBound(0, channel1, maxchannel); + m_d->channel2 =3D qBound(0, channel2, maxchannel); + m_d->imagesNeedUpdate =3D true; + update(); +} + +QImage KisVisualColorSelectorShape::getImageMap() +{ + if (m_d->imagesNeedUpdate =3D=3D true) { + m_d->imagesNeedUpdate =3D false; + m_d->gradient =3D QImage(width(), height(), QImage::Format_ARGB32); + m_d->gradient.fill(Qt::transparent); + QImage img(width(), height(), QImage::Format_ARGB32); + img.fill(Qt::transparent); + for (int y =3D 0; y(img.scanLine(y)); + for (int x=3D0; xgradient =3D img; + } + return m_d->gradient; +} + +KoColor KisVisualColorSelectorShape::convertShapeCoordinateToKoColor(QPoin= tF coordinates, bool cursor) +{ + KoColor c =3D m_d->currentColor; + QVector channelValues (c.colorSpace()->channelCount()); + channelValues.fill(1.0); + c.colorSpace()->normalisedChannelsValue(c.data(), channelValues); + QVector channelValuesDisplay =3D channelValues; + QVector maxvalue(c.colorSpace()->channelCount()); + maxvalue.fill(1.0); + if (m_d->displayRenderer + && (m_d->cs->colorDepthId() =3D=3D Float16BitsColorDepthID + || m_d->cs->colorDepthId() =3D=3D Float32BitsColorDepthID + || m_d->cs->colorDepthId() =3D=3D Float64BitsColorDepthID) + && m_d->cs->colorModelId() !=3D LABAColorModelID + && m_d->cs->colorModelId() !=3D CMYKAColorModelID) { + for (int ch =3D 0; chcs->channels()[ch]; + maxvalue[ch] =3D m_d->displayRenderer->maxVisibleFloatValue(ch= annel); + channelValues[ch] =3D channelValues[ch]/(maxvalue[ch]); + channelValuesDisplay[KoChannelInfo::displayPositionToChannelIn= dex(ch, m_d->cs->channels())] =3D channelValues[ch]; + } + } else { + for (int i =3D0; ics->channels())] =3D qBound((float)0.0,channelValues[i], (float= )1.0); + } + } + qreal huedivider =3D 1.0; + qreal huedivider2 =3D 1.0; + + if (m_d->channel1=3D=3D0) { + huedivider =3D 360.0; + } + if (m_d->channel2=3D=3D0) { + huedivider2 =3D 360.0; + } + if (m_d->model !=3D ColorModel::Channel && c.colorSpace()->colorModelI= d().id() =3D=3D "RGBA") { + if (c.colorSpace()->colorModelId().id() =3D=3D "RGBA") { + if (m_d->model =3D=3D ColorModel::HSV){ + /* + * RGBToHSV has a undefined hue possibility. This means th= at hue will be -1. + * This can be annoying for dealing with a selector, but I= understand it is being + * used for the KoColorSelector... For now implement a qMa= x here. + */ + QVector inbetween(3); + RGBToHSV(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2]); + inbetween =3D convertvectorqrealTofloat(getHSX(convertvect= orfloatToqreal(inbetween))); + inbetween[m_d->channel1] =3D coordinates.x()*huedivider; + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + inbetween[m_d->channel2] =3D coordinates.y()*huedivide= r2; + } + if (cursor=3D=3Dtrue){setHSX(convertvectorfloatToqreal(inb= etween));Q_EMIT sigHSXchange();} + HSVToRGB(qMax(inbetween[0],(float)0.0), inbetween[1], inbe= tween[2], &channelValuesDisplay[0], &channelValuesDisplay[1], &channelValue= sDisplay[2]); + } else if (m_d->model =3D=3D ColorModel::HSL) { + /* + * HSLToRGB can give negative values on the grey. I fixed = the fromNormalisedChannel function to clamp, + * but you might want to manually clamp for floating point= values. + */ + QVector inbetween(3); + RGBToHSL(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2]); + inbetween =3D convertvectorqrealTofloat(getHSX(convertvect= orfloatToqreal(inbetween))); + inbetween[m_d->channel1] =3D fmod(coordinates.x()*huedivid= er, 360.0); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + inbetween[m_d->channel2] =3D coordinates.y()*huedivide= r2; + } + if (cursor=3D=3Dtrue){setHSX(convertvectorfloatToqreal(inb= etween));Q_EMIT sigHSXchange();} + HSLToRGB(qMax(inbetween[0],(float)0.0), inbetween[1], inbe= tween[2],&channelValuesDisplay[0],&channelValuesDisplay[1], &channelValuesD= isplay[2]); + } else if (m_d->model =3D=3D ColorModel::HSI) { + /* + * HSI is a modified HSY function. + */ + QVector chan2 =3D convertvectorfloatToqreal(channe= lValuesDisplay); + QVector inbetween(3); + RGBToHSI(chan2[0],chan2[1], chan2[2], &inbetween[0], &inbe= tween[1], &inbetween[2]); + inbetween =3D getHSX(inbetween); + inbetween[m_d->channel1] =3D coordinates.x(); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + inbetween[m_d->channel2] =3D coordinates.y(); + } + if (cursor=3D=3Dtrue){setHSX(inbetween);Q_EMIT sigHSXchang= e();} + HSIToRGB(inbetween[0], inbetween[1], inbetween[2],&chan2[0= ],&chan2[1], &chan2[2]); + channelValuesDisplay =3D convertvectorqrealTofloat(chan2); + } else /*if (m_d->model =3D=3D ColorModel::HSY)*/ { + /* + * HSY is pretty slow to render due being a pretty over-th= e-top function. + * Might be worth investigating whether HCY can be used in= stead, but I have had + * some weird results with that. + */ + QVector luma=3D m_d->cs->lumaCoefficients(); + QVector chan2 =3D convertvectorfloatToqreal(channe= lValuesDisplay); + QVector inbetween(3); + RGBToHSY(chan2[0],chan2[1], chan2[2], &inbetween[0], &inbe= tween[1], &inbetween[2], + luma[0], luma[1], luma[2]); + inbetween =3D getHSX(inbetween); + inbetween[m_d->channel1] =3D coordinates.x(); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + inbetween[m_d->channel2] =3D coordinates.y(); + } + if (cursor=3D=3Dtrue){setHSX(inbetween);Q_EMIT sigHSXchang= e();} + HSYToRGB(inbetween[0], inbetween[1], inbetween[2],&chan2[0= ],&chan2[1], &chan2[2], + luma[0], luma[1], luma[2]); + channelValuesDisplay =3D convertvectorqrealTofloat(chan2); + } + } + } else { + channelValuesDisplay[m_d->channel1] =3D coordinates.x(); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + channelValuesDisplay[m_d->channel2] =3D coordinates.y(); + } + } + for (int i=3D0; ics->channels())]*(maxvalue[i]); + } + c.colorSpace()->fromNormalisedChannelsValue(c.data(), channelValues); + return c; +} + +QPointF KisVisualColorSelectorShape::convertKoColorToShapeCoordinate(KoCol= or c) +{ + if (c.colorSpace() !=3D m_d->cs) { + c.convertTo(m_d->cs); + } + QVector channelValues (m_d->currentColor.colorSpace()->channel= Count()); + channelValues.fill(1.0); + m_d->cs->normalisedChannelsValue(c.data(), channelValues); + QVector channelValuesDisplay =3D channelValues; + QVector maxvalue(c.colorSpace()->channelCount()); + maxvalue.fill(1.0); + if (m_d->displayRenderer + && (m_d->cs->colorDepthId() =3D=3D Float16BitsColorDepthID + || m_d->cs->colorDepthId() =3D=3D Float32BitsColorDepthID + || m_d->cs->colorDepthId() =3D=3D Float64BitsColorDepthID) + && m_d->cs->colorModelId() !=3D LABAColorModelID + && m_d->cs->colorModelId() !=3D CMYKAColorModelID) { + for (int ch =3D 0; chcs->channels()[ch]; + maxvalue[ch] =3D m_d->displayRenderer->maxVisibleFloatValue(ch= annel); + channelValues[ch] =3D channelValues[ch]/(maxvalue[ch]); + channelValuesDisplay[KoChannelInfo::displayPositionToChannelIn= dex(ch, m_d->cs->channels())] =3D channelValues[ch]; + } + } else { + for (int i =3D0; ics->channels())] =3D qBound((float)0.0,channelValues[i], (float= )1.0); + } + } + QPointF coordinates(0.0,0.0); + qreal huedivider =3D 1.0; + qreal huedivider2 =3D 1.0; + if (m_d->channel1=3D=3D0) { + huedivider =3D 360.0; + } + if (m_d->channel2=3D=3D0) { + huedivider2 =3D 360.0; + } + if (m_d->model !=3D ColorModel::Channel && c.colorSpace()->colorModelI= d().id() =3D=3D "RGBA") { + if (c.colorSpace()->colorModelId().id() =3D=3D "RGBA") { + if (m_d->model =3D=3D ColorModel::HSV){ + QVector inbetween(3); + RGBToHSV(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2]); + inbetween =3D convertvectorqrealTofloat(getHSX(convertvect= orfloatToqreal(inbetween))); + coordinates.setX(inbetween[m_d->channel1]/huedivider); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + coordinates.setY(inbetween[m_d->channel2]/huedivider2); + } + } else if (m_d->model =3D=3D ColorModel::HSL) { + QVector inbetween(3); + RGBToHSL(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2]); + inbetween =3D convertvectorqrealTofloat(getHSX(convertvect= orfloatToqreal(inbetween))); + coordinates.setX(inbetween[m_d->channel1]/huedivider); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + coordinates.setY(inbetween[m_d->channel2]/huedivider2); + } + } else if (m_d->model =3D=3D ColorModel::HSI) { + QVector chan2 =3D convertvectorfloatToqreal(channe= lValuesDisplay); + QVector inbetween(3); + RGBToHSI(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2]); + inbetween =3D getHSX(inbetween); + coordinates.setX(inbetween[m_d->channel1]); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + coordinates.setY(inbetween[m_d->channel2]); + } + } else if (m_d->model =3D=3D ColorModel::HSY) { + QVector luma =3D m_d->cs->lumaCoefficients(); + QVector chan2 =3D convertvectorfloatToqreal(channe= lValuesDisplay); + QVector inbetween(3); + RGBToHSY(channelValuesDisplay[0],channelValuesDisplay[1], = channelValuesDisplay[2], &inbetween[0], &inbetween[1], &inbetween[2], luma[= 0], luma[1], luma[2]); + inbetween =3D getHSX(inbetween); + coordinates.setX(inbetween[m_d->channel1]); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + coordinates.setY(inbetween[m_d->channel2]); + } + } + } + } else { + coordinates.setX(qBound((float)0.0, channelValuesDisplay[m_d->chan= nel1], (float)1.0)); + if (m_d->dimension =3D=3D Dimensions::twodimensional) { + coordinates.setY(qBound((float)0.0, channelValuesDisplay[m_d->= channel2], (float)1.0)); + } + } + return coordinates; +} + +QVector KisVisualColorSelectorShape::convertvectorqrealTofloat(QVec= tor real) +{ + QVector vloat(real.size()); + for (int i=3D0; i KisVisualColorSelectorShape::convertvectorfloatToqreal(QVec= tor vloat) +{ + QVector real(vloat.size()); + for (int i=3D0; imousePressActive =3D true; + QPointF coordinates =3D convertWidgetCoordinateToShapeCoordinate(e->po= s()); + KoColor col =3D convertShapeCoordinateToKoColor(coordinates, true); + setColor(col); + Q_EMIT sigNewColor(col); + m_d->updateTimer->start(); +} + +void KisVisualColorSelectorShape::mouseMoveEvent(QMouseEvent *e) +{ + if (m_d->mousePressActive=3D=3Dtrue && this->mask().contains(e->pos())= ) { + QPointF coordinates =3D convertWidgetCoordinateToShapeCoordinate(e= ->pos()); + KoColor col =3D convertShapeCoordinateToKoColor(coordinates, true); + setColor(col); + if (!m_d->updateTimer->isActive()) { + Q_EMIT sigNewColor(col); + m_d->updateTimer->start(); + } + } else { + e->ignore(); + } +} + +void KisVisualColorSelectorShape::mouseReleaseEvent(QMouseEvent *) +{ + m_d->mousePressActive =3D false; +} +void KisVisualColorSelectorShape::paintEvent(QPaintEvent*) +{ + QPainter painter(this); + + //check if old and new colors differ. + + if (m_d->imagesNeedUpdate) { + setMask(getMaskMap()); + } + drawCursor(); + painter.drawImage(0,0,m_d->fullSelector); +} + +KisVisualColorSelectorShape::Dimensions KisVisualColorSelectorShape::getDi= mensions() +{ + return m_d->dimension; +} + +KisVisualColorSelectorShape::ColorModel KisVisualColorSelectorShape::getCo= lorModel() +{ + return m_d->model; +} + +void KisVisualColorSelectorShape::setFullImage(QImage full) +{ + m_d->fullSelector =3D full; +} +KoColor KisVisualColorSelectorShape::getCurrentColor() +{ + return m_d->currentColor; +} + +QVector KisVisualColorSelectorShape::getHSX(QVector hsx, bo= ol wrangler) +{ + QVector ihsx =3D hsx; + if (!wrangler){ + //Ok, so this docker will not update luminosity if there's not at = the least 3% more variation. + //This is necessary for 8bit. + if (m_d->cs->colorDepthId()=3D=3DInteger8BitsColorDepthID){ + if (hsx[2]>m_d->tone-0.03 && hsx[2]tone+0.03) { + ihsx[2] =3D m_d->tone; + } + } else { + if (hsx[2]>m_d->tone-0.005 && hsx[2]tone+0.005) { + ihsx[2] =3D m_d->tone; + } + } + if (m_d->model=3D=3DHSV){ + if (hsx[2]<=3D0.0) { + ihsx[1] =3D m_d->sat; + } + } else { + if ((hsx[2]<=3D0.0 || hsx[2]>=3D1.0)) { + ihsx[1] =3D m_d->sat; + } + } + if ((hsx[1]<=3D0.0 || hsx[0]<0.0)){ + ihsx[0]=3Dm_d->hue; + } + } else { + ihsx[0]=3Dm_d->hue; + ihsx[1]=3Dm_d->sat; + ihsx[2]=3Dm_d->tone; + } + return ihsx; +} + +void KisVisualColorSelectorShape::setHSX(QVector hsx, bool wrangler) +{ + if (wrangler){ + m_d->tone =3D hsx[2]; + m_d->sat =3D hsx[1]; + m_d->hue =3D hsx[0]; + } else { + if (m_d->channel1=3D=3D2 || m_d->channel2=3D=3D2){ + m_d->tone=3Dhsx[2]; + } + if (m_d->model=3D=3DHSV){ + if (hsx[2]>0.0) { + m_d->sat =3D hsx[1]; + } + } else { + if ((hsx[2]>0.0 || hsx[2]<1.0)) { + m_d->sat =3D hsx[1]; + } + } + if ((hsx[1]>0.0 && hsx[0]>=3D0.0)){ + m_d->hue =3D hsx[0]; + } + } +} + +QVector KisVisualColorSelectorShape::getChannels() +{ + QVector channels(2); + channels[0] =3D m_d->channel1; + channels[1] =3D m_d->channel2; + return channels; +} + +/*-----------Rectangle Shape------------*/ + +KisVisualRectangleSelectorShape::KisVisualRectangleSelectorShape(QWidget *= parent, + Dimension= s dimension, + ColorMode= l model, + const KoC= olorSpace *cs, + int chann= el1, int channel2, + const KoC= olorDisplayRendererInterface *displayRenderer, + int width, + singelDTy= pes d) + : KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, = channel2, displayRenderer) +{ + m_type =3D d; + m_barWidth =3D width; +} + +KisVisualRectangleSelectorShape::~KisVisualRectangleSelectorShape() +{ + +} + +void KisVisualRectangleSelectorShape::setBorderWidth(int width) +{ + m_barWidth =3D width; +} + +QRect KisVisualRectangleSelectorShape::getSpaceForSquare(QRect geom) +{ + QPointF tl; + QPointF br; + + if (m_type=3D=3DKisVisualRectangleSelectorShape::vertical) { + br =3D geom.bottomRight(); + tl =3D QPoint(geom.topLeft().x()+m_barWidth, geom.topLeft().y()); + } else if (m_type=3D=3DKisVisualRectangleSelectorShape::horizontal) { + br =3D geom.bottomRight(); + tl =3D QPoint(geom.topLeft().x(), geom.topLeft().y()+m_barWidth); + } else { + tl =3D QPointF (geom.topLeft().x()+m_barWidth, geom.topLeft().y()+= m_barWidth); + br =3D QPointF (geom.bottomRight().x()-m_barWidth, geom.bottomRigh= t().y()-m_barWidth); + + } + QRect a(tl.toPoint(), br.toPoint()); + QRect r(a.left(), a.top(), qMin(a.height(), a.width()), qMin(a.height(= ), a.width())); + return r; +} + +QRect KisVisualRectangleSelectorShape::getSpaceForCircle(QRect geom) +{ + return getSpaceForSquare(geom); +} + +QRect KisVisualRectangleSelectorShape::getSpaceForTriangle(QRect geom) +{ + return getSpaceForSquare(geom); +} + +QPointF KisVisualRectangleSelectorShape::convertShapeCoordinateToWidgetCoo= rdinate(QPointF coordinate) +{ + qreal x =3D m_barWidth/2; + qreal y =3D m_barWidth/2; + qreal offset =3D 5.0; + KisVisualColorSelectorShape::Dimensions dimension =3D getDimensions(); + if (dimension =3D=3D KisVisualColorSelectorShape::onedimensional) { + if ( m_type =3D=3D KisVisualRectangleSelectorShape::vertical) { + y =3D qMin(coordinate.x()*(height()-offset*2)+offset, (qreal)h= eight()); + } else if (m_type =3D=3D KisVisualRectangleSelectorShape::horizont= al) { + x =3D qMin(coordinate.x()*(width()-offset*2)+offset, (qreal)wi= dth()); + } else if (m_type =3D=3D KisVisualRectangleSelectorShape::border) { + + QRectF innerRect(m_barWidth/2, m_barWidth/2, width()-m_barWidt= h, height()-m_barWidth); + QPointF left (innerRect.left(),innerRect.center().y()); + QList polygonLines; + polygonLines.append(QLineF(left, innerRect.topLeft())); + polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topR= ight())); + polygonLines.append(QLineF(innerRect.topRight(), innerRect.bot= tomRight())); + polygonLines.append(QLineF(innerRect.bottomRight(), innerRect.= bottomLeft())); + polygonLines.append(QLineF(innerRect.bottomLeft(), left)); + + qreal totalLength =3D0.0; + Q_FOREACH(QLineF line, polygonLines) { + totalLength +=3D line.length(); + } + + qreal length =3D coordinate.x()*totalLength; + QPointF intersect(x,y); + Q_FOREACH(QLineF line, polygonLines) { + if (line.length()>length && length>0){ + intersect =3D line.pointAt(length/line.length()); + + } + length-=3Dline.length(); + } + x =3D qRound(intersect.x()); + y =3D qRound(intersect.y()); + + } else /*if (m_type =3D=3D KisVisualRectangleSelectorShape::border= Mirrored)*/ { + + QRectF innerRect(m_barWidth/2, m_barWidth/2, width()-m_barWidt= h, height()-m_barWidth); + QPointF bottom (innerRect.center().x(), innerRect.bottom()); + QList polygonLines; + polygonLines.append(QLineF(bottom, innerRect.bottomLeft())); + polygonLines.append(QLineF(innerRect.bottomLeft(), innerRect.t= opLeft())); + polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topR= ight())); + polygonLines.append(QLineF(innerRect.topRight(), innerRect.bot= tomRight())); + polygonLines.append(QLineF(innerRect.bottomRight(), bottom)); + + qreal totalLength =3D0.0; + Q_FOREACH(QLineF line, polygonLines) { + totalLength +=3D line.length(); + } + + qreal length =3D coordinate.x()*(totalLength/2); + QPointF intersect(x,y); + if (coordinate.y()=3D=3D1) { + for (int i =3D polygonLines.size()-1; i=3D=3D0; i--) { + QLineF line =3D polygonLines.at(i); + if (line.length()>length && length>0){ + intersect =3D line.pointAt(length/line.length()); + + } + length-=3Dline.length(); + } + } else { + Q_FOREACH(QLineF line, polygonLines) { + if (line.length()>length && length>0){ + intersect =3D line.pointAt(length/line.length()); + + } + length-=3Dline.length(); + } + } + x =3D qRound(intersect.x()); + y =3D qRound(intersect.y()); + + } + } else { + x =3D qMin(coordinate.x()*(height()-offset*2)+offset, (qreal)heigh= t()); + y =3D qMin(coordinate.y()*(width()-offset*2)+offset, (qreal)width(= )); + } + return QPointF(x,y); +} + +QPointF KisVisualRectangleSelectorShape::convertWidgetCoordinateToShapeCoo= rdinate(QPoint coordinate) +{ + //default implementation: + qreal x =3D 0.5; + qreal y =3D 0.5; + qreal offset =3D 5.0; + KisVisualColorSelectorShape::Dimensions dimension =3D getDimensions(); + if (getMaskMap().contains(coordinate)) { + if (dimension =3D=3D KisVisualColorSelectorShape::onedimensional )= { + if (m_type =3D=3D KisVisualRectangleSelectorShape::vertical) { + x =3D qMax(((qreal)coordinate.y()-offset)/((qreal)height()= -offset*2), 0.0); + } else if (m_type =3D=3D KisVisualRectangleSelectorShape::hori= zontal) { + x =3D qMax(((qreal)coordinate.x()-offset)/((qreal)width()-= offset*2),0.0); + } else if (m_type =3D=3D KisVisualRectangleSelectorShape::bord= er) { + //border + + QRectF innerRect(m_barWidth, m_barWidth, width()-(m_barWid= th*2), height()-(m_barWidth*2)); + QPointF left (innerRect.left(),innerRect.center().y()); + QList polygonLines; + polygonLines.append(QLineF(left, innerRect.topLeft())); + polygonLines.append(QLineF(innerRect.topLeft(), innerRect.= topRight())); + polygonLines.append(QLineF(innerRect.topRight(), innerRect= .bottomRight())); + polygonLines.append(QLineF(innerRect.bottomRight(), innerR= ect.bottomLeft())); + polygonLines.append(QLineF(innerRect.bottomLeft(), left)); + + QLineF radius(coordinate, this->geometry().center()); + QPointF intersect(0.5,0.5); + qreal length =3D 0.0; + qreal totalLength =3D 0.0; + bool foundIntersect =3D false; + Q_FOREACH(QLineF line, polygonLines) { + if (line.intersect(radius,&intersect)=3D=3DQLineF::Bou= ndedIntersection && foundIntersect=3D=3Dfalse) + { + foundIntersect =3D true; + length+=3DQLineF(line.p1(), intersect).length(); + + } + if (foundIntersect=3D=3Dfalse) { + length+=3Dline.length(); + } + totalLength+=3Dline.length(); + } + + x =3D length/totalLength; + + } else /*if (m_type =3D=3D KisVisualRectangleSelectorShape::bo= rderMirrored)*/ { + //border + + QRectF innerRect(m_barWidth, m_barWidth, width()-(m_barWid= th*2), height()-(m_barWidth*2)); + QPointF bottom (innerRect.center().x(), innerRect.bottom()= ); + QList polygonLines; + polygonLines.append(QLineF(bottom, innerRect.bottomLeft())= ); + polygonLines.append(QLineF(innerRect.bottomLeft(), innerRe= ct.topLeft())); + polygonLines.append(QLineF(innerRect.topLeft(), innerRect.= topRight())); + polygonLines.append(QLineF(innerRect.topRight(), innerRect= .bottomRight())); + polygonLines.append(QLineF(innerRect.bottomRight(), bottom= )); + + QLineF radius(coordinate, this->geometry().center()); + QPointF intersect(0.5,0.5); + qreal length =3D 0.0; + qreal totalLength =3D 0.0; + bool foundIntersect =3D false; + Q_FOREACH(QLineF line, polygonLines) { + if (line.intersect(radius,&intersect)=3D=3DQLineF::Bou= ndedIntersection && foundIntersect=3D=3Dfalse) + { + foundIntersect =3D true; + length+=3DQLineF(line.p1(), intersect).length(); + + } + if (foundIntersect=3D=3Dfalse) { + length+=3Dline.length(); + } + totalLength+=3Dline.length(); + } + int halflength =3D totalLength/2; + + if (length>halflength) { + x =3D (halflength - (length-halflength))/halflength; + y =3D 1.0; + } else { + x =3D length/halflength; + y =3D 0.0; + } + } + } + else { + x =3D qMax(((qreal)coordinate.x()-offset)/((qreal)width()-offs= et*2), 0.0); + y =3D qMax(((qreal)coordinate.y()-offset)/((qreal)height()-off= set*2), 0.0);; + } + } + return QPointF(x, y); +} + +QRegion KisVisualRectangleSelectorShape::getMaskMap() +{ + QRegion mask =3D QRegion(0,0,width(),height()); + if (m_type=3D=3DKisVisualRectangleSelectorShape::border || m_type=3D= =3DKisVisualRectangleSelectorShape::borderMirrored) { + mask =3D mask.subtracted(QRegion(m_barWidth, m_barWidth, width()-(= m_barWidth*2), height()-(m_barWidth*2))); + } + return mask; +} +void KisVisualRectangleSelectorShape::resizeEvent(QResizeEvent *) +{ + forceImageUpdate(); +} + +void KisVisualRectangleSelectorShape::drawCursor() +{ + QPointF cursorPoint =3D convertShapeCoordinateToWidgetCoordinate(getCu= rsorPosition()); + QImage fullSelector =3D getImageMap(); + QColor col =3D getColorFromConverter(getCurrentColor()); + QPainter painter; + painter.begin(&fullSelector); + painter.setRenderHint(QPainter::Antialiasing); + //QPainterPath path; + QBrush fill; + fill.setStyle(Qt::SolidPattern); + + int cursorwidth =3D 5; + QRect rect(cursorPoint.toPoint().x()-cursorwidth,cursorPoint.toPoint()= .y()-cursorwidth, + cursorwidth*2,cursorwidth*2); + if (m_type=3D=3DKisVisualRectangleSelectorShape::vertical){ + int x =3D ( cursorPoint.x()-(width()/2)+1 ); + int y =3D ( cursorPoint.y()-cursorwidth ); + rect.setCoords(x, y, x+width()-2, y+(cursorwidth*2)); + painter.save(); + painter.setCompositionMode(QPainter::CompositionMode_Clear); + QPen pen; + pen.setWidth(5); + painter.setPen(pen); + painter.drawLine(QLine(QPoint(0.0,0.0), QPoint(0.0,height()))); + painter.drawLine(QLine(QPoint(width(),0.0), QPoint(width(),height(= )))); + painter.restore(); + } else { + int x =3D cursorPoint.x()-cursorwidth; + int y =3D cursorPoint.y()-(height()/2)+1; + rect.setCoords(x, y, x+(cursorwidth*2), y+cursorwidth-2); + } + QRectF innerRect(m_barWidth, m_barWidth, width()-(m_barWidth*2), heigh= t()-(m_barWidth*2)); + if (getDimensions() =3D=3D KisVisualColorSelectorShape::onedimensional= && m_type!=3DKisVisualRectangleSelectorShape::border && m_type!=3DKisVisua= lRectangleSelectorShape::borderMirrored) { + painter.setPen(Qt::white); + fill.setColor(Qt::white); + painter.setBrush(fill); + painter.drawRect(rect); + //set filter conversion! + fill.setColor(col); + painter.setPen(Qt::black); + painter.setBrush(fill); + rect.setCoords(rect.topLeft().x()+1, rect.topLeft().y()+1, + rect.topLeft().x()+rect.width()-2, rect.topLeft().y= ()+rect.height()-2); + painter.drawRect(rect); + + }else if(m_type=3D=3DKisVisualRectangleSelectorShape::borderMirrored){ + painter.setPen(Qt::white); + fill.setColor(Qt::white); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth); + QPoint mirror(innerRect.center().x()+(innerRect.center().x()-curso= rPoint.x()),cursorPoint.y()); + painter.drawEllipse(mirror, cursorwidth, cursorwidth); + fill.setColor(col); + painter.setPen(Qt::black); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1); + painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1); + + } else { + painter.save(); + painter.setCompositionMode(QPainter::CompositionMode_Clear); + QPen pen; + pen.setWidth(5); + painter.setPen(pen); + painter.drawRect(QRect(0,0,width(),height())); + painter.restore(); + + painter.setPen(Qt::white); + fill.setColor(Qt::white); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth); + fill.setColor(col); + painter.setPen(Qt::black); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0); + } + painter.end(); + setFullImage(fullSelector); +} + +//----------------Elliptical--------------------------// +KisVisualEllipticalSelectorShape::KisVisualEllipticalSelectorShape(QWidget= *parent, + Dimension= s dimension, + ColorMode= l model, + const KoC= olorSpace *cs, + int chann= el1, int channel2, + const KoC= olorDisplayRendererInterface *displayRenderer, + int borwi= dth, + singelDTy= pes d) + : KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, = channel2, displayRenderer) +{ + m_type =3D d; + m_barWidth =3D borwidth; +} + +KisVisualEllipticalSelectorShape::~KisVisualEllipticalSelectorShape() +{ + +} + +QSize KisVisualEllipticalSelectorShape::sizeHint() const +{ + return QSize(180,180); +} +void KisVisualEllipticalSelectorShape::setBorderWidth(int width) +{ + m_barWidth =3D width; +} + +QRect KisVisualEllipticalSelectorShape::getSpaceForSquare(QRect geom) +{ + int sizeValue =3D qMin(width(),height()); + QRect b(geom.left(), geom.top(), sizeValue, sizeValue); + QLineF radius(b.center(), QPointF(b.left()+m_barWidth, b.center().y())= ); + radius.setAngle(135); + QPointF tl =3D radius.p2(); + radius.setAngle(315); + QPointF br =3D radius.p2(); + QRect r(tl.toPoint(), br.toPoint()); + return r; +} + +QRect KisVisualEllipticalSelectorShape::getSpaceForCircle(QRect geom) +{ + int sizeValue =3D qMin(width(),height()); + QRect b(geom.left(), geom.top(), sizeValue, sizeValue); + QPointF tl =3D QPointF (b.topLeft().x()+m_barWidth, b.topLeft().y()+m_= barWidth); + QPointF br =3D QPointF (b.bottomRight().x()-m_barWidth, b.bottomRight(= ).y()-m_barWidth); + QRect r(tl.toPoint(), br.toPoint()); + return r; +} + +QRect KisVisualEllipticalSelectorShape::getSpaceForTriangle(QRect geom) +{ + int sizeValue =3D qMin(width(),height()); + QRect b(geom.left(), geom.top(), sizeValue, sizeValue); + QLineF radius(b.center(), QPointF(b.left()+m_barWidth, b.center().y())= ); + radius.setAngle(90);//point at yellowgreen :) + QPointF t =3D radius.p2(); + radius.setAngle(330);//point to purple :) + QPointF br =3D radius.p2(); + radius.setAngle(210);//point to cerulean :) + QPointF bl =3D radius.p2(); + QPointF tl =3D QPoint(bl.x(),t.y()); + QRect r(tl.toPoint(), br.toPoint()); + return r; +} + +QPointF KisVisualEllipticalSelectorShape::convertShapeCoordinateToWidgetCo= ordinate(QPointF coordinate) +{ + qreal x; + qreal y; + qreal offset=3D7.0; + qreal a =3D (qreal)width()*0.5; + QPointF center(a, a); + QLineF line(center, QPoint((m_barWidth*0.5),a)); + qreal angle =3D coordinate.x()*360.0; + angle =3D fmod(angle+180.0,360.0); + angle =3D 180.0-angle; + angle =3D angle+180.0; + if (m_type=3D=3DKisVisualEllipticalSelectorShape::borderMirrored) { + angle =3D (coordinate.x()/2)*360.0; + angle =3D fmod((angle+90.0), 360.0); + } + line.setAngle(angle); + if (getDimensions()!=3DKisVisualColorSelectorShape::onedimensional) { + line.setLength(qMin(coordinate.y()*(a-offset), a-offset)); + } + x =3D qRound(line.p2().x()); + y =3D qRound(line.p2().y()); + return QPointF(x,y); +} + +QPointF KisVisualEllipticalSelectorShape::convertWidgetCoordinateToShapeCo= ordinate(QPoint coordinate) +{ + //default implementation: + qreal x =3D 0.5; + qreal y =3D 1.0; + qreal offset =3D 7.0; + QRect total(0, 0, width(), height()); + QLineF line(total.center(), coordinate); + qreal a =3D (total.width()/2); + qreal angle; + + if (m_type!=3DKisVisualEllipticalSelectorShape::borderMirrored){ + angle =3D fmod((line.angle()+180.0), 360.0); + angle =3D 180.0-angle; + angle =3D angle+180.0; + x =3D angle/360.0; + if (getDimensions()=3D=3DKisVisualColorSelectorShape::twodimension= al) { + y =3D qBound(0.0,line.length()/(a-offset), 1.0); + } + + } else { + angle =3D fmod((line.angle()+270.0), 360.0); + if (angle>180.0) { + angle =3D 180.0-angle; + angle =3D angle+180; + } + x =3D (angle/360.0)*2; + if (getDimensions()=3D=3DKisVisualColorSelectorShape::twodimension= al) { + y =3D qBound(0.0,(line.length()+offset)/a, 1.0); + } + } + + return QPointF(x, y); +} + +QRegion KisVisualEllipticalSelectorShape::getMaskMap() +{ + QRegion mask =3D QRegion(0,0,width(),height(), QRegion::Ellipse); + if (getDimensions()=3D=3DKisVisualColorSelectorShape::onedimensional) { + mask =3D mask.subtracted(QRegion(m_barWidth, m_barWidth, width()-(= m_barWidth*2), height()-(m_barWidth*2), QRegion::Ellipse)); + } + return mask; +} + +void KisVisualEllipticalSelectorShape::resizeEvent(QResizeEvent *) +{ + forceImageUpdate(); +} + +void KisVisualEllipticalSelectorShape::drawCursor() +{ + QPointF cursorPoint =3D convertShapeCoordinateToWidgetCoordinate(getCu= rsorPosition()); + QImage fullSelector =3D getImageMap(); + QColor col =3D getColorFromConverter(getCurrentColor()); + QPainter painter; + painter.begin(&fullSelector); + painter.setRenderHint(QPainter::Antialiasing); + QRect innerRect(m_barWidth, m_barWidth, width()-(m_barWidth*2), height= ()-(m_barWidth*2)); + + painter.save(); + painter.setCompositionMode(QPainter::CompositionMode_Clear); + QPen pen; + pen.setWidth(5); + painter.setPen(pen); + painter.drawEllipse(QRect(0,0,width(),height())); + if (getDimensions()=3D=3DKisVisualColorSelectorShape::onedimensional) { + painter.setBrush(Qt::SolidPattern); + painter.drawEllipse(innerRect); + } + painter.restore(); + + QBrush fill; + fill.setStyle(Qt::SolidPattern); + + int cursorwidth =3D 5; + if(m_type=3D=3DKisVisualEllipticalSelectorShape::borderMirrored){ + painter.setPen(Qt::white); + fill.setColor(Qt::white); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth); + QPoint mirror(innerRect.center().x()+(innerRect.center().x()-curso= rPoint.x()),cursorPoint.y()); + painter.drawEllipse(mirror, cursorwidth, cursorwidth); + fill.setColor(col); + painter.setPen(Qt::black); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1); + painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1); + + } else { + painter.setPen(Qt::white); + fill.setColor(Qt::white); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth); + fill.setColor(col); + painter.setPen(Qt::black); + painter.setBrush(fill); + painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0); + } + painter.end(); + setFullImage(fullSelector); +} + +//----------------Triangle--------------------------// +KisVisualTriangleSelectorShape::KisVisualTriangleSelectorShape(QWidget *pa= rent, + Dimension= s dimension, + ColorMode= l model, + const KoC= olorSpace *cs, + int chann= el1, int channel2, + const KoC= olorDisplayRendererInterface *displayRenderer, + int borwi= dth) + : KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, = channel2, displayRenderer) +{ + m_barWidth =3D borwidth; + QRect total(0,0,width()*0.9,width()*0.9); + setTriangle(); +} + +KisVisualTriangleSelectorShape::~KisVisualTriangleSelectorShape() +{ + +} + +void KisVisualTriangleSelectorShape::setBorderWidth(int width) +{ + m_barWidth =3D width; +} + +QRect KisVisualTriangleSelectorShape::getSpaceForSquare(QRect geom) +{ + return geom; +} + +QRect KisVisualTriangleSelectorShape::getSpaceForCircle(QRect geom) +{ + return geom; +} + +QRect KisVisualTriangleSelectorShape::getSpaceForTriangle(QRect geom) +{ + return geom; +} +void KisVisualTriangleSelectorShape::setTriangle() +{ + QPoint apex =3D QPoint (width()*0.5,0); + QPolygon triangle; + triangle<< QPoint(0,height()) << apex << QPoint(width(),height()) << Q= Point(0,height()); + m_triangle =3D triangle; + QLineF a(triangle.at(0),triangle.at(1)); + QLineF b(triangle.at(0),triangle.at(2)); + QLineF ap(triangle.at(2), a.pointAt(0.5)); + QLineF bp(triangle.at(1), b.pointAt(0.5)); + QPointF intersect; + ap.intersect(bp,&intersect); + m_center =3D intersect; + QLineF r(triangle.at(0), intersect); + m_radius =3D r.length(); +} + +QPointF KisVisualTriangleSelectorShape::convertShapeCoordinateToWidgetCoor= dinate(QPointF coordinate) +{ + qreal offset=3D7.0;//the offset is so we get a nice little border that= allows selecting extreme colors better. + qreal y =3D qMin(coordinate.y()*(height()-offset*2)+offset+5.0, (qreal= )height()-offset); + + qreal triWidth =3D width(); + qreal horizontalLineLength =3D y*(2./sqrt(3.)); + qreal horizontalLineStart =3D triWidth/2.-horizontalLineLength/2.; + qreal relativeX =3D coordinate.x()*(horizontalLineLength-offset*2); + qreal x =3D qMin(relativeX + horizontalLineStart + offset, (qreal)widt= h()-offset*2); + if (y, (C) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. + */ +#ifndef KISVISUALCOLORSELECTOR_H +#define KISVISUALCOLORSELECTOR_H + +#include +#include +#include +#include +#include + +#include +#include +#include "KoColorDisplayRendererInterface.h" + + +#include "kritaui_export.h" + +/** + * @brief The KisVisualColorSelector class + * this gives a color selector box that draws gradients and everything. + * Unlike other color selectors, this one draws the full gamut of the give= n colorspace. + */ +class KRITAUI_EXPORT KisVisualColorSelector : public QWidget +{ + Q_OBJECT +public: + //Copied directly from the advanced color selector: + enum Type {Ring, Square, Wheel, Triangle, Slider}; + enum Parameters {H, hsvS, V, hslS, L, SL, SV, SV2, hsvSH, hslSH, VH, L= H, SI, SY, hsiSH, hsySH, I, Y, IH, YH, hsiS, hsyS}; + struct Configuration { + Type mainType; + Type subType; + Parameters mainTypeParameter; + Parameters subTypeParameter; + Configuration(Type mainT =3D Triangle, + Type subT =3D Ring, + Parameters mainTP =3D SL, + Parameters subTP =3D H) + : mainType(mainT), + subType(subT), + mainTypeParameter(mainTP), + subTypeParameter(subTP) + {} + Configuration(QString string) + { + readString(string); + } + + QString toString() const + { + return QString("%1|%2|%3|%4").arg(mainType).arg(subType).arg(m= ainTypeParameter).arg(subTypeParameter); + } + void readString(QString string) + { + QStringList strili =3D string.split('|'); + if(strili.length()!=3D4) return; + + int imt=3Dstrili.at(0).toInt(); + int ist=3Dstrili.at(1).toInt(); + int imtp=3Dstrili.at(2).toInt(); + int istp=3Dstrili.at(3).toInt(); + + if(imt>Slider || ist>Slider || imtp>hsyS || istp>hsyS)//this w= as LH before + return; + + mainType =3D Type(imt); + subType =3D Type(ist); + mainTypeParameter =3D Parameters(imtp); + subTypeParameter =3D Parameters(istp); + } + static Configuration fromString(QString string) + { + Configuration ret; + ret.readString(string); + return ret; + } + }; + + explicit KisVisualColorSelector(QWidget *parent =3D 0); + ~KisVisualColorSelector(); + + /** + * @brief setConfig + * @param forceCircular + * Force circular is for space where you only have room for a circular= selector. + * @param forceSelfUpdate + * force self-update is for making it update itself when using a modal= dialog. + */ + void setConfig(bool forceCircular, bool forceSelfUpdate); + KoColor getCurrentColor(); + +Q_SIGNALS: + void sigNewColor(KoColor c); + +public Q_SLOTS: + + void slotSetColor(KoColor c); + void slotsetColorSpace(const KoColorSpace *cs); + void slotRebuildSelectors(); + void ConfigurationChanged(); + void setDisplayRenderer (const KoColorDisplayRendererInterface *displa= yRenderer); +private Q_SLOTS: + void updateFromWidgets(KoColor c); + void HSXwrangler(); +protected: + void leaveEvent(QEvent *); + void resizeEvent(QResizeEvent *); +private: + struct Private; + const QScopedPointer m_d; + + void updateSelectorElements(QObject *source); + void drawGradients(); + +}; + +//kis_visual_color_selector_shape + +/** + * @brief The KisVisualColorSelectorShape class + * A 2d widget can represent at maximum 2 coordinates. + * So first decide howmany coordinates you need. (onedimensional, or twodi= mensional) + * Then the model, (Channel, HSV, HSL, HSI, YUV). Channel is the raw color= channels. + * When it finds a non-implemented feature it'll return to Channel. + * Then, select the channels you wish to be affected. This uses the model,= so for cmyk + * the channel is c=3D0, m=3D1, y=3D2, k=3D3, but for hsv, hue=3D0, sat=3D= 1, and val=3D2 + * These can also be set with 'slotsetactive channels'. + * Then finally, connect the displayrenderer, you can also do this with 's= etdisplayrenderer' + * + * Either way, this class is made to be subclassed, with a few virtuals so= that the geometry + * can be calculated properly. + */ + +class KisVisualColorSelectorShape : public QWidget +{ + Q_OBJECT +public: + /** + * @brief The Dimensions enum + * Wether or not the shape is single or two dimensional. + **/ + enum Dimensions{onedimensional, twodimensional}; + enum ColorModel{Channel, HSV, HSL, HSI, HSY, YUV}; + explicit KisVisualColorSelectorShape(QWidget *parent, + KisVisualColorSelectorShape::Dime= nsions dimension, + KisVisualColorSelectorShape::Colo= rModel model, + const KoColorSpace *cs, + int channel1, int channel2, + const KoColorDisplayRendererInter= face *displayRenderer =3D KoDumbColorDisplayRenderer::instance()); + ~KisVisualColorSelectorShape(); + + /** + * @brief getCursorPosition + * @return current cursor position in shape-coordinates. + */ + QPointF getCursorPosition(); + /** + * @brief getDimensions + * @return whether this is a single or twodimensional widget. + */ + Dimensions getDimensions(); + /** + * @brief getColorModel + * @return the model of this widget. + */ + ColorModel getColorModel(); + /** + * @brief getPixmap + * @return the pixmap of the gradient, for drawing on with a subclass. + * the pixmap will not change unless 'm_d->setPixmap=3Dtrue' which is = toggled by + * refresh and update functions. + */ + QImage getImageMap(); + /** + * @brief setFullImage + * Set the full widget image to be painted. + * @param full this should be the full image. + */ + void setFullImage(QImage full); + /** + * @brief getCurrentColor + * @return the current kocolor + */ + KoColor getCurrentColor(); + /** + * @brief setDisplayRenderer + * disconnect the old display renderer if needed and connect the new o= ne. + * @param displayRenderer + */ + void setDisplayRenderer (const KoColorDisplayRendererInterface *displa= yRenderer); + /** + * @brief getColorFromConverter + * @param c a koColor. + * @return get the qcolor from the given kocolorusing this widget's di= splay renderer. + */ + QColor getColorFromConverter(KoColor c); + + /** + * @brief getSpaceForSquare + * @param geom the full widget rectangle + * @return rectangle with enough space for second widget + */ + virtual QRect getSpaceForSquare(QRect geom) =3D 0; + virtual QRect getSpaceForCircle(QRect geom) =3D 0; + virtual QRect getSpaceForTriangle(QRect geom) =3D 0; + + /** + * @brief forceImageUpdate + * force the image to recache. + */ + void forceImageUpdate(); + + /** + * @brief setBorderWidth + * set the border of the single dimensional selector. + * @param width + */ + virtual void setBorderWidth(int width) =3D 0; + + /** + * @brief getChannels + * get used channels + * @return + */ + QVector getChannels(); + + /** + * @brief setHSX + * This is for the cursor not to change when selecting + * black, white, and desaturated values. Will not change the non-nativ= e values. + * @param hsx the hsx value. + */ + void setHSX(QVector hsx, bool wrangler=3Dfalse); + /** + * @brief getHSX sets the sat and hue so they won't + * switch around much. + * @param hsx the hsx values. + * @return returns hsx, corrected. + */ + QVector getHSX(QVector hsx, bool wrangler=3D false); + + +Q_SIGNALS: + void sigNewColor(KoColor col); + void sigHSXchange(); + +public Q_SLOTS: + /** + * @brief setColor + * Set this widget's current color and change the cursor position. + * @param c + */ + void setColor(KoColor c); + /** + * @brief setColorFromSibling + * set this widget's current color, but don't change the cursor positi= on, + * instead sent out a signal of the new color. + * @param c + */ + void setColorFromSibling(KoColor c); + /** + * @brief slotSetActiveChannels + * Change the active channels if necessary. + * @param channel1 used by single and twodimensional widgets. + * @param channel2 only used by twodimensional widgets. + */ + void slotSetActiveChannels(int channel1, int channel2); + /** + * @brief updateFromChangedDisplayRenderer + * for updating from the display renderer... not sure why this one is = public. + */ + void updateFromChangedDisplayRenderer(); +protected: + void mousePressEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void paintEvent(QPaintEvent*); +private: + struct Private; + const QScopedPointer m_d; + + /** + * @brief convertShapeCoordinateToWidgetCoordinate + * @return take the position in the shape and convert it to screen coo= rdinates. + */ + virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF) =3D = 0; + + /** + * @brief convertWidgetCoordinateToShapeCoordinate + * Convert a coordinate in the widget's height/width to a shape coordi= nate. + * @param coordinate the position your wish to have the shape coordina= tes of. + */ + virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPoint coordi= nate) =3D 0; + + /** + * @brief updateCursor + * Update the cursor position. + */ + void updateCursor(); + + QPointF convertKoColorToShapeCoordinate(KoColor c); + KoColor convertShapeCoordinateToKoColor(QPointF coordinates, bool curs= or=3Dfalse); + + /** + * @brief getPixmap + * @return the pixmap of this shape. + */ + virtual QRegion getMaskMap() =3D 0; + virtual void drawCursor() =3D 0; + + QVector convertvectorqrealTofloat(QVector real); + QVector convertvectorfloatToqreal(QVector vloat); +}; + +class KisVisualRectangleSelectorShape : public KisVisualColorSelectorShape +{ + Q_OBJECT +public: + enum singelDTypes{vertical, horizontal, border, borderMirrored}; + explicit KisVisualRectangleSelectorShape(QWidget *parent, + Dimensions dimension, + ColorModel model, + const KoColorSpace *cs, + int channel1, int channel2, + const KoColorDisplayRendererInter= face *displayRenderer =3D KoDumbColorDisplayRenderer::instance(), int width= =3D20, + KisVisualRectangleSelectorShape::= singelDTypes d =3D KisVisualRectangleSelectorShape::vertical + ); + ~KisVisualRectangleSelectorShape(); + + void setBorderWidth(int width); + + /** + * @brief getSpaceForSquare + * @param geom the full widget rectangle + * @return rectangle with enough space for second widget + */ + virtual QRect getSpaceForSquare(QRect geom); + virtual QRect getSpaceForCircle(QRect geom); + virtual QRect getSpaceForTriangle(QRect geom); +protected: + void resizeEvent(QResizeEvent *); +private: + virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF coord= inate); + virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPoint coordi= nate); + + singelDTypes m_type; + int m_barWidth; + virtual QRegion getMaskMap(); + virtual void drawCursor(); +}; + +class KisVisualEllipticalSelectorShape : public KisVisualColorSelectorShape +{ + Q_OBJECT +public: + enum singelDTypes{border, borderMirrored}; + explicit KisVisualEllipticalSelectorShape(QWidget *parent, + Dimensions dimension, + ColorModel model, + const KoColorSpace *cs, + int channel1, int channel2, + const KoColorDisplayRendererInter= face *displayRenderer =3D KoDumbColorDisplayRenderer::instance(), int borwi= dth=3D20, + KisVisualEllipticalSelectorShape:= :singelDTypes d =3D KisVisualEllipticalSelectorShape::border + ); + ~KisVisualEllipticalSelectorShape(); + + void setBorderWidth(int width); + + /** + * @brief getSpaceForSquare + * @param geom the full widget rectangle + * @return rectangle with enough space for second widget + */ + virtual QRect getSpaceForSquare(QRect geom); + virtual QRect getSpaceForCircle(QRect geom); + virtual QRect getSpaceForTriangle(QRect geom); +protected: + void resizeEvent(QResizeEvent *); +private: + virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF coord= inate); + virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPoint coordi= nate); + + + singelDTypes m_type; + int m_barWidth; + virtual QRegion getMaskMap(); + virtual void drawCursor(); + QSize sizeHint() const; +}; + +class KisVisualTriangleSelectorShape : public KisVisualColorSelectorShape +{ + Q_OBJECT +public: + enum singelDTypes{border, borderMirrored}; + explicit KisVisualTriangleSelectorShape(QWidget *parent, + Dimensions dimension, + ColorModel model, + const KoColorSpace *cs, + int channel1, int channel2, + const KoColorDisplayRendererInter= face *displayRenderer =3D KoDumbColorDisplayRenderer::instance(), + int borwidth=3D20 + ); + ~KisVisualTriangleSelectorShape(); + + void setBorderWidth(int width); + void setTriangle(); + + /** + * @brief getSpaceForSquare + * @param geom the full widget rectangle + * @return rectangle with enough space for second widget + */ + virtual QRect getSpaceForSquare(QRect geom); + virtual QRect getSpaceForCircle(QRect geom); + virtual QRect getSpaceForTriangle(QRect geom); +protected: + void resizeEvent(QResizeEvent *); +private: + virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF coord= inate); + virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPoint coordi= nate); + + singelDTypes m_type; + int m_barWidth; + QPolygon m_triangle; + QPointF m_center; + qreal m_radius; + virtual QRegion getMaskMap(); + virtual void drawCursor(); +}; +#endif // KISVISUALCOLORSELECTOR_H diff --git a/libs/widgets/CMakeLists.txt b/libs/widgets/CMakeLists.txt index c141267..6d53be6 100644 --- a/libs/widgets/CMakeLists.txt +++ b/libs/widgets/CMakeLists.txt @@ -31,7 +31,6 @@ set(kritawidgets_LIB_SRCS KoColorPopupAction.cpp KoColorSetWidget.cpp KoColorSlider.cpp - KoDualColorButton.cpp KoEditColorSetDialog.cpp KoTriangleColorSelector.cpp KoResourcePopupAction.cpp diff --git a/libs/widgets/KoColorPatch.cpp b/libs/widgets/KoColorPatch.cpp index 6b00068..0d2b534 100644 --- a/libs/widgets/KoColorPatch.cpp +++ b/libs/widgets/KoColorPatch.cpp @@ -22,6 +22,9 @@ = KoColorPatch::KoColorPatch( QWidget *parent ) : QFrame( parent ) { + m_displayRenderer =3D KoDumbColorDisplayRenderer::instance(); + connect(m_displayRenderer, SIGNAL(displayConfigurationChanged()), + SLOT(update()), Qt::UniqueConnection); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } = @@ -40,6 +43,32 @@ void KoColorPatch::setColor(const KoColor& c) = update(); } +void KoColorPatch::setDisplayRenderer(const KoColorDisplayRendererInterfac= e *displayRenderer) +{ + if (displayRenderer) { + if (m_displayRenderer) { + m_displayRenderer->disconnect(this); + } + m_displayRenderer =3D displayRenderer; + } else { + m_displayRenderer =3D KoDumbColorDisplayRenderer::instance(); + } + connect(m_displayRenderer, SIGNAL(displayConfigurationChanged()), + SLOT(update()), Qt::UniqueConnection); + +} + +QColor KoColorPatch::getColorFromDisplayRenderer(KoColor c) +{ + QColor col; + if (m_displayRenderer) { + c.convertTo(m_displayRenderer->getPaintingColorSpace()); + col =3D m_displayRenderer->toQColor(c); + } else { + col =3D c.toQColor(); + } + return col; +} = KoColor KoColorPatch::color() const { @@ -55,9 +84,7 @@ void KoColorPatch::mousePressEvent (QMouseEvent *e ) = void KoColorPatch::paintEvent(QPaintEvent *pe) { - QColor qc; - m_color.toQColor(&qc); - + QColor qc =3D getColorFromDisplayRenderer(m_color); QFrame::paintEvent(pe); QPainter painter( this ); painter.setPen(qc); diff --git a/libs/widgets/KoColorPatch.h b/libs/widgets/KoColorPatch.h index c30b72f..fd3ead4 100644 --- a/libs/widgets/KoColorPatch.h +++ b/libs/widgets/KoColorPatch.h @@ -23,6 +23,7 @@ = #include #include "kritawidgets_export.h" +#include = /** * The small widget showing the selected color @@ -41,6 +42,20 @@ public: void setColor( const KoColor &c ); = /** + * @brief setDisplayRenderer + * Set the display renderer of this object. + * @param displayRenderer + */ + void setDisplayRenderer(const KoColorDisplayRendererInterface *display= Renderer); + + /** + * @brief getColorFromDisplayRenderer + * Get QColor from the display renderers + * @param c + */ + QColor getColorFromDisplayRenderer(KoColor c); + + /** * @return current color shown by this patch */ KoColor color() const; @@ -60,6 +75,7 @@ Q_SIGNALS: = private: KoColor m_color; + const KoColorDisplayRendererInterface *m_displayRenderer; }; = #endif diff --git a/libs/widgets/KoColorSetWidget.cpp b/libs/widgets/KoColorSetWid= get.cpp index 5a5307c..c8e9758 100644 --- a/libs/widgets/KoColorSetWidget.cpp +++ b/libs/widgets/KoColorSetWidget.cpp @@ -53,10 +53,19 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillCol= ors() colorSetLayout->setMargin(3); colorSetLayout->setSpacing(0); // otherwise the use can click where th= ere is none colorSetContainer->setBackgroundRole(QPalette::Dark); - for(int i =3D 0; i<16; i++) { + + int columns =3D 16; + if (colorSet) { + columns =3D colorSet->columnCount(); + } + for(int i =3D 0; isetColumnMinimumWidth(i, 12); } + colorSetContainer->setMinimumWidth(columns*12+6); colorSetContainer->setLayout(colorSetLayout); + patchWidgetList.clear(); + colornames.clear(); + colorNameCmb->clear(); = if (colorSet) { for( int i =3D 0, p=3D 0; i < colorSet->nColors(); i++) { @@ -64,13 +73,21 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::fillCol= ors() patch->setFrameStyle(QFrame::Plain | QFrame::Box); patch->setLineWidth(1); patch->setColor(colorSet->getColor(i).color); + patch->setToolTip(colorSet->getColor(i).name); connect(patch, SIGNAL(triggered(KoColorPatch *)), thePublic, S= LOT(colorTriggered(KoColorPatch *))); - colorSetLayout->addWidget(patch, p/16, p%16); + colorSetLayout->addWidget(patch, p/columns, p%columns); + patch->setDisplayRenderer(displayRenderer); + patchWidgetList.append(patch); + colornames.append(colorSet->getColor(i).name); + QPixmap colorsquare =3D QPixmap(12,12); + colorsquare.fill(colorSet->getColor(i).color.toQColor()); + colorNameCmb->addItem(QIcon(colorsquare), colorSet->getColor(i= ).name); ++p; } } = scrollArea->setWidget(colorSetContainer); + connect(colorNameCmb, SIGNAL(activated(QString)), thePublic, SLOT(setC= olorFromString(QString)), Qt::UniqueConnection); } = void KoColorSetWidget::KoColorSetWidgetPrivate::addRemoveColors() @@ -114,7 +131,8 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::addRece= nt(const KoColor &color) { if(numRecents<6) { recentPatches[numRecents] =3D new KoColorPatch(thePublic); - recentPatches[numRecents]->setFrameShape(QFrame::Box); + recentPatches[numRecents]->setFrameShape(QFrame::StyledPanel); + recentPatches[numRecents]->setDisplayRenderer(displayRenderer); recentsLayout->insertWidget(numRecents+1, recentPatches[numRecents= ]); connect(recentPatches[numRecents], SIGNAL(triggered(KoColorPatch *= )), thePublic, SLOT(colorTriggered(KoColorPatch *))); numRecents++; @@ -168,8 +186,13 @@ KoColorSetWidget::KoColorSetWidget(QWidget *parent) d->scrollArea =3D new QScrollArea(); d->scrollArea->setBackgroundRole(QPalette::Dark); d->mainLayout->addWidget(d->scrollArea); + d->colorNameCmb =3D new QComboBox(this); + d->colorNameCmb->setEditable(true); + d->colorNameCmb->setInsertPolicy(QComboBox::NoInsert); + d->mainLayout->addWidget(d->colorNameCmb); d->fillColors(); = + d->addRemoveButton =3D new QToolButton(this); d->addRemoveButton->setText(i18n("Add / Remove Colors...")); d->addRemoveButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy:= :Fixed); @@ -199,6 +222,8 @@ void KoColorSetWidget::KoColorSetWidgetPrivate::colorTr= iggered(KoColorPatch *pat = emit thePublic->colorChanged(patch->color(), true); = + colorNameCmb->setCurrentIndex(colornames.indexOf(QRegExp(patch->toolTi= p()+"|Fixed"))); + for(i =3D 0; i color()); } = +void KoColorSetWidget::KoColorSetWidgetPrivate::setColorFromString(QString= s) +{ + int i =3D colornames.indexOf(QRegExp(s+"|Fixed")); + i =3D qMax(i,0); + colorTriggered(patchWidgetList.at(i)); +} + void KoColorSetWidget::setColorSet(KoColorSet *colorSet) { if (colorSet =3D=3D d->colorSet) return; @@ -228,6 +260,21 @@ KoColorSet* KoColorSetWidget::colorSet() return d->colorSet; } = +void KoColorSetWidget::setDisplayRenderer(const KoColorDisplayRendererInte= rface *displayRenderer) +{ + if (displayRenderer) { + d->displayRenderer =3D displayRenderer; + Q_FOREACH(KoColorPatch *p, d->patchWidgetList) { + p->setDisplayRenderer(displayRenderer); + } + for (int i=3D0; i<6; i++) { + if (d->recentPatches[i]) { + d->recentPatches[i]->setDisplayRenderer(displayRenderer); + } + } + } +} + void KoColorSetWidget::resizeEvent(QResizeEvent *event) { emit widgetSizeChanged(event->size()); diff --git a/libs/widgets/KoColorSetWidget.h b/libs/widgets/KoColorSetWidge= t.h index 07dbe26..6a26963 100644 --- a/libs/widgets/KoColorSetWidget.h +++ b/libs/widgets/KoColorSetWidget.h @@ -25,6 +25,7 @@ #include = #include "kritawidgets_export.h" +#include = class KoColor; class KoColorSet; @@ -61,6 +62,13 @@ public: void setColorSet(KoColorSet *colorSet); = /** + * @brief setDisplayRenderer + * Set the display renderer of this object. + * @param displayRenderer + */ + void setDisplayRenderer(const KoColorDisplayRendererInterface *display= Renderer); + + /** * Gets the current color set * @returns current color set,, 0 if none set */ @@ -90,6 +98,7 @@ Q_SIGNALS: private: Q_PRIVATE_SLOT(d, void colorTriggered(KoColorPatch *)) Q_PRIVATE_SLOT(d, void addRemoveColors()) + Q_PRIVATE_SLOT(d, void setColorFromString(QString s)) = class KoColorSetWidgetPrivate; KoColorSetWidgetPrivate * const d; diff --git a/libs/widgets/KoColorSetWidget_p.h b/libs/widgets/KoColorSetWid= get_p.h index 0a85e98..867dadf 100644 --- a/libs/widgets/KoColorSetWidget_p.h +++ b/libs/widgets/KoColorSetWidget_p.h @@ -36,11 +36,13 @@ #include #include #include +#include = #include #include = #include +#include = class KoColorPatch; = @@ -57,6 +59,8 @@ public: QHBoxLayout *recentsLayout; KoColorPatch *recentPatches[6]; QToolButton *addRemoveButton; + QComboBox *colorNameCmb; + QStringList colornames; int numRecents; = void colorTriggered(KoColorPatch *patch); @@ -64,6 +68,11 @@ public: void activateRecent(int i); void fillColors(); void addRemoveColors(); + void setColorFromString(QString s); + + QList patchWidgetList; + const KoColorDisplayRendererInterface *displayRenderer; + }; = #endif diff --git a/libs/widgets/KoEditColorSetDialog.cpp b/libs/widgets/KoEditCol= orSetDialog.cpp index c76eead..b5e8e6f 100644 --- a/libs/widgets/KoEditColorSetDialog.cpp +++ b/libs/widgets/KoEditColorSetDialog.cpp @@ -71,7 +71,14 @@ KoEditColorSetWidget::KoEditColorSetWidget(const QList &palettes, index =3D widget.selector->findText(m_activeColorSet->name()); } = - m_scrollArea->setMinimumWidth(16*(12+2)); + int columns =3D 16; + if(m_activeColorSet) { + columns =3D m_activeColorSet->columnCount(); + if (columns=3D=3D0){ + columns =3D 16; + } + } + m_scrollArea->setMinimumWidth(columns*(12+2)); = QHBoxLayout *layout =3D new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); @@ -121,15 +128,20 @@ void KoEditColorSetWidget::setActiveColorSet(int inde= x) = m_activeColorSet =3D m_colorSets.value(index); setEnabled(m_activeColorSet !=3D 0); + int columns =3D 16; if (m_activeColorSet) { + columns =3D m_activeColorSet->columnCount(); + if (columns=3D=3D0){columns=3D16;} widget.remove->setEnabled(false); for (int i =3D 0; i < m_activeColorSet->nColors(); i++) { KoColorPatch *patch =3D new KoColorPatch(widget.patchesFrame); patch->setColor(m_activeColorSet->getColor(i).color); + patch->setToolTip(m_activeColorSet->getColor(i).name); connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(s= etTextLabel(KoColorPatch *))); - m_gridLayout->addWidget(patch, i/16, i%16); + m_gridLayout->addWidget(patch, i/columns, i%columns); } } + m_scrollArea->setMinimumWidth(columns*(12+2)); = wdg->setLayout(m_gridLayout); m_scrollArea->setWidget(wdg); @@ -137,7 +149,7 @@ void KoEditColorSetWidget::setActiveColorSet(int index) = void KoEditColorSetWidget::setTextLabel(KoColorPatch *patch) { - widget.colorName->setText(patch->color().toQColor().name()); + widget.colorName->setText(patch->toolTip()); if (m_activePatch) { m_activePatch->setFrameShape(QFrame::NoFrame); m_activePatch->setFrameShadow(QFrame::Plain); @@ -159,10 +171,11 @@ void KoEditColorSetWidget::addColor() newEntry.name =3D QInputDialog::getText(this, i18n("Add Color To P= alette"), i18n("Color name:")); KoColorPatch *patch =3D new KoColorPatch(widget.patchesFrame); patch->setColor(newEntry.color); + patch->setToolTip(newEntry.name); connect(patch, SIGNAL(triggered(KoColorPatch *)), this, SLOT(setTe= xtLabel(KoColorPatch *))); Q_ASSERT(m_gridLayout); Q_ASSERT(m_activeColorSet); - m_gridLayout->addWidget(patch, m_activeColorSet->nColors()/16, m_a= ctiveColorSet->nColors()%16); + m_gridLayout->addWidget(patch, m_activeColorSet->nColors()/m_activ= eColorSet->columnCount(), m_activeColorSet->nColors()%m_activeColorSet->col= umnCount()); m_activeColorSet->add(newEntry); } } diff --git a/plugins/dockers/animation/onion_skins_docker.cpp b/plugins/doc= kers/animation/onion_skins_docker.cpp index 230f490..ab0879a 100644 --- a/plugins/dockers/animation/onion_skins_docker.cpp +++ b/plugins/dockers/animation/onion_skins_docker.cpp @@ -30,6 +30,7 @@ #include "KisViewManager.h" #include "kis_action_manager.h" #include "kis_action.h" +#include = #include "kis_equalizer_widget.h" = @@ -63,8 +64,8 @@ OnionSkinsDocker::OnionSkinsDocker(QWidget *parent) : connect(m_equalizerWidget, SIGNAL(sigConfigChanged()), &m_updatesCompr= essor, SLOT(start())); layout->addWidget(m_equalizerWidget, 1); = - connect(ui->btnBackwardColor, SIGNAL(changed(QColor)), &m_updatesCompr= essor, SLOT(start())); - connect(ui->btnForwardColor, SIGNAL(changed(QColor)), &m_updatesCompre= ssor, SLOT(start())); + connect(ui->btnBackwardColor, SIGNAL(changed(KoColor)), &m_updatesComp= ressor, SLOT(start())); + connect(ui->btnForwardColor, SIGNAL(changed(KoColor)), &m_updatesCompr= essor, SLOT(start())); connect(ui->doubleTintFactor, SIGNAL(valueChanged(qreal)), &m_updatesC= ompressor, SLOT(start())); = connect(&m_updatesCompressor, SIGNAL(timeout()), @@ -152,8 +153,8 @@ void OnionSkinsDocker::changed() } = config.setOnionSkinTintFactor(ui->doubleTintFactor->value() * 255.0 / = 100.0); - config.setOnionSkinTintColorBackward(ui->btnBackwardColor->color()); - config.setOnionSkinTintColorForward(ui->btnForwardColor->color()); + config.setOnionSkinTintColorBackward(ui->btnBackwardColor->color().toQ= Color()); + config.setOnionSkinTintColorForward(ui->btnForwardColor->color().toQCo= lor()); = KisOnionSkinCompositor::instance()->configChanged(); } @@ -168,8 +169,11 @@ void OnionSkinsDocker::loadSettings() m_equalizerWidget); = ui->doubleTintFactor->setValue(config.onionSkinTintFactor() * 100.0 / = 255); - ui->btnBackwardColor->setColor(config.onionSkinTintColorBackward()); - ui->btnForwardColor->setColor(config.onionSkinTintColorForward()); + KoColor bcol(KoColorSpaceRegistry::instance()->rgb8()); + bcol.fromQColor(config.onionSkinTintColorBackward()); + ui->btnBackwardColor->setColor(bcol); + bcol.fromQColor(config.onionSkinTintColorForward()); + ui->btnForwardColor->setColor(bcol); = KisEqualizerWidget::EqualizerValues v; v.maxDistance =3D 10; diff --git a/plugins/dockers/animation/onion_skins_docker.ui b/plugins/dock= ers/animation/onion_skins_docker.ui index e232c23..001b8cc 100644 --- a/plugins/dockers/animation/onion_skins_docker.ui +++ b/plugins/dockers/animation/onion_skins_docker.ui @@ -6,7 +6,7 @@ 0 0 - 299 + 356 368 @@ -54,7 +54,7 @@
- + 50 @@ -66,7 +66,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -111,24 +111,19 @@ - lblPrevColor - btnBackwardColor - btnForwardColor - lblNextColor - KColorButton - QPushButton -
kcolorbutton.h
- 1 -
- KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1
+ + KisColorButton + QPushButton +
kis_color_button.h
+
diff --git a/plugins/dockers/digitalmixer/digitalmixer_dock.cc b/plugins/do= ckers/digitalmixer/digitalmixer_dock.cc index 8cb19dc..6da7c71 100644 --- a/plugins/dockers/digitalmixer/digitalmixer_dock.cc +++ b/plugins/dockers/digitalmixer/digitalmixer_dock.cc @@ -30,6 +30,8 @@ #include #include = +#include + class DigitalMixerPatch : public KoColorPatch { public: DigitalMixerPatch(QWidget* parent) : KoColorPatch(parent) {} @@ -43,7 +45,13 @@ DigitalMixerDock::DigitalMixerDock( ) : QDockWidget(i18n("Digital Colors Mixer")), m_canvas(0) , m_tellCanvas(true) { - QColor initColors[6] =3D { Qt::black, Qt::white, Qt::red, Qt::green, Q= t::blue, Qt::yellow }; + const KoColorSpace *sRGB =3D KoColorSpaceRegistry::instance()->rgb8(); + KoColor initColors[6] =3D { KoColor(Qt::black, sRGB), + KoColor(Qt::white, sRGB), + KoColor(Qt::red, sRGB), + KoColor(Qt::green, sRGB), + KoColor(Qt::blue, sRGB), + KoColor(Qt::yellow, sRGB) }; = QWidget* widget =3D new QWidget(this); QGridLayout* layout =3D new QGridLayout( widget ); @@ -75,16 +83,14 @@ DigitalMixerDock::DigitalMixerDock( ) mixer.targetSlider->setFixedWidth(22); mixer.targetSlider->setMinimumHeight(66); layout->addWidget(mixer.targetSlider, 1, i + 1); - QToolButton* colorSelector =3D new QToolButton( this ); - mixer.actionColor =3D new KoColorPopupAction(this); - mixer.actionColor->setCurrentColor(initColors[i]); - colorSelector->setDefaultAction(mixer.actionColor); - colorSelector->setFixedSize(colorSelector->sizeHint()); - layout->addWidget(colorSelector, 2, i + 1); + mixer.actionColor =3D new KisColorButton( this ); + mixer.actionColor->setColor(initColors[i]); + mixer.actionColor->setFixedWidth(22); + layout->addWidget(mixer.actionColor, 2, i + 1); = m_mixers.push_back(mixer); = - connect(mixer.actionColor, SIGNAL(colorChanged(KoColor)), signalMa= pperSelectColor, SLOT(map())); + connect(mixer.actionColor, SIGNAL(changed(KoColor)), signalMapperS= electColor, SLOT(map())); signalMapperSelectColor->setMapping(mixer.actionColor, i); = connect(mixer.targetSlider, SIGNAL(valueChanged(int)), signalMappe= rColorSlider, SLOT(map())); @@ -120,7 +126,7 @@ void DigitalMixerDock::setCanvas(KoCanvasBase * canvas) = void DigitalMixerDock::popupColorChanged(int i) { - KoColor color =3D m_mixers[i].actionColor->currentKoColor(); + KoColor color =3D m_mixers[i].actionColor->color(); color.convertTo(m_currentColor.colorSpace()); m_mixers[i].targetSlider->setColors( color, m_currentColor); colorSliderChanged(i); diff --git a/plugins/dockers/digitalmixer/digitalmixer_dock.h b/plugins/doc= kers/digitalmixer/digitalmixer_dock.h index 1604b4b..21677b3 100644 --- a/plugins/dockers/digitalmixer/digitalmixer_dock.h +++ b/plugins/dockers/digitalmixer/digitalmixer_dock.h @@ -25,6 +25,7 @@ class KoColorPopupAction; class KoColorSlider; class KoColorPatch; +class KisColorButton; = class DigitalMixerDock : public QDockWidget, public KoCanvasObserverBase { Q_OBJECT @@ -48,7 +49,7 @@ private: struct Mixer { KoColorPatch* targetColor; KoColorSlider* targetSlider; - KoColorPopupAction* actionColor; + KisColorButton* actionColor; }; QList m_mixers; bool m_tellCanvas; diff --git a/plugins/dockers/palettedocker/palettedocker_dock.cpp b/plugins= /dockers/palettedocker/palettedocker_dock.cpp index a436356..d641835 100644 --- a/plugins/dockers/palettedocker/palettedocker_dock.cpp +++ b/plugins/dockers/palettedocker/palettedocker_dock.cpp @@ -304,6 +304,7 @@ void PaletteDockerDock::entrySelected(QModelIndex index) int i =3D index.row()*m_model->columnCount()+index.column(); if (i < m_currentColorSet->nColors()) { KoColorSetEntry entry =3D m_currentColorSet->getColor(i); + m_wdgPaletteDock->lblColorName->setText(entry.name); if (m_resourceProvider) { m_resourceProvider->setFGColor(entry.color); } diff --git a/plugins/dockers/palettedocker/wdgpalettedock.ui b/plugins/dock= ers/palettedocker/wdgpalettedock.ui index 0154b44..28e41e6 100644 --- a/plugins/dockers/palettedocker/wdgpalettedock.ui +++ b/plugins/dockers/palettedocker/wdgpalettedock.ui @@ -14,7 +14,16 @@ 1 - + + 0 + + + 0 + + + 0 + + 0 @@ -29,7 +38,26 @@ - + + + + Add color + + + ... + + + + 22 + 22 + + + + false + + + + Qt::Horizontal @@ -42,7 +70,14 @@ - + + + + + + + + Delete color @@ -61,7 +96,7 @@ - + Add foreground color @@ -80,27 +115,17 @@ - - - - Add color - - - ... - - + + + - 22 - 22 + 60 + 0 - - false + + QFrame::StyledPanel - - - - diff --git a/plugins/dockers/specificcolorselector/CMakeLists.txt b/plugins= /dockers/specificcolorselector/CMakeLists.txt index 98359c5..b05aff2 100644 --- a/plugins/dockers/specificcolorselector/CMakeLists.txt +++ b/plugins/dockers/specificcolorselector/CMakeLists.txt @@ -1,4 +1,8 @@ -set(KRITA_SPECIFICCOLORSELECTOR_SOURCES specificcolorselector.cc specificc= olorselector_dock.cc kis_specific_color_selector_widget.cc kis_color_input.= cc ) +set(KRITA_SPECIFICCOLORSELECTOR_SOURCES = + specificcolorselector.cc = + specificcolorselector_dock.cc = + kis_specific_color_selector_widget.cc = +) add_library(kritaspecificcolorselector MODULE ${KRITA_SPECIFICCOLORSELECTO= R_SOURCES}) target_link_libraries(kritaspecificcolorselector kritaui ${OPENEXR_LIBRARI= ES}) install(TARGETS kritaspecificcolorselector DESTINATION ${KRITA_PLUGIN_INS= TALL_DIR}) diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selec= tor_widget.cc b/plugins/dockers/specificcolorselector/kis_specific_color_se= lector_widget.cc index c6dc9be..f5bb7e7 100644 --- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_wid= get.cc +++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_wid= get.cc @@ -31,12 +31,12 @@ #include #include = -#include "kis_color_input.h" +#include #include -#include "kis_debug.h" -#include "kis_color_space_selector.h" -#include "kis_signal_compressor.h" -#include "kis_display_color_converter.h" +#include +#include +#include +#include = = KisSpecificColorSelectorWidget::KisSpecificColorSelectorWidget(QWidget* pa= rent) diff --git a/plugins/extensions/layersplit/dlg_layersplit.cpp b/plugins/ext= ensions/layersplit/dlg_layersplit.cpp index cb55361..1656834 100644 --- a/plugins/extensions/layersplit/dlg_layersplit.cpp +++ b/plugins/extensions/layersplit/dlg_layersplit.cpp @@ -20,6 +20,8 @@ #include "dlg_layersplit.h" = #include + +#include #include = #include @@ -45,6 +47,11 @@ DlgLayerSplit::DlgLayerSplit() m_page->intFuzziness->setSingleStep(1); = = + + m_colorSetChooser =3D new KisColorsetChooser(); + m_page->paletteChooser->setPopupWidget(m_colorSetChooser); + connect(m_colorSetChooser, SIGNAL(paletteSelected(KoColorSet*)), this,= SLOT(slotSetPalette(KoColorSet*))); + KisConfig cfg; m_page->intFuzziness->setValue(cfg.readEntry("layersplit/fuzzines= s", 20)); m_page->chkCreateGroupLayer->setChecked(cfg.readEntry("layerspit= /createmastergroup", true)); @@ -54,6 +61,17 @@ DlgLayerSplit::DlgLayerSplit() m_page->chkSortLayers->setChecked(cfg.readEntry("layerspit/sortl= ayers", true)); m_page->chkDisregardOpacity->setChecked(cfg.readEntry("layerspit= /disregardopacity", true)); = + QString paletteName =3D cfg.readEntry("layersplit/paletteName= ", "Default"); + KoResourceServer *pserver =3D KoResourceServerProvider::in= stance()->paletteServer(false); + KoColorSet *pal =3D pserver->resourceByName(paletteName); + if (pal) { + m_palette =3D pal; + m_page->paletteChooser->setText(pal->name()); + QIcon icon(QPixmap::fromImage(pal->image())); + m_page->paletteChooser->setIcon(icon); + } + + connect(this, SIGNAL(applyClicked()), this, SLOT(applyClicked())); = setMainWidget(m_page); @@ -73,6 +91,7 @@ void DlgLayerSplit::applyClicked() cfg.writeEntry("layerspit/hideoriginal", m_page->chkHideOriginal->isCh= ecked()); cfg.writeEntry("layerspit/sortlayers", m_page->chkSortLayers->isChecke= d()); cfg.writeEntry("layerspit/disregardopacity", m_page->chkDisregardOpaci= ty->isChecked()); + cfg.writeEntry("layersplit/paletteName", m_palette->name()); = accept(); } @@ -113,5 +132,17 @@ int DlgLayerSplit::fuzziness() const = } = +KoColorSet *DlgLayerSplit::palette() const +{ + return m_palette; +} = - +void DlgLayerSplit::slotSetPalette(KoColorSet *pal) +{ + if (pal) { + m_palette =3D pal; + m_page->paletteChooser->setText(pal->name()); + QIcon icon(QPixmap::fromImage(pal->image())); + m_page->paletteChooser->setIcon(icon); + } +} diff --git a/plugins/extensions/layersplit/dlg_layersplit.h b/plugins/exten= sions/layersplit/dlg_layersplit.h index aced7bf..5f35425 100644 --- a/plugins/extensions/layersplit/dlg_layersplit.h +++ b/plugins/extensions/layersplit/dlg_layersplit.h @@ -20,7 +20,8 @@ #define DLG_LAYERSPLIT = #include - +#include +#include #include = #include "wdg_layersplit.h" @@ -46,13 +47,17 @@ public: bool sortLayers() const; bool disregardOpacity() const; int fuzziness() const; + KoColorSet* palette() const; = private Q_SLOTS: = void applyClicked(); + void slotSetPalette(KoColorSet *pal); = private: WdgLayerSplit* m_page; + KisColorsetChooser *m_colorSetChooser; + KoColorSet *m_palette; }; = #endif // DLG_LAYERSPLIT diff --git a/plugins/extensions/layersplit/layersplit.cpp b/plugins/extensi= ons/layersplit/layersplit.cpp index 15d60aa..6d01d05 100644 --- a/plugins/extensions/layersplit/layersplit.cpp +++ b/plugins/extensions/layersplit/layersplit.cpp @@ -149,9 +149,13 @@ void LayerSplit::slotLayerSplit() } = if (!found) { + QString name =3D dlg.palette()->closestColorName(c); + if (name.toLower() =3D=3D "untitled" || name.toLower()= =3D=3D "none" || name.toLower() =3D=3D "") { + name =3D KoColor::toQString(c); + } Layer l; l.color =3D c; - l.device =3D new KisPaintDevice(cs, KoColor::toQString= (c)); + l.device =3D new KisPaintDevice(cs, name); l.accessor =3D l.device->createRandomAccessorNG(col, r= ow); l.accessor->moveTo(col, row); memcpy(l.accessor->rawData(), acc->rawDataConst(), cs-= >pixelSize()); diff --git a/plugins/extensions/layersplit/wdg_layersplit.ui b/plugins/exte= nsions/layersplit/wdg_layersplit.ui index 6b48346..927b670 100644 --- a/plugins/extensions/layersplit/wdg_layersplit.ui +++ b/plugins/extensions/layersplit/wdg_layersplit.ui @@ -7,7 +7,7 @@ 0 0 449 - 271 + 273 @@ -77,7 +77,7 @@ - + @@ -86,6 +86,20 @@
+ + + + Palette to use for naming the layers: + + + + + + + Choose Palette + + +
@@ -124,6 +138,11 @@ + KisPopupButton + QPushButton +
kis_popup_button.h
+
+ KisSliderSpinBox QWidget
kis_slider_spin_box.h
diff --git a/plugins/filters/colors/kis_wdg_color_to_alpha.cpp b/plugins/fi= lters/colors/kis_wdg_color_to_alpha.cpp index e45e7b0..1d13900 100644 --- a/plugins/filters/colors/kis_wdg_color_to_alpha.cpp +++ b/plugins/filters/colors/kis_wdg_color_to_alpha.cpp @@ -33,6 +33,7 @@ #include #include #include +#include = #include "ui_wdgcolortoalphabase.h" = @@ -48,11 +49,12 @@ KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) = m_widget->intThreshold->setRange(1, 255, 0); = - connect(m_widget->colorSelector, SIGNAL(colorChanged(const QColor&)), = SLOT(slotColorSelectorChanged(const QColor&))); + connect(m_widget->colorSelector, SIGNAL(sigNewColor(KoColor)), SLOT(sl= otColorSelectorChanged(const KoColor&))); connect(m_widget->intThreshold, SIGNAL(valueChanged(qreal)), SIGNAL(si= gConfigurationItemChanged())); - connect(m_widget->btnCustomColor, SIGNAL(changed(const QColor&)), SLOT= (slotCustomColorSelected(const QColor&))); + connect(m_widget->btnCustomColor, SIGNAL(changed(const KoColor)), SLOT= (slotCustomColorSelected(const KoColor&))); = - m_widget->btnCustomColor->setColor(Qt::white); + KoColor c(Qt::white, KoColorSpaceRegistry::instance()->rgb8()); + m_widget->btnCustomColor->setColor(c); } = KisWdgColorToAlpha::~KisWdgColorToAlpha() @@ -67,17 +69,17 @@ void KisWdgColorToAlpha::setView(KisViewManager *view) = void KisWdgColorToAlpha::slotFgColorChanged(const KoColor &color) { - m_widget->btnCustomColor->setColor(color.toQColor()); + m_widget->btnCustomColor->setColor(color); } = -void KisWdgColorToAlpha::slotColorSelectorChanged(const QColor &color) +void KisWdgColorToAlpha::slotColorSelectorChanged(const KoColor &color) { m_widget->btnCustomColor->setColor(color); } = -void KisWdgColorToAlpha::slotCustomColorSelected(const QColor &color) +void KisWdgColorToAlpha::slotCustomColorSelected(const KoColor &color) { - m_widget->colorSelector->setQColor(color); + m_widget->colorSelector->slotSetColor(color); emit sigConfigurationItemChanged(); } = @@ -85,7 +87,13 @@ void KisWdgColorToAlpha::setConfiguration(const KisPrope= rtiesConfiguration* conf { QVariant value; if (config->getProperty("targetcolor", value)) { - m_widget->colorSelector->setQColor(value.value()); + KoColor c; + if (value.value().isValid()) { + c.fromQColor(value.value()); + } else { + c =3D value.value(); + } + m_widget->colorSelector->slotSetColor(c); } if (config->getProperty("threshold", value)) { m_widget->intThreshold->setValue(value.toInt()); @@ -95,7 +103,7 @@ void KisWdgColorToAlpha::setConfiguration(const KisPrope= rtiesConfiguration* conf KisPropertiesConfiguration* KisWdgColorToAlpha::configuration() const { KisFilterConfiguration* config =3D new KisFilterConfiguration("colorto= alpha", 1); - config->setProperty("targetcolor", widget()->colorSelector->color()); + config->setProperty("targetcolor", widget()->colorSelector->getCurrent= Color().toQColor()); config->setProperty("threshold", widget()->intThreshold->value()); return config; } diff --git a/plugins/filters/colors/kis_wdg_color_to_alpha.h b/plugins/filt= ers/colors/kis_wdg_color_to_alpha.h index 2b7a7cf..2a2937d 100644 --- a/plugins/filters/colors/kis_wdg_color_to_alpha.h +++ b/plugins/filters/colors/kis_wdg_color_to_alpha.h @@ -49,8 +49,8 @@ protected: = private Q_SLOTS: void slotFgColorChanged(const KoColor &color); - void slotColorSelectorChanged(const QColor &color); - void slotCustomColorSelected(const QColor &color); + void slotColorSelectorChanged(const KoColor &color); + void slotCustomColorSelected(const KoColor &color); = private: Ui_WdgColorToAlphaBase* m_widget; diff --git a/plugins/filters/colors/wdgcolortoalphabase.ui b/plugins/filter= s/colors/wdgcolortoalphabase.ui index 4d7c8b3..961c772 100644 --- a/plugins/filters/colors/wdgcolortoalphabase.ui +++ b/plugins/filters/colors/wdgcolortoalphabase.ui @@ -63,7 +63,7 @@
- + 0 @@ -139,7 +139,7 @@ - + 0 @@ -162,7 +162,7 @@ - + 0 @@ -192,16 +192,15 @@ - KColorButton - QPushButton -
kcolorbutton.h
+ KisVisualColorSelector + QWidget +
kis_visual_color_selector.h
1
- KoTriangleColorSelector - QWidget -
KoTriangleColorSelector.h
- 1 + KisColorButton + QPushButton +
kis_color_button.h
KisDoubleSliderSpinBox diff --git a/plugins/filters/indexcolors/kiswdgindexcolors.cpp b/plugins/fi= lters/indexcolors/kiswdgindexcolors.cpp index 22a57c9..c375e6e 100644 --- a/plugins/filters/indexcolors/kiswdgindexcolors.cpp +++ b/plugins/filters/indexcolors/kiswdgindexcolors.cpp @@ -28,7 +28,7 @@ = #include "kis_int_parse_spin_box.h" = -#include +#include = KisWdgIndexColors::KisWdgIndexColors(QWidget* parent, Qt::WFlags f, int de= lay): KisConfigWidget(parent, f, delay) { @@ -100,7 +100,7 @@ void KisWdgIndexColors::setup(QStringList shadesLabels,= int ramps) for(int y =3D 0; y < rows; ++y) for(int x =3D 0; x < collumns; ++x) { - KColorButton* b =3D new KColorButton; + KisColorButton* b =3D new KisColorButton; QCheckBox* c =3D new QCheckBox; c->setChecked(false); b->setEnabled(false); @@ -109,7 +109,7 @@ void KisWdgIndexColors::setup(QStringList shadesLabels,= int ramps) = connect(c, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool))); connect(c, SIGNAL(toggled(bool)), this, SIGNAL(sigConfiguratio= nItemChanged())); - connect(b, SIGNAL(changed(QColor)), this, SIGNAL(sigConfigurat= ionItemChanged())); + connect(b, SIGNAL(changed(KoColor)), this, SIGNAL(sigConfigura= tionItemChanged())); = QHBoxLayout* cell =3D new QHBoxLayout(); cell->setSpacing(0); @@ -133,7 +133,7 @@ KisPropertiesConfiguration* KisWdgIndexColors::configur= ation() const for(int y =3D 0; y < 4; ++y) for(int x =3D 0; x < 4; ++x) { - palCfg.colors[y][x] =3D m_colorSelectors[y][x].button->color(); + palCfg.colors[y][x] =3D m_colorSelectors[y][x].button->color()= .toQColor(); palCfg.colorsEnabled[y][x] =3D m_colorSelectors[y][x].button->= isEnabled(); } = @@ -179,7 +179,9 @@ void KisWdgIndexColors::setConfiguration(const KisPrope= rtiesConfiguration* confi { m_colorSelectors[y][x].checkbox->setChecked(palCfg.colorsEnabl= ed[y][x]); m_colorSelectors[y][x].button->setEnabled(palCfg.colorsEnabled= [y][x]); - m_colorSelectors[y][x].button->setColor(palCfg.colors[y][x]); + KoColor c; + c.fromQColor(palCfg.colors[y][x]); + m_colorSelectors[y][x].button->setColor(c); } = for(int y =3D 0; y < 3; ++y) diff --git a/plugins/filters/indexcolors/kiswdgindexcolors.h b/plugins/filt= ers/indexcolors/kiswdgindexcolors.h index 4f32831..f1d4605 100644 --- a/plugins/filters/indexcolors/kiswdgindexcolors.h +++ b/plugins/filters/indexcolors/kiswdgindexcolors.h @@ -27,7 +27,7 @@ #include = class QCheckBox; -class KColorButton; +class KisColorButton; namespace Ui { class KisWdgIndexColors; @@ -48,7 +48,7 @@ private Q_SLOTS: private: struct ColorWidgets { - KColorButton* button; + KisColorButton* button; QCheckBox* checkbox; }; QVector< QVector > m_colorSelectors; diff --git a/plugins/generators/pattern/wdgpatternoptions.ui b/plugins/gene= rators/pattern/wdgpatternoptions.ui index bc75be6..47e3dd0 100644 --- a/plugins/generators/pattern/wdgpatternoptions.ui +++ b/plugins/generators/pattern/wdgpatternoptions.ui @@ -52,10 +52,10 @@
- + - + 0 @@ -70,9 +70,9 @@ - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h
KisPatternChooser diff --git a/plugins/generators/solid/colorgenerator.cpp b/plugins/generato= rs/solid/colorgenerator.cpp index d147d74..6726888 100644 --- a/plugins/generators/solid/colorgenerator.cpp +++ b/plugins/generators/solid/colorgenerator.cpp @@ -100,4 +100,4 @@ void KisColorGenerator::generate(KisProcessingInformati= on dstInfo, } } = -#include "colorgenerator.moc" \ No newline at end of file +#include "colorgenerator.moc" diff --git a/plugins/generators/solid/kis_wdg_color.cpp b/plugins/generator= s/solid/kis_wdg_color.cpp index a48e1f1..83624ec 100644 --- a/plugins/generators/solid/kis_wdg_color.cpp +++ b/plugins/generators/solid/kis_wdg_color.cpp @@ -27,11 +27,12 @@ = #include "ui_wdgcoloroptions.h" = -KisWdgColor::KisWdgColor(QWidget* parent) +KisWdgColor::KisWdgColor(QWidget* parent, const KoColorSpace *cs) : KisConfigWidget(parent) { m_widget =3D new Ui_WdgColorOptions(); m_widget->setupUi(this); + m_cs =3D cs; } = KisWdgColor::~KisWdgColor() @@ -43,14 +44,16 @@ KisWdgColor::~KisWdgColor() void KisWdgColor::setConfiguration(const KisPropertiesConfiguration* confi= g) { QVariant value; - widget()->bnColor->setColor(config->getColor("color").toQColor()); + KoColor c =3Dconfig->getColor("color"); + c.convertTo(m_cs); + widget()->bnColor->setColor(c); } = KisPropertiesConfiguration* KisWdgColor::configuration() const { KisFilterConfiguration* config =3D new KisFilterConfiguration("color",= 1); KoColor c; - c.fromQColor(this->widget()->bnColor->color()); + c.fromKoColor(this->widget()->bnColor->color()); QVariant v; v.setValue(c); config->setProperty("color", v); diff --git a/plugins/generators/solid/kis_wdg_color.h b/plugins/generators/= solid/kis_wdg_color.h index 2410a14..55ce1e5 100644 --- a/plugins/generators/solid/kis_wdg_color.h +++ b/plugins/generators/solid/kis_wdg_color.h @@ -22,6 +22,8 @@ #define KIS_WDG_COLOR_H = #include +#include +#include = class Ui_WdgColorOptions; = @@ -29,7 +31,7 @@ class KisWdgColor : public KisConfigWidget { Q_OBJECT public: - KisWdgColor(QWidget* parent =3D 0); + KisWdgColor(QWidget* parent =3D 0, const KoColorSpace *cs =3D KoColorS= paceRegistry::instance()->rgb8()); ~KisWdgColor(); public: inline const Ui_WdgColorOptions* widget() const { @@ -39,6 +41,7 @@ public: virtual KisPropertiesConfiguration* configuration() const; private: Ui_WdgColorOptions* m_widget; + const KoColorSpace *m_cs; }; = #endif diff --git a/plugins/generators/solid/wdgcoloroptions.ui b/plugins/generato= rs/solid/wdgcoloroptions.ui index a28c4ad..b1f3e5e 100644 --- a/plugins/generators/solid/wdgcoloroptions.ui +++ b/plugins/generators/solid/wdgcoloroptions.ui @@ -25,7 +25,7 @@
- + @@ -63,9 +63,9 @@ - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h
diff --git a/plugins/impex/jpeg/kis_jpeg_export.cc b/plugins/impex/jpeg/kis= _jpeg_export.cc index 8169266..c252383 100644 --- a/plugins/impex/jpeg/kis_jpeg_export.cc +++ b/plugins/impex/jpeg/kis_jpeg_export.cc @@ -31,6 +31,7 @@ #include = #include +#include #include #include #include @@ -120,8 +121,11 @@ KisImportExportFilter::ConversionStatus KisJPEGExport:= :convert(const QByteArray& wdgUi.chkSaveProfile->setChecked(cfg.getBool("saveProfile", true)); = QStringList rgb =3D cfg.getString("transparencyFillcolor", "255,255,25= 5").split(','); - wdgUi.bnTransparencyFillColor->setDefaultColor(Qt::white); - wdgUi.bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[1].= toInt(), rgb[2].toInt())); + KoColor background(KoColorSpaceRegistry::instance()->rgb8()); + background.fromQColor(Qt::white); + wdgUi.bnTransparencyFillColor->setDefaultColor(background); + background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].to= Int())); + wdgUi.bnTransparencyFillColor->setColor(background); = frm.setEnabledFilters(cfg.getString("filters").split(',')); = @@ -170,7 +174,7 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::= convert(const QByteArray& options.xmp =3D wdgUi.xmp->isChecked(); cfg.setProperty("xmp", options.xmp); = - QColor c =3D wdgUi.bnTransparencyFillColor->color(); + QColor c =3D wdgUi.bnTransparencyFillColor->color().toQColor(); options.transparencyFillColor =3D c; cfg.setProperty("transparencyFillcolor", QString("%1,%2,%3").arg(c.red= ()).arg(c.green()).arg(c.blue())); = diff --git a/plugins/impex/jpeg/kis_wdg_options_jpeg.ui b/plugins/impex/jpe= g/kis_wdg_options_jpeg.ui index eb0dbbd..c159651 100644 --- a/plugins/impex/jpeg/kis_wdg_options_jpeg.ui +++ b/plugins/impex/jpeg/kis_wdg_options_jpeg.ui @@ -6,7 +6,7 @@ 0 0 - 537 + 545 390 @@ -41,7 +41,7 @@ 20 - + 0 @@ -89,7 +89,7 @@ - + 0 @@ -145,7 +145,7 @@ 20 - + 0 @@ -343,16 +343,16 @@ - KColorButton - QPushButton -
kcolorbutton.h
-
- KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1
+ + KisColorButton + QPushButton +
kis_color_button.h
+
tabWidget diff --git a/plugins/impex/png/kis_png_export.cc b/plugins/impex/png/kis_pn= g_export.cc index 7edb7cd..0f3aaf0 100644 --- a/plugins/impex/png/kis_png_export.cc +++ b/plugins/impex/png/kis_png_export.cc @@ -28,6 +28,7 @@ #include = #include +#include #include #include #include @@ -165,8 +166,11 @@ KisImportExportFilter::ConversionStatus KisPNGExport::= convert(const QByteArray& wdg->chkForceSRGB->setChecked(cfg.getBool("forceSRGB", false)); = QStringList rgb =3D cfg.getString("transparencyFillcolor", "0,0,0"= ).split(','); - wdg->bnTransparencyFillColor->setDefaultColor(Qt::white); - wdg->bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[= 1].toInt(), rgb[2].toInt())); + KoColor background(KoColorSpaceRegistry::instance()->rgb8()); + background.fromQColor(Qt::white); + wdg->bnTransparencyFillColor->setDefaultColor(background); + background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2= ].toInt())); + wdg->bnTransparencyFillColor->setColor(background); = kdb->setMainWidget(wdg); QApplication::restoreOverrideCursor(); @@ -182,7 +186,7 @@ KisImportExportFilter::ConversionStatus KisPNGExport::c= onvert(const QByteArray& bool interlace =3D wdg->interlacing->isChecked(); int compression =3D (int)wdg->compressionLevel->value(); bool tryToSaveAsIndexed =3D wdg->tryToSaveAsIndexed->isChecked(); - QColor c =3D wdg->bnTransparencyFillColor->color(); + QColor c =3D wdg->bnTransparencyFillColor->color().toQColor(); bool saveSRGB =3D wdg->chkSRGB->isChecked(); bool forceSRGB =3D wdg->chkForceSRGB->isChecked(); = diff --git a/plugins/impex/png/kis_wdg_options_png.ui b/plugins/impex/png/k= is_wdg_options_png.ui index 3e4eb99b..405c28e 100644 --- a/plugins/impex/png/kis_wdg_options_png.ui +++ b/plugins/impex/png/kis_wdg_options_png.ui @@ -6,7 +6,7 @@ 0 0 - 476 + 546 243 @@ -52,7 +52,7 @@
- + Note: the compression level does not change the quality of= the result @@ -159,7 +159,7 @@ Enabling interlacing will cause the image to be display= ed by the browser even wh - + 0 @@ -205,9 +205,9 @@ Enabling interlacing will cause the image to be display= ed by the browser even wh 1
- KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h