I develop GUI library from scratch (use only SFML drawing primitives - e.g. rectangles). This project is mostly about developing complex OOP system. At this stage I've already used several OOP patterns like:
- Compositor for Widget system.
- Strategy for canvas drawing tools.
- Decorator for texted and textured buttons.
[Button]
state = PRESS | UNPRESS
position
size
color
funcs:
process_click()
press()
unpress()
is_in_area()
results:
- button changes state (and color) with click
- mutex button manager (only one button can be pressed)
results:
- point is drawn when click on button
results:
- draw on canvas with active color
- draw on canvas with active instrument
Buttons:
- red, green, blue - set canvas active color
- brush, eraser [const white brush], pouring [check pouring algo] - set canvas active instrument
Parameterize canvas with instrument (make class from instrument).
[Instrument]
properties: size...
funcs:
apply(position)
results:
- textured widget
- text on widget
- load picture -> text input box (button that on click gets keyboard input)
Use decorator pattern to implement decorations.
results:
- Apply filter to every pixel when click on concrete filter
Filters:
- B&W [R=G=B = average(R,G,B)]
- inverse [R=255-R ...]
- Blur (check B2B1 video about convolution)
results:
- Drop-down menu when click on filter button
results:
- New tools (that need layering)
Tools:
- Line
- Rectangle
- Triangle
- Polyline
Tree traverse and dump Restore from dump (check factory pattern)
2 mods:
- canvas works as screen for raytracer
- paint
Objects can be added to the scene on air with special menu. Also spheres can be dragged directly by touching image.
(for spheres managing MVC may be applied)
- undo opearation (history of operations? queue of instruments applied? and should be considered - how to reverse them)
- save picture (guess smth with sfml)
- load picture (guess smth with sfml and OS interaction)
- help panel
- plugins
- instruments to toolbox: line, rectangle (!!)
- set properties for instruments (size for brush)
- filters with curves
- user can add new layers, choose one to draw on it