Changeset 49
- Timestamp:
- 04/23/07 23:22:26 (1 year ago)
- Files:
-
- trunk/luigi/gui.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/gui.d
r48 r49 1970 1970 1971 1971 int checked_item(int v) { 1972 writefln("checked item(%d), cur = %d", v, m_checkedItem); 1972 1973 if (v == m_checkedItem) { return m_checkedItem; } 1973 1974 m_checkedItem = v; … … 1988 1989 } 1989 1990 1991 private class _ButtonUpdater { 1992 int id; 1993 Button button; 1994 void update(int v) { 1995 if (id == v) { button.value=1; } 1996 else { button.value=0; } 1997 } 1998 } 1999 1990 2000 /** Have button b join this group, using value val */ 1991 2001 void add(Button b, int val) { 1992 m_obj2id[b] = val;2002 // We observe the button's value 1993 2003 b.value_changed.connect( &_member_value_changed ); 2004 // The button value should also observe us 2005 auto bup = new _ButtonUpdater; 2006 bup.id = val; 2007 bup.button = b; 2008 m_obj2id[b] = bup; 2009 selection_changed ~= &bup.update; 1994 2010 // Leave this up to the user? 1995 2011 b.is_toggle = true; … … 2053 2069 Button[] opIndex(int v) { 2054 2070 Button [] ret; 2055 foreach(Button b, intval; m_obj2id) {2056 if (v==val ) ret ~= b;2071 foreach(Button b, _ButtonUpdater val; m_obj2id) { 2072 if (v==val.id) ret ~= b; 2057 2073 } 2058 2074 return ret; … … 2063 2079 */ 2064 2080 int opIndex(Button b) { 2065 int*p = (b in m_obj2id);2066 if (p) return *p;2081 _ButtonUpdater *p = (b in m_obj2id); 2082 if (p) return p.id; 2067 2083 return int.min; 2068 2084 } … … 2074 2090 int minv = int.max; 2075 2091 foreach(v; m_obj2id.values) { 2076 if (v < minv) minv = v;2092 if (v.id < minv) minv = v.id; 2077 2093 } 2078 2094 return minv; … … 2083 2099 int maxv = int.min; 2084 2100 foreach(v; m_obj2id.values) { 2085 if (v > maxv) maxv = v;2101 if (v.id > maxv) maxv = v.id; 2086 2102 } 2087 2103 return maxv; … … 2126 2142 private: 2127 2143 int m_checkedItem = int.min; 2128 int[Button] m_obj2id;2144 _ButtonUpdater[Button] m_obj2id; 2129 2145 } 2130 2146
