button_panel.py 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Flexlay - A Generic 2D Game Editor
  2. # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
  3. #
  4. # This program 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. # This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
  16. from typing import TYPE_CHECKING
  17. from flexlay.util.config import Config
  18. if TYPE_CHECKING:
  19. from supertux.gui import SuperTuxGUI
  20. from flexlay.gui_manager import GUIManager
  21. class SuperTuxButtonPanel:
  22. def __init__(self, gui_manager: 'GUIManager', editor: 'SuperTuxGUI') -> None:
  23. # Create Buttonpanel
  24. self.button_panel = gui_manager.create_button_panel(True)
  25. # File Handling
  26. self.button_panel.add_icon("data/images/icons24/stock_new.png", editor.gui_level_new,
  27. hover="New", shortcut="Ctrl+N")
  28. self.button_panel.add_icon("data/images/icons24/stock_open.png", editor.gui_level_load,
  29. hover="Open", shortcut="Ctrl+O")
  30. self.button_panel.add_icon("data/images/icons24/stock_save.png", editor.gui_level_save,
  31. hover="Save", shortcut="Ctrl+S")
  32. self.button_panel.add_icon("data/images/icons24/stock_save_as.png", editor.gui_level_save_as,
  33. hover="Save As")
  34. # Copy&Paste
  35. self.button_panel.add_separator()
  36. self.button_panel.add_icon("data/images/icons24/stock_copy.png", lambda: None, hover="Copy")
  37. self.button_panel.add_icon("data/images/icons24/stock_paste.png", lambda: None, hover="Paste")
  38. # Undo Redo
  39. self.button_panel.add_separator()
  40. self.undo_icon = self.button_panel.add_icon("data/images/icons24/stock_undo.png", editor.undo,
  41. hover="Undo", shortcut="Ctrl+Z")
  42. self.redo_icon = self.button_panel.add_icon("data/images/icons24/stock_redo.png", editor.redo,
  43. hover="Redo", shortcut="Ctrl+Y")
  44. self.undo_icon.disable()
  45. self.redo_icon.disable()
  46. # Visibility Toggles
  47. self.button_panel.add_separator()
  48. self.minimap_icon = self.button_panel.add_icon("data/images/icons24/minimap.png",
  49. editor.gui_toggle_minimap, hover="Minimap")
  50. self.grid_icon = self.button_panel.add_icon("data/images/icons24/grid.png",
  51. editor.gui_toggle_grid, hover="Grid")
  52. # Zoom Buttons
  53. self.button_panel.add_separator()
  54. self.button_panel.add_icon("data/images/icons24/stock_zoom_in.png", editor.gui_zoom_in, hover="Zoom In")
  55. self.button_panel.add_icon("data/images/icons24/stock_zoom_out.png", editor.gui_zoom_out, hover="Zoom Out")
  56. self.button_panel.add_icon("data/images/icons24/stock_zoom_1.png", lambda: editor.gui_set_zoom(1.0),
  57. hover="Zoom 1:1")
  58. self.button_panel.add_icon("data/images/icons24/stock_zoom_fit.png", editor.gui_zoom_fit,
  59. hover="Zoom to Fit")
  60. # Raise/Lower
  61. self.button_panel.add_separator()
  62. self.button_panel.add_icon("data/images/icons24/object_lower_to_bottom.png", editor.lower_selection_to_bottom,
  63. hover="Object to Bottom")
  64. self.button_panel.add_icon("data/images/icons24/object_lower.png", editor.lower_selection,
  65. hover="Lower Object")
  66. self.button_panel.add_icon("data/images/icons24/object_raise.png", editor.raise_selection,
  67. hover="Raise Object")
  68. self.button_panel.add_icon("data/images/icons24/object_raise_to_top.png", editor.raise_selection_to_top,
  69. hover="Object to Top")
  70. self.button_panel.add_separator()
  71. self.run_icon = self.button_panel.add_icon("data/images/icons24/run.png", editor.gui_run_level,
  72. hover="Run Level")
  73. self.button_panel.add_separator()
  74. assert Config.current is not None
  75. self.button_panel.add_icon(Config.current.datadir + "/images/engine/editor/camera.png",
  76. editor.camera_properties,
  77. hover="Camera Properties")
  78. # EOF #