Skip to content

Refactor Color Selector tool to stop drawing directly to ImageView#686

Closed
HiCamino wants to merge 1 commit into
HaikuArchives:masterfrom
HiCamino:alpha-bg-colorselector
Closed

Refactor Color Selector tool to stop drawing directly to ImageView#686
HiCamino wants to merge 1 commit into
HaikuArchives:masterfrom
HiCamino:alpha-bg-colorselector

Conversation

@HiCamino
Copy link
Copy Markdown
Contributor

This code needs HiCamino@1f79d69 to work properly

  • Removed drawing / erasing code from ColorSelectorTool::UseTool
  • in ImageView::DrawBrush draw rect for color selection

MUST TEST with #685 applied first

- Set default for "bg" parameter in Image::Render to false so it doesn't draw the checker bg
- Remove code to render the checker bg in Image::DoRenderPreview
- In ImageView add checker bg bitmap. it is the size of two checker squares and is drawn as a tiled
  bitmap first thing in the ImageView::Draw function. the bitmap is drawn in the ImageView::MakeBackground()
  function and this is also called when the settings change to redraw the background bitmap
- in ImageView::Draw the background is drawn first and the brush drawing was also moved here. this is
  because in Haiku drawing should happen only in the Draw() function so other Draw commands were removed
  unless in functions called by Draw().
- ImageView::BlitImage() uses alpha drawing mode to draw the changed bitmap parts
- ImageView::UpdateImage() uses Invalidate() to force redraw but doesn't use BlitImage() anymore
- ImageView::MouseDown() invalidates window region when scrolling view to force redraw
- ImageView::MouseUp() code is not needed because DrawBrush happens in Draw()
- ImageView::MouseMoved() invalidates area where brush is drawn but doesn't draw brush because it
  happens in Draw() function. Also the Draw() when the mouse leaves the view is changed to Invalidate()
- ImageView::DrawBrush() clear code is not needed because Draw erases the bg before calling DrawBrush.
  Also calls to Draw are replaced by Invalidate()
- A few tools (FreeLineTool, EraserTool, HairyBrushTool) make sure updated_rect is within the image bounds
  to prevent crashes

Refactor Color Selector tool to stop drawing directly to ImageView
- Removed drawing / erasing code from ColorSelectorTool::UseTool
- in ImageView::DrawBrush draw rect for color selection
@HiCamino HiCamino force-pushed the alpha-bg-colorselector branch 2 times, most recently from 62145f8 to d8a2fae Compare January 1, 2026 22:38
@humdingerb
Copy link
Copy Markdown
Member

Superceded by #687

@humdingerb humdingerb closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants