Skip to content

Commit

Permalink
Working on Accordeon
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jan 29, 2025
1 parent 268bac4 commit 86dfe5f
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 185 deletions.
2 changes: 1 addition & 1 deletion src/Toplo-Examples/ToElementWithEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ToElementWithEditor >> beforeEditorOpened: anEditor fromManager: aManager [
do: [ :event | aManager closeWindow ].

anEditor text: (contents ifNil: [self background paint color asString]).
anEditor infinite requestFocus.
anEditor requestFocus.
anEditor selecter
all;
apply.
Expand Down
51 changes: 46 additions & 5 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ ToSandBox class >> example_CodeEditor [
disabox := ToCheckMenuItem new label: (ToLabel text: 'Disable').

menuBar := ToMenuBar new.
menuBar hMatchParent.
menuBar addItem: fileMenu.
menuBar addItem: inspectBtn.
menuBar addItem: showStatisticsBtn.
Expand Down Expand Up @@ -983,6 +984,46 @@ ToSandBox class >> example_EditableList2WithAllClassesNames [
space show
]

{ #category : #album }
ToSandBox class >> example_EditorWithMinHeight [

| pane menuBar text album disabox inspectBtn showStatisticsBtn |
pane := ToPane vertical matchParent.

text := ''.
album := ToAlbum new.
album hMatchParent.
album vFitContent.
album next constraintsDo: [ :c |
c vertical fitContent.
c horizontal matchParent ].
album infinite constraintsDo: [ :c |
c vertical fitContent.
c horizontal matchParent ].
album text: text copy.
album minHeight: 100.

inspectBtn := ToMenuItem new labelText: 'Inspect'.
showStatisticsBtn := ToMenuItem new labelText: 'Statistics'.
disabox := ToCheckMenuItem new label: (ToLabel text: 'Disable').

menuBar := ToMenuBar new.
menuBar hMatchParent.
menuBar addItem: inspectBtn.
menuBar addItem: showStatisticsBtn.
menuBar addItem: disabox.

pane addChild: menuBar.
pane addChild: album.

inspectBtn whenClickedDo: [ :evt | album space root inspect ].
disabox whenClickedDo: [ :evt | album disabled: disabox isChecked ].
showStatisticsBtn whenClickedDo: [ :evt |
album space showStatisticsWindow ].

pane openInSpace
]

{ #category : #album }
ToSandBox class >> example_EditorWithPlaceholder [

Expand All @@ -1002,8 +1043,8 @@ ToSandBox class >> example_EditorWithPlaceholder [
withRowNumbers;
withSaveCapability;
whenSaveRequestedDo: [ :saveRequested |
saveRequested client saveResult: true ];
withEditsFeedback.
saveRequested accepted: true ];
yourself.
view openInInnerWindow
]

Expand All @@ -1027,7 +1068,7 @@ ToSandBox class >> example_EditorWithPlaceholderWithAlbum [
withRowNumbers;
withSaveCapability;
whenSaveRequestedDo: [ :saveRequested |
saveRequested client saveResult: true ];
saveRequested accepted: true ];
withEditsFeedback.
view openInInnerWindow
]
Expand All @@ -1041,10 +1082,10 @@ ToSandBox class >> example_EditorWithoutSoftLine [
withRowNumbers;
withSaveCapability;
whenSaveRequestedDo: [ :saveRequested |
saveRequested client saveResult: true ];
saveRequested accepted: true ];
withEditsFeedback.
view withoutSoftLine.
view text: ((String loremIpsum: 100000) asRopedText fontName: 'Source Code Pro').
view text: ((String loremIpsum: 10000) asRopedText fontName: 'Source Code Pro').
view openInSpace
]

Expand Down
20 changes: 10 additions & 10 deletions src/Toplo-Examples/ToWorkspaceExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Class {
#name : #ToWorkspaceExample,
#superclass : #Object,
#instVars : [
'textModel',
'bindings'
'bindings',
'album'
],
#category : #'Toplo-Examples-TopLevel'
}
Expand Down Expand Up @@ -72,8 +72,8 @@ ToWorkspaceExample >> correctFrom: start to: stop with: aString [
ToWorkspaceExample >> doIt [

| toDo |
toDo := textModel selectedText asString.
toDo ifEmpty: [ toDo := textModel text asString ].
toDo := album selectedText asString.
toDo ifEmpty: [ toDo := album text asString ].
[
OpalCompiler new
source: toDo readStream;
Expand All @@ -93,14 +93,14 @@ ToWorkspaceExample >> hasBindingOf: aString [
ToWorkspaceExample >> initialize [
super initialize.
bindings := Dictionary new.
textModel := ToAlbum new.
album := ToAlbum new.

]

{ #category : #'user interface' }
ToWorkspaceExample >> initializeCodeEditor [

textModel
album
withRowNumbers;
placeholderBuilder: [ :thePlaceholder :e | | text lab |
text := (('Workspace example' , String cr , '- doit: Cmd-d') asRopedText
Expand Down Expand Up @@ -145,15 +145,15 @@ ToWorkspaceExample >> openInSpace: aSpace [

| frame |
self initializeCodeEditor.
textModel infinite requestFocus.
textModel showPlaceholder.
album requestFocus.
album showPlaceholder.
frame := ToInnerWindow new title: 'Workspace'.
frame pane addChild: textModel.
frame pane addChild: album.
aSpace root addChild: frame
]

{ #category : #accessing }
ToWorkspaceExample >> text [

^ textModel text
^ album text
]
146 changes: 0 additions & 146 deletions src/Toplo-Widget-Accordion/ToAccordionElement.class.st

This file was deleted.

71 changes: 71 additions & 0 deletions src/Toplo-Widget-Accordion/ToAccordionItemBodyElement.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Class {
#name : #ToAccordionItemBodyElement,
#superclass : #ToElement,
#instVars : [
'builder',
'content',
'preservedContent',
'isBuilt'
],
#category : #'Toplo-Widget-Accordion-Core'
}

{ #category : #accessing }
ToAccordionItemBodyElement >> builder: aValuable [
"With content as argument"

isBuilt := false.
builder := aValuable
]

{ #category : #accessing }
ToAccordionItemBodyElement >> content [

^ content
]

{ #category : #initialization }
ToAccordionItemBodyElement >> initialize [

super initialize.
isBuilt := false.
preservedContent := true.
self initializeContent
]

{ #category : #initialization }
ToAccordionItemBodyElement >> initializeContent [

content := ToElement new
withNullSkin;
background: BlBackground transparent;
layout: BlLinearLayout vertical;
constraintsDo: [ :c |
c vertical fitContent.
c horizontal matchParent ];
yourself.
self addChild: content
]

{ #category : #accessing }
ToAccordionItemBodyElement >> preservedContent: aBoolean [

preservedContent := aBoolean
]

{ #category : #'expanding-collapsing' }
ToAccordionItemBodyElement >> switchCollapsed [

preservedContent ifFalse: [ content removeChildren ].
content visibility: BlVisibility gone
]

{ #category : #'expanding-collapsing' }
ToAccordionItemBodyElement >> switchExpanded [

(isBuilt and: [ preservedContent ]) ifFalse: [
content removeChildren.
builder ifNotNil: [ builder value: content ].
isBuilt := true ].
content visibility: BlVisibility visible
]
Loading

0 comments on commit 86dfe5f

Please sign in to comment.