KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
5.1KB

  1. Selections in Chalk
  2. Please disregard any lingering presence of the KisFloatingSelection
  3. class and the associated rectangular marque rendering code. If you
  4. find anything connected with that after I finish coding the new
  5. selections scheme, it's something I forgot.
  6. Selections in Chalk are special paint devices as big as their parent
  7. layer. The selection has the alpha colour strategy. The alpha channel
  8. contains the selectedness of a pixel. It is not a binary value, but a scale,
  9. hardcoded to 8 bits unsigned
  10. TODO: * implement heterogenous compositing. (Needs knowledge by the
  11. target layer of the color strategy of the source layer).
  12. Selections can be changed using tools that are clones of the usual
  13. painting tools: brush, eraser, polygon, etc.
  14. TODO: * implement most of these, the polygon, circle, rectangle tools
  15. should fill by default. XXX: make it easier to leverage the
  16. code for the standard tools: after all, the only difference
  17. is which layer they should paint on.
  18. XXX: Fill-by-default should be an option for the polygon, circle,
  19. rectangle painting tools, too.
  20. Selections can also changed by procedures like select-by-color etc.
  21. TODO: * finish dialog for select by color
  22. * implement select-by-color (depends on usable iterators)
  23. Selections are represented as 0== unselected and 255 == fully
  24. selected. Values in between are semi selected
  25. Other representations of selections are possible: the selection for a
  26. particular rect is rendered as a separate step in
  27. KisImage::renderToProjection. I like the mask type rendering, but
  28. someone else might want to provide an optional marque-rendering.
  29. TODO: * enable kconfig option to select between renderings.
  30. Selected pixels can be mangled -- for instance, filled with a
  31. gradient, moved, made brighter, lighter or sprightlier, cut and
  32. pasted. These manglings fall into two groups: the kind that demands
  33. that the selected pixels are removed from their native layer, and the
  34. kind that merely changes their value.
  35. A) Moving, cutting, copying, pasting.
  36. Each of these operations moves pixels to a new KisLayer that is not
  37. part of the regular stack of layers. The operations are defined as
  38. follows:
  39. Moving: create new layer, copy selected pixels to this layer, set
  40. pixels in old layer to transparent background colour, set new layer
  41. visible.
  42. Cutting: create new layer, copy selected pixels to this layer, set
  43. pixels in old layer to transparent background colour, add new layer to
  44. the cut scrapbook (if we're going to have such a thing).
  45. XXX: Discuss desirability of cut scrapbook.
  46. Copying: create new layer, copy selected pixels to this layer, add new
  47. layer to the cut scrapbook (if we're going to have such a thing).
  48. Pasting: check if cut or copy layer exists in scrapbook, copy pixels
  49. from this layer to the target layer.
  50. B) Changing the value of selected pixels
  51. Use cases: fills (gradient, pattern, color), filtering.
  52. Fills are easiest implemented by creating a filled paint device for
  53. the rect covered by the selection, and then, while composting the fill
  54. with the target layer, pass the mask to the compositing loop, and skip
  55. un-selected pixels.
  56. XXX: Discuss whether this is true
  57. Filtering needs looping over all pixels of a layer, and, if selection
  58. is present, only apply filter to the selected pixel.
  59. XXX: What about convolving, which takes a matrix of pixels. If only
  60. the middle pixel of a matrix is selected, should we take the input of
  61. the surrounding unselected pixels, or should the operation then assume
  62. edge conditions? Or should this be an option?
  63. TODO: infrastructure for all these operations, actual implementation.
  64. Actions to a selection need to be undoable.
  65. TODO: Make it so.
  66. I am not sure whether selections need to be saved and loaded:
  67. Photoshop offers this, but our selection mechanism works differently.
  68. The Gimp offers selection adding/subtracting, but that's also not
  69. really necessary. A good idea is perhaps to add a combobox to the
  70. selection tool properties widget to choose between 'select' and
  71. 'deselect', where the brush is initially set to 'select' and the
  72. eraser to 'deselect'.
  73. From a thread in the mailing list Boudewijn wrote:
  74. -----------------------------------------------------------------------
  75. This is the behaviour I expect from a paint app:
  76. If there's a selection on the current layer, only the selected pixels in the
  77. current layer should be transformed, rotated, scaled or sheared. This happens
  78. within the layer. If the new pixels overlap untransformed pixels, they are
  79. composed with the giving composite op and opacity.
  80. If there's no selection, a transform on a layer should transform all pixels in
  81. a layer, i.e., act as if the layer was completely selected. No new layer is
  82. created. There is no composition, because the old layer data is completely
  83. discarded.
  84. If a transform is applied to a image, all layers are transformed. The
  85. selection is transformed, too: in the new situation, the layer that has a
  86. selection active still has a selection, but the tqshape of the selection is
  87. transformed.
  88. If a layer is moved, the selection moves with the layer (this is not
  89. implemented yet).
  90. A transform never creates a new layer (expect perhaps temporarily and it
  91. wouldn't be visible to the user).