mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Center RegistersWidget painting.
This commit is contained in:
parent
56c3167156
commit
ee3a77f32c
@ -73,15 +73,16 @@ void RegistersWidget::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegistersWidget::paint(Painter& painter) {
|
void RegistersWidget::paint(Painter& painter) {
|
||||||
draw_legend(painter);
|
const Coord left = (size().w - config.row_width()) / 2;
|
||||||
|
|
||||||
draw_values(painter);
|
draw_legend(left, painter);
|
||||||
|
draw_values(left, painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegistersWidget::draw_legend(Painter& painter) {
|
void RegistersWidget::draw_legend(const Coord left, Painter& painter) {
|
||||||
for(size_t i=0; i<config.registers_count; i+=config.registers_per_row) {
|
for(size_t i=0; i<config.registers_count; i+=config.registers_per_row) {
|
||||||
const Point offset {
|
const Point offset {
|
||||||
0, static_cast<Coord>((i / config.registers_per_row) * row_height)
|
left, static_cast<Coord>((i / config.registers_per_row) * row_height)
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto text = to_string_hex(i, config.legend_length);
|
const auto text = to_string_hex(i, config.legend_length);
|
||||||
@ -94,11 +95,12 @@ void RegistersWidget::draw_legend(Painter& painter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegistersWidget::draw_values(
|
void RegistersWidget::draw_values(
|
||||||
|
const Coord left,
|
||||||
Painter& painter
|
Painter& painter
|
||||||
) {
|
) {
|
||||||
for(size_t i=0; i<config.registers_count; i++) {
|
for(size_t i=0; i<config.registers_count; i++) {
|
||||||
const Point offset = {
|
const Point offset = {
|
||||||
static_cast<Coord>(config.legend_width() + 8 + (i % config.registers_per_row) * (config.value_width() + 8)),
|
static_cast<Coord>(left + config.legend_width() + 8 + (i % config.registers_per_row) * (config.value_width() + 8)),
|
||||||
static_cast<Coord>((i / config.registers_per_row) * row_height)
|
static_cast<Coord>((i / config.registers_per_row) * row_height)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +104,10 @@ struct RegistersWidgetConfig {
|
|||||||
return registers_row_length() * 8;
|
return registers_row_length() * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Dim row_width() const {
|
||||||
|
return legend_width() + 8 + registers_row_width();
|
||||||
|
}
|
||||||
|
|
||||||
constexpr size_t rows() const {
|
constexpr size_t rows() const {
|
||||||
return registers_count / registers_per_row;
|
return registers_count / registers_per_row;
|
||||||
}
|
}
|
||||||
@ -126,8 +130,8 @@ private:
|
|||||||
|
|
||||||
static constexpr Dim row_height = 16;
|
static constexpr Dim row_height = 16;
|
||||||
|
|
||||||
void draw_legend(Painter& painter);
|
void draw_legend(const Coord left, Painter& painter);
|
||||||
void draw_values(Painter& painter);
|
void draw_values(const Coord left, Painter& painter);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RegistersView : public View {
|
class RegistersView : public View {
|
||||||
|
Loading…
Reference in New Issue
Block a user