ui: move graphics and color controls to right sidebar
This commit is contained in:
@@ -183,13 +183,30 @@ class MainWindow(QMainWindow):
|
||||
|
||||
center_layout.addLayout(top_bar)
|
||||
|
||||
# Color Shortcuts
|
||||
color_layout = QHBoxLayout()
|
||||
# Middle Layout (Canvas + Right Sidebar)
|
||||
middle_layout = QHBoxLayout()
|
||||
center_layout.addLayout(middle_layout, 1)
|
||||
|
||||
# Canvas
|
||||
self.canvas = TeletextCanvas()
|
||||
self.canvas.cursorChanged.connect(self.on_cursor_changed)
|
||||
middle_layout.addWidget(self.canvas, 1) # Expand
|
||||
|
||||
# Right Sidebar
|
||||
right_sidebar = QWidget()
|
||||
right_sidebar.setFixedWidth(160)
|
||||
right_layout = QVBoxLayout(right_sidebar)
|
||||
right_layout.setContentsMargins(5, 0, 0, 0)
|
||||
middle_layout.addWidget(right_sidebar)
|
||||
|
||||
# Color Shortcuts
|
||||
# Graphics Mode Toggle
|
||||
self.chk_graphics = QCheckBox("Graphics")
|
||||
self.chk_graphics.setToolTip("If checked, inserts Graphics Color codes (e.g. Red Graphics 0x11) instead of Alpha (0x01)")
|
||||
color_layout.addWidget(self.chk_graphics)
|
||||
right_layout.addWidget(self.chk_graphics)
|
||||
|
||||
colors_grid = QGridLayout()
|
||||
colors_grid.setSpacing(5)
|
||||
|
||||
colors = [
|
||||
("Black", 0x00, "#000000"),
|
||||
@@ -202,9 +219,10 @@ class MainWindow(QMainWindow):
|
||||
("White", 0x07, "#FFFFFF"),
|
||||
]
|
||||
|
||||
row, col = 0, 0
|
||||
for name, code, hex_color in colors:
|
||||
btn = QPushButton(name)
|
||||
btn.setFixedSize(60, 30) # Fixed size for uniformity
|
||||
btn.setFixedSize(60, 30)
|
||||
|
||||
# Common style
|
||||
style = f"background-color: {hex_color}; font-weight: bold; border: 1px solid #555; border-radius: 3px;"
|
||||
@@ -220,20 +238,25 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# Use separate method to handle graphics check
|
||||
btn.clicked.connect(lambda checked, c=code: self.insert_color(c))
|
||||
color_layout.addWidget(btn)
|
||||
colors_grid.addWidget(btn, row, col)
|
||||
|
||||
col += 1
|
||||
if col > 1:
|
||||
col = 0
|
||||
row += 1
|
||||
|
||||
right_layout.addLayout(colors_grid)
|
||||
|
||||
# Mosaics Button
|
||||
btn_mosaic = QPushButton("Mosaics...")
|
||||
btn_mosaic.clicked.connect(self.open_mosaic_dialog)
|
||||
color_layout.addWidget(btn_mosaic)
|
||||
right_layout.addWidget(btn_mosaic)
|
||||
|
||||
color_layout.addStretch()
|
||||
center_layout.addLayout(color_layout)
|
||||
right_layout.addSpacing(10)
|
||||
|
||||
# Background Controls
|
||||
bg_layout = QHBoxLayout()
|
||||
bg_label = QLabel("Background:")
|
||||
bg_layout.addWidget(bg_label)
|
||||
right_layout.addWidget(bg_label)
|
||||
|
||||
# New Background (0x1D)
|
||||
btn_new_bg = QPushButton("New BG")
|
||||
@@ -241,7 +264,7 @@ class MainWindow(QMainWindow):
|
||||
btn_new_bg.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
|
||||
btn_new_bg.setToolTip("Sets the current foreground color as the new background color (0x1D)")
|
||||
btn_new_bg.clicked.connect(lambda: self.insert_char(0x1D))
|
||||
bg_layout.addWidget(btn_new_bg)
|
||||
right_layout.addWidget(btn_new_bg)
|
||||
|
||||
# Black Background (0x1C)
|
||||
btn_black_bg = QPushButton("Black BG")
|
||||
@@ -249,15 +272,13 @@ class MainWindow(QMainWindow):
|
||||
btn_black_bg.setStyleSheet("background-color: black; color: white; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
|
||||
btn_black_bg.setToolTip("Resets the background color to Black (0x1C)")
|
||||
btn_black_bg.clicked.connect(lambda: self.insert_char(0x1C))
|
||||
bg_layout.addWidget(btn_black_bg)
|
||||
right_layout.addWidget(btn_black_bg)
|
||||
|
||||
bg_layout.addStretch()
|
||||
center_layout.addLayout(bg_layout)
|
||||
right_layout.addSpacing(10)
|
||||
|
||||
# Graphics Control
|
||||
gfx_ctrl_layout = QHBoxLayout()
|
||||
gfx_ctrl_label = QLabel("Graphics Control:")
|
||||
gfx_ctrl_layout.addWidget(gfx_ctrl_label)
|
||||
right_layout.addWidget(gfx_ctrl_label)
|
||||
|
||||
# Hold Graphics (0x1E)
|
||||
btn_hold = QPushButton("Hold Gfx")
|
||||
@@ -265,7 +286,7 @@ class MainWindow(QMainWindow):
|
||||
btn_hold.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
|
||||
btn_hold.setToolTip("Hold Graphics (0x1E): Displays the last graphic char in place of subsequent control codes.")
|
||||
btn_hold.clicked.connect(lambda: self.insert_char(0x1E))
|
||||
gfx_ctrl_layout.addWidget(btn_hold)
|
||||
right_layout.addWidget(btn_hold)
|
||||
|
||||
# Release Graphics (0x1F)
|
||||
btn_release = QPushButton("Release Gfx")
|
||||
@@ -273,15 +294,9 @@ class MainWindow(QMainWindow):
|
||||
btn_release.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
|
||||
btn_release.setToolTip("Release Graphics (0x1F): Ends the 'Hold Graphics' effect.")
|
||||
btn_release.clicked.connect(lambda: self.insert_char(0x1F))
|
||||
gfx_ctrl_layout.addWidget(btn_release)
|
||||
right_layout.addWidget(btn_release)
|
||||
|
||||
gfx_ctrl_layout.addStretch()
|
||||
center_layout.addLayout(gfx_ctrl_layout)
|
||||
|
||||
# Canvas
|
||||
self.canvas = TeletextCanvas()
|
||||
self.canvas.cursorChanged.connect(self.on_cursor_changed)
|
||||
center_layout.addWidget(self.canvas, 1) # Expand
|
||||
right_layout.addStretch()
|
||||
|
||||
self.layout.addLayout(center_layout, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user