xosd.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ;;; xosd.scm --- Guile-XOSD procedures
  2. ;; Copyright © 2016 Alex Kost <alezost@gmail.com>
  3. ;; This file is part of Guile-XOSD.
  4. ;; Guile-XOSD is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;;
  9. ;; Guile-XOSD is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with Guile-XOSD. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; This module provides more "Schemey" procedures than the ones from
  18. ;; (xosd bindings) module.
  19. ;;; Code:
  20. (define-module (xosd)
  21. #:use-module (xosd bindings)
  22. #:export (make-osd
  23. toggle-osd
  24. display-string-in-osd
  25. display-percentage-in-osd
  26. display-slider-in-osd))
  27. (define-public kill-osd xosd-destroy)
  28. (define-public show-osd xosd-show)
  29. (define-public hide-osd xosd-hide)
  30. (define-public scroll-osd xosd-scroll)
  31. (define-public osd-color xosd-get-colour)
  32. (define-public osd-number-of-lines xosd-get-number-lines)
  33. (define-public osd-on-screen? xosd-onscreen?)
  34. (define-public osd-displayed? xosd-onscreen?)
  35. (define-public set-osd-align! xosd-set-align!)
  36. (define-public set-osd-position! xosd-set-pos!)
  37. (define-public set-osd-bar-length! xosd-set-bar-length!)
  38. (define-public set-osd-timeout! xosd-set-timeout!)
  39. (define-public set-osd-color! xosd-set-colour!)
  40. (define-public set-osd-font! xosd-set-font!)
  41. (define-public set-osd-horizontal-offset! xosd-set-horizontal-offset!)
  42. (define-public set-osd-vertical-offset! xosd-set-vertical-offset!)
  43. (define-public set-osd-outline-offset! xosd-set-outline-offset!)
  44. (define-public set-osd-shadow-offset! xosd-set-shadow-offset!)
  45. (define-public set-osd-outline-color! xosd-set-outline-colour!)
  46. (define-public set-osd-shadow-color! xosd-set-shadow-colour!)
  47. (define-public wait-while-osd-displayed xosd-wait-until-no-display)
  48. (define-public wait-while-osd-on-screen xosd-wait-until-no-display)
  49. (define* (make-osd #:key (lines 1) align position
  50. bar-length timeout color font
  51. horizontal-offset vertical-offset
  52. outline-offset shadow-offset
  53. outline-color shadow-color)
  54. "Create and return a new OSD object with the specified parameters.
  55. LINES is the number of lines that the OSD object can display.
  56. See 'set-osd-...' procedures for the meaning of the other arguments."
  57. (let ((osd (xosd-create lines)))
  58. (when align
  59. (set-osd-align! osd align))
  60. (when position
  61. (set-osd-position! osd position))
  62. (when bar-length
  63. (set-osd-bar-length! osd bar-length))
  64. (when timeout
  65. (set-osd-timeout! osd timeout))
  66. (when color
  67. (set-osd-color! osd color))
  68. (when font
  69. (set-osd-font! osd font))
  70. (when horizontal-offset
  71. (set-osd-horizontal-offset! osd horizontal-offset))
  72. (when vertical-offset
  73. (set-osd-vertical-offset! osd vertical-offset))
  74. (when outline-offset
  75. (set-osd-outline-offset! osd outline-offset))
  76. (when shadow-offset
  77. (set-osd-shadow-offset! osd shadow-offset))
  78. (when outline-color
  79. (set-osd-outline-color! osd outline-color))
  80. (when shadow-color
  81. (set-osd-shadow-color! osd shadow-color))
  82. osd))
  83. (define* (display-string-in-osd osd string
  84. #:optional (line-number 0))
  85. "Display STRING in OSD.
  86. See 'xosd-display-string' for details."
  87. (xosd-display-string osd line-number string))
  88. (define* (display-percentage-in-osd osd percentage
  89. #:optional (line-number 0))
  90. "Display PERCENTAGE in OSD.
  91. See 'xosd-display-percentage' for details."
  92. (xosd-display-percentage osd line-number percentage))
  93. (define* (display-slider-in-osd osd percentage
  94. #:optional (line-number 0))
  95. "Display slider PERCENTAGE in OSD.
  96. See 'xosd-display-slider' for details."
  97. (xosd-display-slider osd line-number percentage))
  98. (define (toggle-osd osd)
  99. "Hide/show OSD."
  100. (if (osd-displayed? osd)
  101. (hide-osd osd)
  102. (show-osd osd)))
  103. ;;; xosd.scm ends here