very basic listbox code request for comments

Timmy Douglas timmy+slate at cc.gatech.edu
Sat May 13 21:46:51 PDT 2006


"Brian T. Rice" <water at tunes.org> writes:

> On Sun, April 23, 2006 1:18 pm, Timmy Douglas said:
>> "Brian T. Rice" <water at tunes.org> writes:
>>> Otherwise it looks like a decent start. Feel free to experiment with
>>> idioms for new nouns and verbs until the code feels more natural.
>>
>> One thing that would probably be nice to have before going further
>> on making the components is like a 'theme settings' type object
>> where I could get the appropriate font/colors to use everywhere.
>
> I agree. XML-type styles or CSS and so forth strike me as ideas that
> should carry over into non-web UI architecture, and I consider this
> sort of thing a worthwhile addition to Slate's UI layer.

Well, I'm back from my break before the summer semester starts and I
decided to play around with having a central repository for
color/etc. See what you think... It doesn't really have any XML or CSS
ideas in it now though.


-------------- next part --------------
diff -rN -u old-main/demo/ui.slate new-main/demo/ui.slate
--- old-main/demo/ui.slate	2006-05-14 00:44:50.312701608 -0400
+++ new-main/demo/ui.slate	2006-05-14 00:44:50.871616640 -0400
@@ -35,6 +35,18 @@
     v
 ].
 
+
+
+lobby addSlot: #numberList valued: (ListboxElement newTarget: Nil getList: #getList getSelection: #getSelection setSelection: #setSelection:).
+
+lobby addSlot: #numberListSelected valued: 0. 
+
+lb at numberList getList [ {1. 2. 3. 4. 5. 6. 7} ].
+lb at numberList getSelection [ lobby numberListSelected ].
+lb at numberList setSelection: value@(Integer traits) [ lobby numberListSelected: value ].
+
+
+
 (lobby addSlotAndReturnValue: #mainWindow valued: (WindowSceneElement newWidth: 640 height: 480)) `>> [
     parents: {
         WindowSceneElement.
@@ -47,6 +59,13 @@
     bold: True.
     textColor: Colors Red.
     addAll: {
+        numberList `>> [
+            parents: childParents.
+            position: (400, 50).
+            extent: (200, 200).
+            backgroundColor: Colors Grey.
+            bold: True.
+        ].
         (addSlotAndReturnValue: #container1 valued: SceneElement new) `>> [
             parents: containerParents ; {HBox}.
             position: (50, 50).
diff -rN -u old-main/src/ui/graphics.slate new-main/src/ui/graphics.slate
--- old-main/src/ui/graphics.slate	2006-05-14 00:44:50.188720456 -0400
+++ new-main/src/ui/graphics.slate	2006-05-14 00:44:50.714640504 -0400
@@ -21,6 +21,11 @@
 
 SceneElement addImmutableSlot: #needToAllocateSpace valued: False.
 
+se@(SceneElement traits) updateThemeTo: newTheme@(ThemeElement traits)
+[
+   se children do: [| :child |  child updateThemeTo: newTheme]
+].
+
 se1@(SceneElement traits) = se2@(SceneElement traits)
 [
     se1 == se2
@@ -589,12 +594,10 @@
         ifFalse: [resend]
 ].
 
-Graphics define: #Handle &parents: {SceneElement. Drag} &slots: {
+Graphics define: #Handle &parents: {SceneElement. BorderedThemeElement. Drag} &slots: {
     #solidColor -> Colors White. 
     #solidAlpha -> 1.
     #borderWidth -> 2.
-    #borderColor -> Colors Black.
-    #borderAlpha -> 1.
     #width -> 10.
     #height -> 10.
     #target.
@@ -749,9 +752,7 @@
     resend
 ].
 
-Graphics define: #PaintSolidBackground &parents: {SceneElement} &slots: {
-    #backgroundColor -> Colors White.
-    #backgroundAlpha -> 1}.
+Graphics define: #PaintSolidBackground &parents: {BackgroundThemeElement. SceneElement}.
 
 se@(PaintSolidBackground traits) handle: event@(PaintEvent traits)
 [
@@ -778,18 +779,12 @@
     resend
 ].
 
-define: #Text &parents: {SceneElement}.
+Graphics define: #Text &parents: {TextThemeElement. SceneElement}.
 
 Text addImmutableSlot: #text valued: ''.
-Text addImmutableSlot: #font valued: 'Courier'.
-Text addImmutableSlot: #italic valued: False.
-Text addImmutableSlot: #bold valued: False.
-Text addImmutableSlot: #fontSize valued: 12.
-Text addImmutableSlot: #textColor valued: Colors Black.
-Text addImmutableSlot: #textAlpha valued: 1.0.
 Text addImmutableSlot: #textOffset valued: 0 , 0.
 
-{#text. #font. #italic. #bold. #fontSize. #textColor. #textAlpha. #textOffset} do: [|:slotName|
+{#text. #textOffset} do: [|:slotName|
     [|:se :v| 
         se atSlotNamed: slotName put: v.
         se repaintSoon.
@@ -798,7 +793,7 @@
 se@(Text traits) cleanup
 [
     resend.
-    {#text. #font. #italic. #bold. #fontSize. #textColor. #textAlpha. #textOffset} do: [|:slotName|
+    {#text. #textOffset} do: [|:slotName|
         se removeMutator: slotName].
 ].
 
diff -rN -u old-main/src/ui/README new-main/src/ui/README
--- old-main/src/ui/README	2006-05-14 00:44:50.207717568 -0400
+++ new-main/src/ui/README	2006-05-14 00:44:50.741636400 -0400
@@ -95,13 +95,15 @@
 load: 'src/ui/form.slate'. 
 load: 'src/lib/print.slate'.
 load: 'src/ui/spacerequirement.slate'. 
+load: 'src/ui/theme.slate'. 
 prototypes Graphics.
 load: 'src/ui/layout.slate'. 
 load: 'src/ui/frame.slate'.
 load: 'src/ui/inspector.slate'.
 load: 'src/ui/contextsceneelement.slate'. 
+load: 'src/ui/listbox.slate'. 
 
-You probably want to save your image at this point.
+"You probably want to save your image at this point."
 
 load: 'src/plugins/sdl-windows/windows.slate'. 
 load: 'src/plugins/cairo/cairo.slate'. 

-------------- next part --------------




" a location for storing visual/audio/size/color/text/etc properties "

Graphics define: #ThemeElement &parents: {Cloneable}.


Graphics define: #ForegroundThemeElement &parents: {ThemeElement} &slots:
    {#foregroundColor -> Colors Black.
     #foregroundAlpha -> 1.0.}.

Graphics define: #BackgroundThemeElement &parents: {ThemeElement} &slots:
    {#backgroundColor -> Colors White.
     #backgroundAlpha -> 1.0.}.


Graphics define: #BorderedThemeElement &parents: {ThemeElement} &slots:
    {#borderColor -> Colors Black.
     #borderAlpha -> 1.0.}.

Graphics define: #SelectionThemeElement &parents: {ThemeElement} &slots:
    {#selectionColor -> Colors Black.
     #selectionAlpha -> 1.0.}.


Graphics define: #TextThemeElement &parents: {ThemeElement} &slots:
{ #font -> 'Courier'.
  #bold -> False.
  #italic -> False.
  #underline -> False.
  #strikethrough -> False.
  #fontSize -> 12.
  #textColor -> Colors Black.
  #textAlpha -> 1.0. }.




se@(TextThemeElement traits) updateThemeTo: se2@(TextThemeElement traits)
[
    "what's a good way to just copy all the slots over?
     or should I do it another way?"
    resend.
].


More information about the Slate mailing list