Check-in [1e328bcd88]
Overview
SHA1:1e328bcd882f7319618f5ef3e750a4612b0637f4
Date: 2015-09-22 09:14:47
User: spaskalev
Comment:imgui design notes additions
Timelines: family | ancestors | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2015-09-22
09:14
[1e328bcd88] Leaf: imgui design notes additions (user: spaskalev, tags: trunk)
06:54
[4d1ed64397] added design notes for imgui (user: spaskalev, tags: trunk)
Changes

Modified src/0dev.org/imgui/design.txt from [128d0bd137] to [352165b2a4].

     1      1   Design of an immediate graphical user interface api with managed layouts
     2      2   
     3      3   Terms:
     4      4   
     5         -1. Canvas - a drawing area with a managed layout
            5  +1. Canvas - a drawing area
     6      6   
     7      7   User stories
     8      8   
     9      9   1. I would like to call UI-rendering functions without specifying dimensions and locations
           10  +
    10     11   2. I would like to call custom UI-rendering functions while specifying dimensions and locations
    11     12   
           13  +/----------------------------------
    12     14   Story 2 needs a way to get a proper starting location or a bounding box If 1 is in place.
    13     15   
    14     16   Consider the single method Layout interface:
    15     17   
    16     18   type Layout interface {
    17     19   	// Advances the layout and returns a starting point
    18     20   	// for an element based on the last ending point.
    19         -	Next(Point) Point
           21  +	Next(last Point) Point
    20     22   }
    21     23   
    22     24   Story 1 necessitates that library-aware UI-rendering functions acquire their starting locations
    23     25   on their own. This allows for the following two approaches (more are possible of course)
    24     26   
    25     27   * Store the ending point of the last element. New calls can get it and pass it to the layout
    26     28     + does not advance the layout unless required, saving cpu
           29  +  + does not imply a dependency on the layout, the UI drawing needs just a starting point
    27     30   
    28     31   * Store the next starting point by calling Next() at the end of the element drawing routine.
    29     32   The next drawing can continue from it.
    30     33     - advancing the layout costs cpu
    31     34     - the user might want an out of layer render
           35  +  - puts a dependency on the layout
           36  +
           37  +The first strategy is definatelly more sound and neatly allows for a layout-aware tracker
           38  +to handle the locations.
           39  +\----------------------------------
    32     40   
           41  +3. I would like to enhance drawing functions with additional behavior (e.g. layout trackers, styling, etc)

Modified src/0dev.org/imgui/imgui.go from [8340e5f08a] to [6ffb33222b].

     4      4   type Point struct {
     5      5   	X, Y uint16 // might revisit type for bigger resolutions
     6      6   }
     7      7   
     8      8   type Layout interface {
     9      9   	// Advances the layout and returns a starting point
    10     10   	// for an element based on the last ending point.
    11         -	Next(Point) Point
           11  +	Next(last Point) Point
    12     12   }
    13     13   
    14     14   // Groups UI drawing routines
    15     15   type Canvas interface {
    16     16   	Layout
    17     17   	// Draws a string
    18     18   	Label(string)
    19     19   	//Button()
    20     20   	//TextArea()
    21     21   }