binditems.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. // auto-generated
  2. // **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //
  3. package binding
  4. import (
  5. "bytes"
  6. "fyne.io/fyne/v2"
  7. )
  8. // Bool supports binding a bool value.
  9. //
  10. // Since: 2.0
  11. type Bool interface {
  12. DataItem
  13. Get() (bool, error)
  14. Set(bool) error
  15. }
  16. // ExternalBool supports binding a bool value to an external value.
  17. //
  18. // Since: 2.0
  19. type ExternalBool interface {
  20. Bool
  21. Reload() error
  22. }
  23. // NewBool returns a bindable bool value that is managed internally.
  24. //
  25. // Since: 2.0
  26. func NewBool() Bool {
  27. var blank bool = false
  28. return &boundBool{val: &blank}
  29. }
  30. // BindBool returns a new bindable value that controls the contents of the provided bool variable.
  31. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  32. //
  33. // Since: 2.0
  34. func BindBool(v *bool) ExternalBool {
  35. if v == nil {
  36. var blank bool = false
  37. v = &blank // never allow a nil value pointer
  38. }
  39. b := &boundExternalBool{}
  40. b.val = v
  41. b.old = *v
  42. return b
  43. }
  44. type boundBool struct {
  45. base
  46. val *bool
  47. }
  48. func (b *boundBool) Get() (bool, error) {
  49. b.lock.RLock()
  50. defer b.lock.RUnlock()
  51. if b.val == nil {
  52. return false, nil
  53. }
  54. return *b.val, nil
  55. }
  56. func (b *boundBool) Set(val bool) error {
  57. b.lock.Lock()
  58. defer b.lock.Unlock()
  59. if *b.val == val {
  60. return nil
  61. }
  62. *b.val = val
  63. b.trigger()
  64. return nil
  65. }
  66. type boundExternalBool struct {
  67. boundBool
  68. old bool
  69. }
  70. func (b *boundExternalBool) Set(val bool) error {
  71. b.lock.Lock()
  72. defer b.lock.Unlock()
  73. if b.old == val {
  74. return nil
  75. }
  76. *b.val = val
  77. b.old = val
  78. b.trigger()
  79. return nil
  80. }
  81. func (b *boundExternalBool) Reload() error {
  82. return b.Set(*b.val)
  83. }
  84. // Bytes supports binding a []byte value.
  85. //
  86. // Since: 2.2
  87. type Bytes interface {
  88. DataItem
  89. Get() ([]byte, error)
  90. Set([]byte) error
  91. }
  92. // ExternalBytes supports binding a []byte value to an external value.
  93. //
  94. // Since: 2.2
  95. type ExternalBytes interface {
  96. Bytes
  97. Reload() error
  98. }
  99. // NewBytes returns a bindable []byte value that is managed internally.
  100. //
  101. // Since: 2.2
  102. func NewBytes() Bytes {
  103. var blank []byte = nil
  104. return &boundBytes{val: &blank}
  105. }
  106. // BindBytes returns a new bindable value that controls the contents of the provided []byte variable.
  107. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  108. //
  109. // Since: 2.2
  110. func BindBytes(v *[]byte) ExternalBytes {
  111. if v == nil {
  112. var blank []byte = nil
  113. v = &blank // never allow a nil value pointer
  114. }
  115. b := &boundExternalBytes{}
  116. b.val = v
  117. b.old = *v
  118. return b
  119. }
  120. type boundBytes struct {
  121. base
  122. val *[]byte
  123. }
  124. func (b *boundBytes) Get() ([]byte, error) {
  125. b.lock.RLock()
  126. defer b.lock.RUnlock()
  127. if b.val == nil {
  128. return nil, nil
  129. }
  130. return *b.val, nil
  131. }
  132. func (b *boundBytes) Set(val []byte) error {
  133. b.lock.Lock()
  134. defer b.lock.Unlock()
  135. if bytes.Equal(*b.val, val) {
  136. return nil
  137. }
  138. *b.val = val
  139. b.trigger()
  140. return nil
  141. }
  142. type boundExternalBytes struct {
  143. boundBytes
  144. old []byte
  145. }
  146. func (b *boundExternalBytes) Set(val []byte) error {
  147. b.lock.Lock()
  148. defer b.lock.Unlock()
  149. if bytes.Equal(b.old, val) {
  150. return nil
  151. }
  152. *b.val = val
  153. b.old = val
  154. b.trigger()
  155. return nil
  156. }
  157. func (b *boundExternalBytes) Reload() error {
  158. return b.Set(*b.val)
  159. }
  160. // Float supports binding a float64 value.
  161. //
  162. // Since: 2.0
  163. type Float interface {
  164. DataItem
  165. Get() (float64, error)
  166. Set(float64) error
  167. }
  168. // ExternalFloat supports binding a float64 value to an external value.
  169. //
  170. // Since: 2.0
  171. type ExternalFloat interface {
  172. Float
  173. Reload() error
  174. }
  175. // NewFloat returns a bindable float64 value that is managed internally.
  176. //
  177. // Since: 2.0
  178. func NewFloat() Float {
  179. var blank float64 = 0.0
  180. return &boundFloat{val: &blank}
  181. }
  182. // BindFloat returns a new bindable value that controls the contents of the provided float64 variable.
  183. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  184. //
  185. // Since: 2.0
  186. func BindFloat(v *float64) ExternalFloat {
  187. if v == nil {
  188. var blank float64 = 0.0
  189. v = &blank // never allow a nil value pointer
  190. }
  191. b := &boundExternalFloat{}
  192. b.val = v
  193. b.old = *v
  194. return b
  195. }
  196. type boundFloat struct {
  197. base
  198. val *float64
  199. }
  200. func (b *boundFloat) Get() (float64, error) {
  201. b.lock.RLock()
  202. defer b.lock.RUnlock()
  203. if b.val == nil {
  204. return 0.0, nil
  205. }
  206. return *b.val, nil
  207. }
  208. func (b *boundFloat) Set(val float64) error {
  209. b.lock.Lock()
  210. defer b.lock.Unlock()
  211. if *b.val == val {
  212. return nil
  213. }
  214. *b.val = val
  215. b.trigger()
  216. return nil
  217. }
  218. type boundExternalFloat struct {
  219. boundFloat
  220. old float64
  221. }
  222. func (b *boundExternalFloat) Set(val float64) error {
  223. b.lock.Lock()
  224. defer b.lock.Unlock()
  225. if b.old == val {
  226. return nil
  227. }
  228. *b.val = val
  229. b.old = val
  230. b.trigger()
  231. return nil
  232. }
  233. func (b *boundExternalFloat) Reload() error {
  234. return b.Set(*b.val)
  235. }
  236. // Int supports binding a int value.
  237. //
  238. // Since: 2.0
  239. type Int interface {
  240. DataItem
  241. Get() (int, error)
  242. Set(int) error
  243. }
  244. // ExternalInt supports binding a int value to an external value.
  245. //
  246. // Since: 2.0
  247. type ExternalInt interface {
  248. Int
  249. Reload() error
  250. }
  251. // NewInt returns a bindable int value that is managed internally.
  252. //
  253. // Since: 2.0
  254. func NewInt() Int {
  255. var blank int = 0
  256. return &boundInt{val: &blank}
  257. }
  258. // BindInt returns a new bindable value that controls the contents of the provided int variable.
  259. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  260. //
  261. // Since: 2.0
  262. func BindInt(v *int) ExternalInt {
  263. if v == nil {
  264. var blank int = 0
  265. v = &blank // never allow a nil value pointer
  266. }
  267. b := &boundExternalInt{}
  268. b.val = v
  269. b.old = *v
  270. return b
  271. }
  272. type boundInt struct {
  273. base
  274. val *int
  275. }
  276. func (b *boundInt) Get() (int, error) {
  277. b.lock.RLock()
  278. defer b.lock.RUnlock()
  279. if b.val == nil {
  280. return 0, nil
  281. }
  282. return *b.val, nil
  283. }
  284. func (b *boundInt) Set(val int) error {
  285. b.lock.Lock()
  286. defer b.lock.Unlock()
  287. if *b.val == val {
  288. return nil
  289. }
  290. *b.val = val
  291. b.trigger()
  292. return nil
  293. }
  294. type boundExternalInt struct {
  295. boundInt
  296. old int
  297. }
  298. func (b *boundExternalInt) Set(val int) error {
  299. b.lock.Lock()
  300. defer b.lock.Unlock()
  301. if b.old == val {
  302. return nil
  303. }
  304. *b.val = val
  305. b.old = val
  306. b.trigger()
  307. return nil
  308. }
  309. func (b *boundExternalInt) Reload() error {
  310. return b.Set(*b.val)
  311. }
  312. // Rune supports binding a rune value.
  313. //
  314. // Since: 2.0
  315. type Rune interface {
  316. DataItem
  317. Get() (rune, error)
  318. Set(rune) error
  319. }
  320. // ExternalRune supports binding a rune value to an external value.
  321. //
  322. // Since: 2.0
  323. type ExternalRune interface {
  324. Rune
  325. Reload() error
  326. }
  327. // NewRune returns a bindable rune value that is managed internally.
  328. //
  329. // Since: 2.0
  330. func NewRune() Rune {
  331. var blank rune = rune(0)
  332. return &boundRune{val: &blank}
  333. }
  334. // BindRune returns a new bindable value that controls the contents of the provided rune variable.
  335. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  336. //
  337. // Since: 2.0
  338. func BindRune(v *rune) ExternalRune {
  339. if v == nil {
  340. var blank rune = rune(0)
  341. v = &blank // never allow a nil value pointer
  342. }
  343. b := &boundExternalRune{}
  344. b.val = v
  345. b.old = *v
  346. return b
  347. }
  348. type boundRune struct {
  349. base
  350. val *rune
  351. }
  352. func (b *boundRune) Get() (rune, error) {
  353. b.lock.RLock()
  354. defer b.lock.RUnlock()
  355. if b.val == nil {
  356. return rune(0), nil
  357. }
  358. return *b.val, nil
  359. }
  360. func (b *boundRune) Set(val rune) error {
  361. b.lock.Lock()
  362. defer b.lock.Unlock()
  363. if *b.val == val {
  364. return nil
  365. }
  366. *b.val = val
  367. b.trigger()
  368. return nil
  369. }
  370. type boundExternalRune struct {
  371. boundRune
  372. old rune
  373. }
  374. func (b *boundExternalRune) Set(val rune) error {
  375. b.lock.Lock()
  376. defer b.lock.Unlock()
  377. if b.old == val {
  378. return nil
  379. }
  380. *b.val = val
  381. b.old = val
  382. b.trigger()
  383. return nil
  384. }
  385. func (b *boundExternalRune) Reload() error {
  386. return b.Set(*b.val)
  387. }
  388. // String supports binding a string value.
  389. //
  390. // Since: 2.0
  391. type String interface {
  392. DataItem
  393. Get() (string, error)
  394. Set(string) error
  395. }
  396. // ExternalString supports binding a string value to an external value.
  397. //
  398. // Since: 2.0
  399. type ExternalString interface {
  400. String
  401. Reload() error
  402. }
  403. // NewString returns a bindable string value that is managed internally.
  404. //
  405. // Since: 2.0
  406. func NewString() String {
  407. var blank string = ""
  408. return &boundString{val: &blank}
  409. }
  410. // BindString returns a new bindable value that controls the contents of the provided string variable.
  411. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  412. //
  413. // Since: 2.0
  414. func BindString(v *string) ExternalString {
  415. if v == nil {
  416. var blank string = ""
  417. v = &blank // never allow a nil value pointer
  418. }
  419. b := &boundExternalString{}
  420. b.val = v
  421. b.old = *v
  422. return b
  423. }
  424. type boundString struct {
  425. base
  426. val *string
  427. }
  428. func (b *boundString) Get() (string, error) {
  429. b.lock.RLock()
  430. defer b.lock.RUnlock()
  431. if b.val == nil {
  432. return "", nil
  433. }
  434. return *b.val, nil
  435. }
  436. func (b *boundString) Set(val string) error {
  437. b.lock.Lock()
  438. defer b.lock.Unlock()
  439. if *b.val == val {
  440. return nil
  441. }
  442. *b.val = val
  443. b.trigger()
  444. return nil
  445. }
  446. type boundExternalString struct {
  447. boundString
  448. old string
  449. }
  450. func (b *boundExternalString) Set(val string) error {
  451. b.lock.Lock()
  452. defer b.lock.Unlock()
  453. if b.old == val {
  454. return nil
  455. }
  456. *b.val = val
  457. b.old = val
  458. b.trigger()
  459. return nil
  460. }
  461. func (b *boundExternalString) Reload() error {
  462. return b.Set(*b.val)
  463. }
  464. // URI supports binding a fyne.URI value.
  465. //
  466. // Since: 2.1
  467. type URI interface {
  468. DataItem
  469. Get() (fyne.URI, error)
  470. Set(fyne.URI) error
  471. }
  472. // ExternalURI supports binding a fyne.URI value to an external value.
  473. //
  474. // Since: 2.1
  475. type ExternalURI interface {
  476. URI
  477. Reload() error
  478. }
  479. // NewURI returns a bindable fyne.URI value that is managed internally.
  480. //
  481. // Since: 2.1
  482. func NewURI() URI {
  483. var blank fyne.URI = fyne.URI(nil)
  484. return &boundURI{val: &blank}
  485. }
  486. // BindURI returns a new bindable value that controls the contents of the provided fyne.URI variable.
  487. // If your code changes the content of the variable this refers to you should call Reload() to inform the bindings.
  488. //
  489. // Since: 2.1
  490. func BindURI(v *fyne.URI) ExternalURI {
  491. if v == nil {
  492. var blank fyne.URI = fyne.URI(nil)
  493. v = &blank // never allow a nil value pointer
  494. }
  495. b := &boundExternalURI{}
  496. b.val = v
  497. b.old = *v
  498. return b
  499. }
  500. type boundURI struct {
  501. base
  502. val *fyne.URI
  503. }
  504. func (b *boundURI) Get() (fyne.URI, error) {
  505. b.lock.RLock()
  506. defer b.lock.RUnlock()
  507. if b.val == nil {
  508. return fyne.URI(nil), nil
  509. }
  510. return *b.val, nil
  511. }
  512. func (b *boundURI) Set(val fyne.URI) error {
  513. b.lock.Lock()
  514. defer b.lock.Unlock()
  515. if compareURI(*b.val, val) {
  516. return nil
  517. }
  518. *b.val = val
  519. b.trigger()
  520. return nil
  521. }
  522. type boundExternalURI struct {
  523. boundURI
  524. old fyne.URI
  525. }
  526. func (b *boundExternalURI) Set(val fyne.URI) error {
  527. b.lock.Lock()
  528. defer b.lock.Unlock()
  529. if compareURI(b.old, val) {
  530. return nil
  531. }
  532. *b.val = val
  533. b.old = val
  534. b.trigger()
  535. return nil
  536. }
  537. func (b *boundExternalURI) Reload() error {
  538. return b.Set(*b.val)
  539. }