Skip to content

Refactor SelectorTool to not draw directly to ImageView#687

Merged
humdingerb merged 1 commit into
HaikuArchives:masterfrom
HiCamino:alpha-bg-selection
Jan 5, 2026
Merged

Refactor SelectorTool to not draw directly to ImageView#687
humdingerb merged 1 commit into
HaikuArchives:masterfrom
HiCamino:alpha-bg-selection

Conversation

@HiCamino
Copy link
Copy Markdown
Contributor

@HiCamino HiCamino commented Dec 29, 2025

  • add SelectorTool to ImageView::DrawBrush so selection draws during Draw() function
  • in SelectorTool store the points for a selection in progress. "selectionPoints" is for
    drawing selections like rectangle or ellipse. "activePoints" is needed for intelligent scissors
    because there is the part currenyly being drawn and then "selectionPoints" is for the part that the user
    drew before clicking the mouse.
  • add SelectorTool::DrawSelection function to draw in progress selections based on points stored
    in SelectorTool::UseTool
  • removed drawing code from SelectorTool::UseTool. store points for selections. use ImageUpdater
    like other drawing tools to update the image instead of drawing directly to the view

NEEDS commit 1f79d69

aka MUST TEST with #685 applied first

Refactor ImageView drawing to remove checker background from render
- 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

Refactor SelectorTool to not draw directly to ImageView
- add SelectorTool to ImageView::DrawBrush so selection draws during Draw() function
- in SelectorTool store the points for a selection in progress. "selectionPoints" is for
  drawing selections like rectangle or ellipse. "activePoints" is needed for intelligent scissors
  because there is the part currenyly being drawn and then "selectionPoints" is for the part that the user
  drew before clicking the mouse.
- add SelectorTool::DrawSelection function to draw in progress selections based on points stored
  in SelectorTool::UseTool
- removed drawing code from SelectorTool::UseTool. store points for selections. use ImageUpdater
  like other drawing tools to update the image instead of drawing directly to the view
@HiCamino HiCamino force-pushed the alpha-bg-selection branch from 8dea339 to fd8a636 Compare January 3, 2026 00:46
@HiCamino
Copy link
Copy Markdown
Contributor Author

HiCamino commented Jan 3, 2026

added a quick fix so the cursors work again

@HiCamino HiCamino force-pushed the alpha-bg-selection branch from fd8a636 to 38c7880 Compare January 3, 2026 01:39
@humdingerb
Copy link
Copy Markdown
Member

Thanks very much!

@humdingerb humdingerb merged commit 4022995 into HaikuArchives:master Jan 5, 2026
4 checks passed
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