UI_testing.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # THIS FILE IS A PART OF VCStudio
  2. # PYTHON 3
  3. # This a console project manager.
  4. import os
  5. # GTK module ( Graphical interface
  6. import gi
  7. gi.require_version('Gtk', '3.0')
  8. from gi.repository import Gtk
  9. import cairo
  10. # Own modules
  11. from settings import settings
  12. from settings import talk
  13. #UI modules
  14. from UI import UI_elements
  15. from UI import UI_color
  16. def layer(win):
  17. # Making the layer
  18. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
  19. win.current['h'])
  20. layer = cairo.Context(surface)
  21. #text setting
  22. layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
  23. # Variables I will need tfor animations
  24. testing_bar = UI_elements.animate("UI_testing_banner", win)
  25. # Testing top banner thingy
  26. if testing_bar > 0.01:
  27. layer.set_source_rgba(1,1,1,0.5)
  28. UI_elements.roundrect(layer, win,
  29. 5,
  30. 5,
  31. (win.current['w']-10)*testing_bar,
  32. 30,
  33. 10)
  34. # testing will be drawn only it's activated
  35. if win.current["testing"]:
  36. #Animating values
  37. testing_bar = UI_elements.animate("UI_testing_banner", win, testing_bar, 1, 10, force=True)
  38. # Current Framerate
  39. UI_color.set(layer, win, "testing_banner")
  40. UI_elements.roundrect(layer, win,
  41. 5,
  42. 5,
  43. 60,
  44. 30,
  45. 10)
  46. UI_color.set(layer, win, "testing_text")
  47. layer.set_font_size(20)
  48. layer.move_to(20,27)
  49. layer.show_text(str(win.FPS))
  50. # Mouse Visualization thingy
  51. for n ,button in enumerate(["LMB", "MMB", "RMB"]):
  52. if win.current[button]:
  53. UI_color.set(layer, win, button)
  54. #line from click to current mouse position
  55. layer.move_to(win.current[button][0],
  56. win.current[button][1])
  57. layer.line_to(win.current["mx"],
  58. win.current["my"])
  59. layer.stroke()
  60. else:
  61. UI_color.set(layer, win, "testing_banner")
  62. UI_elements.roundrect(layer, win,
  63. 75 + (35 * n),
  64. 5,
  65. 30,
  66. 30,
  67. 10)
  68. # Keyboard
  69. UI_color.set(layer, win, "testing_banner")
  70. UI_elements.roundrect(layer, win,
  71. 185,
  72. 5,
  73. 30,
  74. 30,
  75. 10)
  76. UI_color.set(layer, win, "testing_text")
  77. layer.set_font_size(20)
  78. layer.move_to(195,27)
  79. layer.show_text(win.current["key_letter"])
  80. for n, key in enumerate(win.current["keys"]):
  81. UI_color.set(layer, win, "testing_banner")
  82. UI_elements.roundrect(layer, win,
  83. 220 + (80 * n),
  84. 5,
  85. 75,
  86. 30,
  87. 10)
  88. UI_color.set(layer, win, "testing_text")
  89. layer.set_font_size(20)
  90. layer.move_to(225 + (80 * n),27)
  91. layer.show_text(str(key))
  92. else: # if not testing bar
  93. # Animating back to 0
  94. testing_bar = UI_elements.animate("UI_testing_banner", win, testing_bar, 0, 10, force=True)
  95. # Switch to activate testing (or diactivate it). Top, Right corner.
  96. def do():
  97. # Mouse Click
  98. win.current["testing"] = not win.current["testing"]
  99. UI_color.set(layer, win, "testing_banner")
  100. UI_elements.roundrect(layer, win,
  101. win.current['w'] - 35,
  102. 5,
  103. 30,
  104. 30,
  105. 10,
  106. do,
  107. tip=talk.text("UI_testing_tooltip"))
  108. return surface