Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger dynamic layouts #630

Merged
merged 7 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 62 additions & 9 deletions src/NewTools-Debugger/StDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ Class {
'EnableStackColoring',
'FastTDD'
],
#classInstVars : [
'layoutConfigurator'
],
#category : 'NewTools-Debugger-View',
#package : 'NewTools-Debugger',
#tag : 'View'
Expand Down Expand Up @@ -122,6 +125,19 @@ StDebugger class >> closeAllDebuggers [
self allInstancesDo: [ :dbg | dbg close ]
]

{ #category : 'accessing' }
StDebugger class >> configureLayout [
^self layoutConfigurator selectedLayout
]

{ #category : 'accessing' }
StDebugger class >> configureLayout: aSymbol [

self layoutConfigurator selectedLayout: aSymbol.
SystemAnnouncer uniqueInstance announce:
StDebuggerLayoutChangedAnnouncement new
]

{ #category : 'instance creation' }
StDebugger class >> debugSession: aDebugSession [

Expand All @@ -140,6 +156,21 @@ StDebugger class >> debuggerContextClass [
^ StDebuggerContext
]

{ #category : 'accessing' }
StDebugger class >> debuggerLayoutSettingsOn: aBuilder [

<systemsettings>
(aBuilder pickOne: #configureLayout)
parent: #debugging;
label: 'Debugger Layout';
target: StDebugger;
default: #beVerticalStackThenCode;
domainValues:
#( #beHorizontalCodeThenStack #beHorizontalStackThenCode
#beVerticalCodeThenStack #beVerticalStackThenCode );
description: ''
]

{ #category : 'accessing' }
StDebugger class >> defaultDebuggerRank [

Expand Down Expand Up @@ -201,6 +232,13 @@ StDebugger class >> initialize [
EnableStackColoring := true
]

{ #category : 'accessing' }
StDebugger class >> layoutConfigurator [

^ layoutConfigurator ifNil: [
layoutConfigurator := StDebuggerLayoutConfiguration new ]
]

{ #category : 'opening' }
StDebugger class >> openOn: aDebugSession withFullView: aBool [

Expand Down Expand Up @@ -370,7 +408,7 @@ StDebugger >> code [
^ code
]

{ #category : 'specs' }
{ #category : 'layout' }
StDebugger >> codeLayout [

^ SpBoxLayout newTopToBottom
Expand Down Expand Up @@ -671,6 +709,7 @@ StDebugger >> initialize [
self debuggerActionModel updateContextPredicate.
self forceSessionUpdate.
self susbcribeToExtensionToggleAnnouncement.
self susbcribeToLayoutChangesAnnouncement.

programmaticallyClosed := false.
]
Expand Down Expand Up @@ -1144,17 +1183,15 @@ StDebugger >> stack [

]

{ #category : 'specs' }
{ #category : 'layout' }
StDebugger >> stackAndCodeLayout [

^ SpPanedLayout newTopToBottom
positionOfSlider: 30 percent;
add: self stackLayout;
add: self codeLayout;
yourself
^ self class layoutConfigurator configureForLayouts: {
(#stack -> self stackLayout).
(#code -> self codeLayout) } asDictionary
]

{ #category : 'specs' }
{ #category : 'layout' }
StDebugger >> stackAndCodeWithExtensionsLayout [

^ (SpPanedLayout newLeftToRight
Expand Down Expand Up @@ -1199,7 +1236,7 @@ StDebugger >> stackIconForContext: context [
^ self iconNamed: #overlayDirty
]

{ #category : 'specs' }
{ #category : 'layout' }
StDebugger >> stackLayout [
^ SpBoxLayout newTopToBottom
add: #stackHeader
Expand Down Expand Up @@ -1291,6 +1328,15 @@ StDebugger >> susbcribeToExtensionToggleAnnouncement [
to: self
]

{ #category : 'subscription' }
StDebugger >> susbcribeToLayoutChangesAnnouncement [

SystemAnnouncer uniqueInstance weak
when: StDebuggerLayoutChangedAnnouncement
send: #updateLayout
to: self
]

{ #category : 'accessing - presenters' }
StDebugger >> toolbar [

Expand Down Expand Up @@ -1443,6 +1489,13 @@ StDebugger >> updateInspectorFromContext: aContext [
inspector getRawInspectorPresenterOrNil ifNotNil: [ :p | p update ]
]

{ #category : 'updating' }
StDebugger >> updateLayout [

self setStackAndCodeContainer.
self layout: self defaultLayout
]

{ #category : 'initialization' }
StDebugger >> updatePresenter [

Expand Down
10 changes: 10 additions & 0 deletions src/NewTools-Debugger/StDebuggerLayoutChangedAnnouncement.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"
I am announced when the debugger layout has changed, to allow open debuggers to dynamically update their layouts.
"
Class {
#name : 'StDebuggerLayoutChangedAnnouncement',
#superclass : 'Announcement',
#category : 'NewTools-Debugger-Model',
#package : 'NewTools-Debugger',
#tag : 'Model'
}
83 changes: 83 additions & 0 deletions src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"
A trivial layout configurator for the `StDebugger`.
It is configureable through api methods.
To change the layout, it takes as input a dictionary with the name of the element to layout associated to the element itself.
"
Class {
#name : 'StDebuggerLayoutConfiguration',
#superclass : 'Object',
#instVars : [
'order',
'selectedLayout'
],
#category : 'NewTools-Debugger-Model',
#package : 'NewTools-Debugger',
#tag : 'Model'
}

{ #category : 'configuration' }
StDebuggerLayoutConfiguration >> beHorizontalCodeThenStack [

order := #( #code #stack ).
^ SpPanedLayout newLeftToRight
positionOfSlider: 30 percent;
yourself
]

{ #category : 'configuration' }
StDebuggerLayoutConfiguration >> beHorizontalStackThenCode [

order := #( #stack #code ).
^ SpPanedLayout newLeftToRight
positionOfSlider: 30 percent;
yourself
]

{ #category : 'configuration' }
StDebuggerLayoutConfiguration >> beVerticalCodeThenStack [

order := #( #code #stack ).
^ SpPanedLayout newTopToBottom
positionOfSlider: 30 percent;
yourself
]

{ #category : 'configuration' }
StDebuggerLayoutConfiguration >> beVerticalStackThenCode [

order := #( #stack #code ).
^ SpPanedLayout newTopToBottom
positionOfSlider: 30 percent;
yourself
]

{ #category : 'configuration' }
StDebuggerLayoutConfiguration >> configureForLayouts: layoutsDictionary [

| layout |
layout := self perform: selectedLayout.

order do: [ :layoutSymbol |
layoutsDictionary at: layoutSymbol ifPresent: [ :l | layout add: l ] ].

^ layout
]

{ #category : 'initialization' }
StDebuggerLayoutConfiguration >> initialize [

order := #( #stack #code ).
selectedLayout := #beVerticalStackThenCode
]

{ #category : 'accessing' }
StDebuggerLayoutConfiguration >> selectedLayout [

^ selectedLayout
]

{ #category : 'accessing' }
StDebuggerLayoutConfiguration >> selectedLayout: anObject [

selectedLayout := anObject
]