Implement Group/Ungroup Shapes Functionality #36

Open
opened 2026-03-27 23:18:11 +00:00 by thib8956 · 0 comments
Owner

Overview

Implement functionality to group multiple shapes into a single unit and ungroup them.

Current State

  • SCollection already exists as composite pattern implementation
  • SCollection supports add(), remove(), and child iteration
  • No UI for creating groups from selection

Implementation Plan

1. Group operation

  • Select multiple shapes
  • Press G (or menu item) to group
  • Create new SCollection containing selected shapes
  • Replace selected shapes with the group in model
  • Select the new group

2. Ungroup operation

  • Select a SCollection (group)
  • Press U (or menu item) to ungroup
  • Add all children to model at top level
  • Remove the SCollection from model
  • Select all the ungrouped shapes

3. Visual feedback

  • Groups show different selection highlight (thicker border or different color)
  • Double-click to enter group (edit children)? Or keep flat?
  • Show group bounds when selected

4. Operations on groups

  • Move: translate all children (already works via SCollection.translate())
  • Resize: either resize bounds only or resize proportionally
  • Color: apply to all children (already works)
  • Delete: remove group and all children

5. Nested groups

  • Allow groups within groups (SCollection can contain SCollection)
  • Recursive operations

Files to modify

  • Modify: ui/Controller.java - add group/ungroup handlers
  • Modify: App.java - add menu items
  • Modify: ui/ShapeDraftman.java - different rendering for groups

Edge cases

  • Ungroup empty collection: just remove it
  • Group single shape: valid but maybe warn
  • Nested groups: recursive ungroup option?
  • Move child out of group: not supported initially
## Overview Implement functionality to group multiple shapes into a single unit and ungroup them. ## Current State - SCollection already exists as composite pattern implementation - SCollection supports add(), remove(), and child iteration - No UI for creating groups from selection ## Implementation Plan ### 1. Group operation - Select multiple shapes - Press G (or menu item) to group - Create new SCollection containing selected shapes - Replace selected shapes with the group in model - Select the new group ### 2. Ungroup operation - Select a SCollection (group) - Press U (or menu item) to ungroup - Add all children to model at top level - Remove the SCollection from model - Select all the ungrouped shapes ### 3. Visual feedback - Groups show different selection highlight (thicker border or different color) - Double-click to enter group (edit children)? Or keep flat? - Show group bounds when selected ### 4. Operations on groups - Move: translate all children (already works via SCollection.translate()) - Resize: either resize bounds only or resize proportionally - Color: apply to all children (already works) - Delete: remove group and all children ### 5. Nested groups - Allow groups within groups (SCollection can contain SCollection) - Recursive operations ## Files to modify - Modify: ui/Controller.java - add group/ungroup handlers - Modify: App.java - add menu items - Modify: ui/ShapeDraftman.java - different rendering for groups ## Edge cases - Ungroup empty collection: just remove it - Group single shape: valid but maybe warn - Nested groups: recursive ungroup option? - Move child out of group: not supported initially
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thib8956/new-shapes#36