ArdourButton: add option to expand buttons to be square
This commit is contained in:
parent
0254e7e6b0
commit
2066f7018d
@ -763,7 +763,10 @@ ArdourButton::on_size_request (Gtk::Requisition* req)
|
||||
req->width = wh;
|
||||
req->height = wh;
|
||||
}
|
||||
else if (_tweaks & Square) {
|
||||
else if (_tweaks & (Square | ExpandtoSquare)) {
|
||||
if (_squaresize.has_value ()) {
|
||||
req->width = std::max (req->width, _squaresize.value ());
|
||||
}
|
||||
// currerntly unused (again)
|
||||
if (req->width < req->height)
|
||||
req->width = req->height;
|
||||
@ -1074,6 +1077,15 @@ ArdourButton::on_size_allocate (Allocation& alloc)
|
||||
/* re-center text */
|
||||
//_layout->get_pixel_size (_text_width, _text_height);
|
||||
}
|
||||
if (_tweaks & ExpandtoSquare && alloc.get_width () != alloc.get_height ()) {
|
||||
if (!_squaresize.has_value ()) {
|
||||
_squaresize = std::max (alloc.get_width (), alloc.get_height ());
|
||||
queue_resize ();
|
||||
} else {
|
||||
/* allow widget to shink next time */
|
||||
_squaresize.reset ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1334,6 +1346,7 @@ ArdourButton::set_tweaks (Tweaks t)
|
||||
{
|
||||
if (_tweaks != t) {
|
||||
_tweaks = t;
|
||||
_squaresize.reset ();
|
||||
if (get_realized()) {
|
||||
queue_resize ();
|
||||
}
|
||||
|
@ -61,12 +61,13 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
|
||||
virtual ~ArdourButton ();
|
||||
|
||||
enum Tweaks {
|
||||
Square = 0x1,
|
||||
TrackHeader = 0x2,
|
||||
OccasionalText = 0x4,
|
||||
OccasionalLED = 0x8,
|
||||
Square = 0x01,
|
||||
TrackHeader = 0x02,
|
||||
OccasionalText = 0x04,
|
||||
OccasionalLED = 0x08,
|
||||
ForceBoxy = 0x10,
|
||||
ForceFlat = 0x20,
|
||||
ExpandtoSquare = 0x40,
|
||||
};
|
||||
|
||||
static Tweaks default_tweaks;
|
||||
@ -202,6 +203,7 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ
|
||||
|
||||
uint32_t outline_color;
|
||||
|
||||
std::optional<int> _squaresize;
|
||||
|
||||
cairo_pattern_t* convex_pattern;
|
||||
cairo_pattern_t* concave_pattern;
|
||||
|
Loading…
Reference in New Issue
Block a user