Skip to content

Commit

Permalink
Merge pull request #44 from ElvinPero/ICelv
Browse files Browse the repository at this point in the history
Toggleable class method + triangle LED
  • Loading branch information
lucretiomsp authored Sep 30, 2024
2 parents a8fa3aa + 8eab942 commit b67d4d9
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 6 deletions.
22 changes: 20 additions & 2 deletions CoypuIDE/TbButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,23 @@ container:= BlElement new

e1:= TbButton new.
e2:= TbLEDButton new.
e3:= TbLEDButton new.
e3:= TbLEDButton toggleable.
e4:= TbLEDDarkButton new.
e5:= TbLEDDarkButton new.
e5:= TbLEDDarkButton toggleable.

container addChildren: { e1 . e2 . e3 . e4 . e5 }.
container openInSpace.



]

{ #category : 'api - attribute' }
TbButton class >> toggleable [
|ele|
ele:= self new.
ele reInitializeEvents.
^ ele.
]

{ #category : 'evaluating' }
Expand Down Expand Up @@ -312,6 +320,16 @@ TbButton >> offColor [

]

{ #category : 'evaluating' }
TbButton >> reInitializeEvents [

button addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent | self toggle ]).


]

{ #category : 'evaluating' }
TbButton >> setValue: req [
self value = req
Expand Down
48 changes: 48 additions & 0 deletions CoypuIDE/TbHorizontalSwitch.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Class {
#name : 'TbHorizontalSwitch',
#superclass : 'TbSwitch',
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'initialization' }
TbHorizontalSwitch >> initializeSwitch [
|s|
self switch: (BlElement new
geometry:(BlRoundedRectangleGeometry cornerRadius: 4);
background: self switchOnColor;
transformDo: [ :t|
t translateBy: 0@ -4 ];
effect: (BlGaussianShadowEffect color: (self shadowColor) offset: 0@ 4 width: 10);
size: 60@35 ;
margin: (BlInsets all: 10);
layout: BlFrameLayout new;
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter.
]).
s:= BlElement new
geometry: (BlRoundedRectangleGeometry cornerRadius: 4);
background: self switchOffColor;
size: 55@25 ;
margin: (BlInsets all: 2);
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignTop.
].
switch addChild: s.
self addChild:self switch.
]

{ #category : 'initialization' }
TbHorizontalSwitch >> initializeWidget [
self size: widgetSize.
self background: (Color gray alpha:0.0).
self layout: BlFrameLayout new.
]

{ #category : 'initialization' }
TbHorizontalSwitch >> initializeWidgetSize [
widgetSize:= 70@50.
]
128 changes: 128 additions & 0 deletions CoypuIDE/TbOnOffSwitch.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
Class {
#name : 'TbOnOffSwitch',
#superclass : 'TbSwitch',
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'initialization' }
TbOnOffSwitch >> initializeSwitch [
|s l1 l2 l3|
self switch: (BlElement new
geometry:(BlRoundedRectangleGeometry cornerRadius: 4);
background: (self switchOnColor );
transformDo: [ :t|
t translateBy: 0@ -4 ];
effect: (BlGaussianShadowEffect color: (self shadowColor) offset: 0@ 4 width: 10);
size: 60@30 ;
margin: (BlInsets all: 10);
layout: BlFrameLayout new;
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter.
]).
s:= BlElement new
geometry: (BlRoundedRectangleGeometry cornerRadius: 4);
background: self switchOffColor;
layout: BlFrameLayout new;
size: 30@25 ;
margin: (BlInsets all: 2);
padding: (BlInsets all: 5);
constraintsDo: [ :c |
c frame horizontal alignLeft.
c frame vertical alignCenter.
].
l1:= BlElement new
geometry: (BlRoundedRectangleGeometry cornerRadius: 2);
background: self lineColor;
layout: BlFrameLayout new;
size: 3@15;
margin: (BlInsets all: 2);
constraintsDo: [ :c |
c frame horizontal alignLeft.
c frame vertical alignCenter.
].
l2:= BlElement new
geometry: (BlRoundedRectangleGeometry cornerRadius: 2);
background: self lineColor;
layout: BlFrameLayout new;
size: 3@15 ;
margin: (BlInsets all: 2);
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter.
].
l3:= BlElement new
geometry: (BlRoundedRectangleGeometry cornerRadius: 2);
background: self lineColor;
layout: BlFrameLayout new;
size: 3@15 ;
margin: (BlInsets all: 2);
constraintsDo: [ :c |
c frame horizontal alignRight.
c frame vertical alignCenter.
].
s addChildren: { l1. l2. l3 }.
switch addChild: s.
self addChild:self switch.
]

{ #category : 'initialization' }
TbOnOffSwitch >> initializeWidget [
self size: widgetSize.
self background: (Color gray alpha:0.0).
self layout: BlFrameLayout new.
]

{ #category : 'initialization' }
TbOnOffSwitch >> initializeWidgetSize [
widgetSize:= 70@50.
]

{ #category : 'initialization' }
TbOnOffSwitch >> lineColor [
^ (Color r:166 g:136 b:108 range:255).


]

{ #category : 'initialization' }
TbOnOffSwitch >> switchOnColor [
^ (Color r:110 g:90 b:70 range:255).
]

{ #category : 'initialization' }
TbOnOffSwitch >> toggle [
self toggleValue.
self value = 1
ifTrue: [
"On Mode"

switch background: (self switchOnColor alpha: 1.0);
childrenDo: [ :i|
i constraintsDo: [ :c |
c frame horizontal alignRight.
c frame vertical alignCenter.
].

].
]
ifFalse: [
"Off Mode"


switch background: (self switchOnColor alpha: 1.0);
childrenDo: [ :i|
i constraintsDo: [ :c |
c frame horizontal alignLeft.
c frame vertical alignCenter.
].

].




].
]
30 changes: 26 additions & 4 deletions CoypuIDE/TbSwitch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Class {
{ #category : 'as yet unclassified' }
TbSwitch class >> Switchexample [
<script>
| container e1 e2 |
| container e1 e2 e3 e4 e5 e6|
container:= BlElement new

geometry: BlRectangleGeometry new;
Expand All @@ -30,14 +30,24 @@ TbSwitch class >> Switchexample [

e1:=TbSwitch new.
e2:= TbSwitch new toggle.
e3:= TbSwitch toggleable.
e4:= TbHorizontalSwitch new.
e5:= TbHorizontalSwitch toggleable.
e6:= TbOnOffSwitch toggleable.



container addChildren: { e1. e2}.
container addChildren: { e1. e2. e3. e4. e5. e6}.
container openInSpace.

]

{ #category : 'as yet unclassified' }
TbSwitch class >> toggleable [
|ele|
ele:= self new.
ele reInitializeEvents.
^ ele.
]

{ #category : 'as yet unclassified' }
TbSwitch >> backColor [
"^ (Color veryVeryDarkGray alpha:1.0)"
Expand Down Expand Up @@ -122,6 +132,16 @@ TbSwitch >> offColor [

]

{ #category : 'evaluating' }
TbSwitch >> reInitializeEvents [

switch addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent | self toggle ]).


]

{ #category : 'initialization' }
TbSwitch >> setValue: req [
self value = req
Expand Down Expand Up @@ -154,6 +174,8 @@ TbSwitch >> switchOffColor [
{ #category : 'as yet unclassified' }
TbSwitch >> switchOnColor [
^ (Color r:166 g:136 b:108 range:255).


]

{ #category : 'initialization' }
Expand Down
Loading

0 comments on commit b67d4d9

Please sign in to comment.