Browse Source

made the widgets a tad more modular and easier to implement. I'm sure there's way too much overhead now, but well, that can be optimized later

added shortcut overrides to loading and saving world files. You can of course use each widget multiple times, different shortcuts are important :)
Progress bar now respects the sizegrips width
master
Christian Voigt 1 year ago
parent
commit
957b9a1239
  1. 57
      main.py

57
main.py

@ -7,10 +7,9 @@ from PyQt5.QtGui import QCursor @@ -7,10 +7,9 @@ from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import (
QMainWindow, QApplication, QWidget,
QHBoxLayout, QVBoxLayout,
QProgressBar, QToolBar, QLabel, QPushButton
QProgressBar, QToolBar, QPushButton, QSizeGrip
)
# from formatter import Formatter
from cursors import ChraniCursors
from cursors import MouseCursorHelper
from world_regions_widget import WorldRegionsWidget
@ -65,59 +64,45 @@ class ChraniMapTools(QMainWindow, ChraniCursors): @@ -65,59 +64,45 @@ class ChraniMapTools(QMainWindow, ChraniCursors):
self.mouse_cursor_helper.center_label_signal.connect(self.center_label_slot)
def init_ui(self):
toolbar = QToolBar()
label = QPushButton("world viewer")
toolbar.addWidget(label)
label = QPushButton("noise generator")
toolbar.addWidget(label)
application_focus_switcher = toolbar
# toolbar = QToolBar()
# label = QPushButton("world viewer")
# toolbar.addWidget(label)
# label = QPushButton("noise generator")
# toolbar.addWidget(label)
# application_focus_switcher = toolbar
application_frame = QWidget()
application_frame_layout = QVBoxLayout()
application_frame_layout.setContentsMargins(0, 0, 0, 0)
action_pane_width = 256
self.progress_bar_helper.set_maximum_size(QSize(action_pane_width, 12))
widget_frame = QWidget()
widget_frame_layout = QHBoxLayout()
widget_frame_layout.setContentsMargins(0, 0, 0, 0)
effective_progress_bar_width = 256 - QSizeGrip(self).sizeHint().width()
self.progress_bar_helper.set_maximum_size(QSize(effective_progress_bar_width, 12))
self.statusBar().addPermanentWidget(self.progress_bar_helper.progress_bar)
# map viewer
map_viewer_window = QWidget()
map_viewer_window_layout = QHBoxLayout()
map_viewer_window_layout.setContentsMargins(0, 0, 0, 0)
region_view_width = 512
region_view = QWidget()
region_view_layout = QVBoxLayout()
region_view.setStyleSheet("background-color: #cccccc;")
region_view_layout.setContentsMargins(0, 0, 0, 0)
region_view.setLayout(region_view_layout)
region_view.setMinimumSize(QSize(region_view_width, region_view_width))
world_regions_widget = WorldRegionsWidget(
progress_bar_helper=self.progress_bar_helper,
mouse_cursor_helper=self.mouse_cursor_helper
mouse_cursor_helper=self.mouse_cursor_helper,
width=512
)
region_view_layout.addWidget(world_regions_widget)
map_viewer_window_layout.addWidget(region_view)
map_viewer_window.setLayout(map_viewer_window_layout)
# noise_generator
noise_generator_window = QWidget()
noise_generator_window_layout = QHBoxLayout()
noise_generator_window_layout.setContentsMargins(0, 0, 0, 0)
noise_map_widget = NoiseMapWidget(
progress_bar_helper=self.progress_bar_helper,
mouse_cursor_helper=self.mouse_cursor_helper,
width=action_pane_width
width=256
)
noise_generator_window_layout.addWidget(noise_map_widget)
noise_generator_window.setLayout(noise_generator_window_layout)
# init view
application_frame_layout.addWidget(application_focus_switcher)
application_frame_layout.addWidget(map_viewer_window)
# application_frame_layout.addWidget(application_focus_switcher)
widget_frame_layout.addWidget(world_regions_widget)
widget_frame_layout.addWidget(noise_map_widget)
widget_frame.setLayout(widget_frame_layout)
application_frame_layout.addWidget(widget_frame)
application_frame.setLayout(application_frame_layout)
self.setCentralWidget(application_frame)

Loading…
Cancel
Save