Skip to content

IDE-109: Implement collapseable scripts and composite bricks#5196

Draft
harshsomankar123-tech wants to merge 2 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/IDE-109-collapseable-scripts
Draft

IDE-109: Implement collapseable scripts and composite bricks#5196
harshsomankar123-tech wants to merge 2 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/IDE-109-collapseable-scripts

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Member

Description

Jira Ticket::[(https://catrobat.atlassian.net/browse/IDE-109)]

Summary of Changes:
This pull request introduces the ability to collapse and expand Scripts and Composite Bricks (such as loops) within the workspace. This enhancement significantly improves project navigation and code readability by allowing users to temporarily hide complex or lengthy blocks of logic.

Key Technical Implementations:

  • State Management: Introduced a transient collapsed state to both Script and BrickBaseType to track visibility without permanently altering the project model.
  • View Filtering: Updated the list rendering logic to actively filter out and hide the children of collapsed CompositeBrick items from the flat list.
  • Interactions & Menus: * Implemented a new collapse/expand Action Mode that ensures all checkboxes remain visible for seamless bulk operations.
    • Added dedicated context menu items for toggling individual scripts and loops.
    • Integrated a global collapse_expand menu option into the SpriteActivity.
  • Visual Feedback: * Added a FrameLayout overlay to serve as a visual indicator, which is strictly displayed only when an item is in its collapsed state.
    • Included new ic_collapse and ic_expand vector drawables to support the UI updates.

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

- Add transient collapsed state to Script and BrickBaseType
- Add collapse/expand action mode with ALL checkboxes visible
- Add context menu items for individual script/loop collapse
- Add FrameLayout overlay collapse indicator (only shown when collapsed)
- Filter collapsed CompositeBrick children from flat list
- Add ic_collapse/ic_expand vector drawables
- Add collapse_expand menu item to SpriteActivity
@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft April 15, 2026 01:27
updateItemsFromCurrentScripts()
}

private fun handleCheckBoxModeCollapseExpand(item: Brick) {
return R.drawable.ic_library_add_small;
case R.string.menu_rate_us:
return R.drawable.ic_star_rate;
case R.string.brick_context_dialog_collapse_script:
case R.string.brick_context_dialog_collapse_script:
case R.string.brick_context_dialog_collapse_brick:
return R.drawable.ic_collapse;
case R.string.brick_context_dialog_expand_script:
case R.id.comment_in_out:
startActionMode(COMMENT);
break;
case R.id.collapse_expand:
}
listView.highlightControlStructureBricks(positions);
break;
case R.string.brick_context_dialog_collapse_script:
brick.getScript().setCollapsed(true);
adapter.updateItems(ProjectManager.getInstance().getCurrentSprite());
break;
case R.string.brick_context_dialog_expand_script:
brick.getScript().setCollapsed(false);
adapter.updateItems(ProjectManager.getInstance().getCurrentSprite());
break;
case R.string.brick_context_dialog_collapse_brick:
((BrickBaseType) brick).setCollapsed(true);
adapter.updateItems(ProjectManager.getInstance().getCurrentSprite());
break;
case R.string.brick_context_dialog_expand_brick:
@harshsomankar123-tech harshsomankar123-tech added the WIP Work in progress label Apr 15, 2026
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.annotation.IntDef
import androidx.core.content.ContextCompat
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.annotation.IntDef
import androidx.core.content.ContextCompat
notifyDataSetChanged()
}

private fun filterCollapsedCompositeBricks() {
private fun filterCollapsedCompositeBricks() {
val filteredItems = ArrayList<Brick>()
squashedBricks.clear()

private fun filterCollapsedCompositeBricks() {
val filteredItems = ArrayList<Brick>()
squashedBricks.clear()

scaleType = ImageView.ScaleType.CENTER_INSIDE
val density = resources.displayMetrics.density
layoutParams = FrameLayout.LayoutParams(
(32 * density).toInt(),
val density = resources.displayMetrics.density
layoutParams = FrameLayout.LayoutParams(
(32 * density).toInt(),
(32 * density).toInt()
(32 * density).toInt()
).apply {
gravity = Gravity.END or Gravity.CENTER_VERTICAL
marginEnd = (8 * density).toInt()
marginEnd = (8 * density).toInt()
}
setColorFilter(Color.WHITE)
alpha = if (isCollapsed) 0.8f else 0.5f
marginEnd = (8 * density).toInt()
}
setColorFilter(Color.WHITE)
alpha = if (isCollapsed) 0.8f else 0.5f
@sonarqubecloud
Copy link
Copy Markdown

if (itemView is ViewGroup) {
itemView.clipChildren = true
// Hide checkbox
if (itemView.childCount > 0) {
)
if (itemView is ViewGroup) {
itemView.clipChildren = false
if (itemView.childCount > 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants