Graphics API: Difference between revisions

From OLPC
Jump to navigation Jump to search
Line 24: Line 24:


'''
'''
class WriteActivity(activity.Activity):
class WriteActivity(activity.Activity):
def __init__(self, handle, browser=None):
def __init__(self, handle, browser=None):
activity.Activity.__init__(self, handle)
activity.Activity.__init__(self, handle)
toolbox = activity.ActivityToolbox(self)
toolbox = activity.ActivityToolbox(self)
toolbar = gtk.Toolbar()
toolbar = gtk.Toolbar()
toolbox.add_toolbar(_('Write'), toolbar)
toolbox.add_toolbar(_('Write'), toolbar)
toolbar.show()
toolbar.show()
self.set_toolbox(toolbox)
self.set_toolbox(toolbox)
editor = Editor()
editor = Editor()
self.set_canvas(editor)
self.set_canvas(editor)
editor.show()
editor.show()
'''
'''



Revision as of 12:28, 27 April 2007

Colors

Black
palettes, popups
Toolbar Grey #262626
toolbars, expanded palette
Button Grey #808080
buttons
Selection Grey #A6A6A6
selection, expanded panels
Panel Grey #C0C0C0
panel, desktop
Text field Grey #E5E5E5
text field background
White
pressed states and multiline text areas

States

Default
gtk.STATE_NORMAL
Focused
gtk.STATE_SELECTED
Pressed
gtk.STATE_ACTIVE
Hover
gtk.STATE_PRELIGHT
Inactive
gtk.STATE_INSENSITIVE

Activity

sugar.activity.Activity

The high level activity view, inherits from Window. Example code for a stock activity:

class WriteActivity(activity.Activity):
    def __init__(self, handle, browser=None):
        activity.Activity.__init__(self, handle)

        toolbox = activity.ActivityToolbox(self)

        toolbar = gtk.Toolbar()
        toolbox.add_toolbar(_('Write'), toolbar)
        toolbar.show()

        self.set_toolbox(toolbox)

        editor = Editor()
        self.set_canvas(editor)
        editor.show()

Window

sugar.graphics.window

  • Support canvas, toolbox and panel elements and layout them correctly.

Button

gtk.Button

  • The image should work the same of the image button
  • Need to write a theme to match the visual style
  • Cancel should never be default because you can always activate it with Esc
  • Radius should be 1/2 of the control height
  • Write a list of stock icons people should use and replace them in the theme to match our visual style

Icon

sugar.graphics.Icon

  • Used in canvas-like views so probably an Hippo item.
  • Svg Only.
  • It should support xo colors easily.
  • Rollovers with a focus mark.

Toolbox

sugar.graphics.Toolbox

  • Supports multiple toolbars in tabs

IconButton

sugar.graphics.IconButton

  • Support for SVG and png.
  • Icons should be grey scale. But might be coloured with the XO colors (svg only)
  • Size of the button is 75 pixels, size of the icon canvas is 55 and suggested icon size is around 45.
  • States, defaults:
   Hover : Black
   Pressed : Rounded rectangle 61 pixels, 10 pixels of radius, filled in selection grey
   Focused : Rounded rectangle 61 pixels, 10 pixels of radius, stroked in white 2.25 points
   Inactive. Fallbacks if no inactive icon is specified.
       Svg: Remove the fill and render the stroke in button grey
       Png: just do some effect on the pixbuf, which also work for grey icons
  • You can set an icon for each states which replace the default except for the Hover state of buttons which has rollover.
  • "palette" boolean property. If true show an arrow active immediately on click (but also on hover)

ToolButton

sugar.graphics.ToolButton

  • Support for rollovers
  • Contains IconButton
  • There is no palette but a tooltip.
  • Normal: Button grey rounded filled rectangle
  • Inactive: Button grey rounded stroked rectangle

ToggleIconButton

sugar.graphics.ToggleIconButton

  • Toggled should be like Pressed
  • Inconsistent should be the same of Default (the action depend on the cases)
  • Pressed state and Toggled state is Selection grey

ToolIconButton

sugar.graphics.ToolIconButton

  • Contains a ToggleIconButton

CheckButton

gtk.CheckButton

  • Match the visual design, should be possible with just theme changes

RadioButton

gtk.RadioButton

  • Exactly like CheckButton just a different indicator

OptionMenu

gtk.OptionMenu

  • Match the visual style. Hopefully only theme changes.
  • Add the scroll thing.
  • Groups. Either by a normal separator or a titled separator.
  • Optional support for showing just the icon from the menu (maybe, low priority)
  • Allow fixed sizing of the "button" and ellipsize the label

Entry

gtk.Entry

  • Support for packing icons before and after the entry. Extend gtk.Entry.
  • Activate/Cancel functionality. Two buttons at the end to the entry and key bindings (Esc and Enter). They are visible only when there are changes. The icons appear only when the field is focused and the content is changed since it gained focus. When hitting escape revert and select all the text.

ComboBox

gtk.ComboxBox

  • We miss accept/cancel functionality. Probably patch gtk to allow to replace the entry in the combo box with sugar.Entry.

SearchEntry

sugar.graphics.SearchEntry

  • Use sugar.Entry
  • Search button on the left. Clicking should focus the entry.
  • Cancel button (Esc) on the right, always visible when there is text in the entry. Clicking it will clear the text and focus the textfield.
  • Activate button (Enter) on the right displayed when the content of the text field changed from the last focus or activation.
  • While activating:
   the Activate button becomes a Spinner.
   clicking the close button also cancel the search.
  • When activation is completed:
   The spinner goes away.
   We *don't* clear the entry but we select the text.
  • Search can either be incremental or on activation. For incremental there is no Accept button. start_spinning and stop_spinning to control the spin icon. start would only spin for an amount of time decided by the widget itself (and documented).
  • The suggestions list is provided by the application. Need to figure out which api to use, either model or signal based.
  • Default implementation of suggestions which automatically save the latest searches.

DateSelector

sugar.graphics.DateSelector sugar.graphics.DateComboBox (lower priority)

  • Pluggable calendar implementation to support different kind of calendars (localization).
  • Might reuse gtk.Calendar. We should unify month/year selectors and accellerate the movement gradually.

SpinButton

gtk.SpinButton

  • Make it match the visual design, hopefully just theme changes

ToolItem

gtk.ToolItem or sugar.graphics.ToolItem (the API will be kept very similar)

  • Optional label, either text or icon
  • Used for example to have a label near a SpinButton. Clicking on the label should focus the spin button.

ProgressBar

gtk.ProgressBar

  • Make it match the visual design, hopefully just theme changes.
  • For determinate progress bars should we always pulse to show that there is activity (power consumption? necessary feedback?)
  • Do not use text inside the progress bar

Spinner

sugar.graphics.Spinner

  • pulse() call to keep it running with a timeout
  • stop()

Slider

gtk.Range

  • Property to show the fill in white color, probably default on.
  • Draw the discrete steps.
  • For colored sliders, subclass gtk.Range and add a gradient.

LevelIndicator

sugar.graphics.LevelIndicator

  • Set the number of blocks
  • Set the level as percentage
  • Property for discrete or not
  • We can probably use a GtkAdjustment for most of the above.Rollovers

TextView

gtk.TextView

ScrolledWindow

gtk.ScrolledWindow

  • Theme it to match the visual.

sugar.ScrolledWindow

  • Support for markers. Line as default and optional support for other shapes (star for bookmarks, circles for xos...). Generic way of add marks and keep them updated (observer?)

Expander

gtk.Expander

Separator

gtk.Separator

GroupBox

sugar.GroupBox

  • just a container
  • set_title and set_title_widget (checkbox, radiobutton...)
  • different color and separator under title

TreeView

gtk.TreeView

Notebook

gtk.Notebook

  • Expand to fill the whole space by default but property to turn it off
  • Switching tabs with the little arrows should page

Palette

sugar.graphics.Palette

  • Inmediately on rollover, show the black background.
  • After a very short delay, show the primary state (name of the action and key shortcut).
  • After a bigger delay, show the popup secondary state.
  • Could be animated.
  • Menu Items would go on the top and then the free-form rollover content.
  • The popup would be a gtk.Window that contains a Label, a MenuShell, an hippo.Canvas (or whatever) and finally a button bar (OK/Cancel).
  • The popup will have a setPrimaryState(label, accelerator) method. For action buttons would be a MenuItem, for the others would only be a Label.
  • The primary state should already have the same width as the secondary state and the expandable areas.
  • Primary states appear and disappear automatically (with a short delay). A click outside makes it disappear instantly.
  • Secondary states appear after a delay, or with a single click on the icon.
  • Secondary disappears with the esc key, clicking outside the popup or clicking on a button inside.