On 28 February 2017 at 15:34, Nyall Dawson <nyall.daw...@gmail.com> wrote: > On 21 February 2017 at 00:31, Matthias Kuhn <matth...@opengis.ch> wrote: >> I'd say in the API we should be closer to the data and hence use 0-255, in >> the slider we convert it to 0-100%. >> We could possibly have a slider that allows for 255 positions but prints >> numbers from 0%-100%? >> >> Are you aware of systems where there are more values than 8 bits for the >> alpha channel (for which we should prepare)? >> It wouldn't be a much bigger deal to go this road, but I think it shouldn't >> be purely prophylactic without real needs in mind. > > > Here's the tricky bit - using 0-255 and storing as an int doesn't > translate well to displaying in a slider with values from 0-100. You > need to allow 0.1 steps in the slider to avoid loss of precision, but > then you get the confusing behaviour for users where they set the > slider to 91.2, and reopen to find it's changed to 91.3 (made up > numbers). > > I'd like to avoid that, so I think in api we should always use a > double with range 0-1 for storing opacity. This can be exposed to > users on a 0-100 scale, but also converted to a 0-255 int for > rendering/etc without issue.
For reference - this has been fixed in master. Now: - all opacity/transparency/alpha related api is setOpacity()/opacity() , using doubles from 0 (transparent) to 1 (opaque) - all UI controls use a standard QgsOpacityWidget control which shows the opacity from 0 -> 100% (allowing 0.1% increments) Nyall _______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer