13
0

meterbridge: track size and position via configure events

This allows ::get_state() to be const.
This commit is contained in:
Paul Davis 2022-04-07 11:47:13 -06:00
parent 04d34c4061
commit 0d82703f8e
2 changed files with 17 additions and 15 deletions

View File

@ -244,19 +244,10 @@ Meterbridge::set_window_pos_and_size ()
}
}
void
Meterbridge::get_window_pos_and_size () const
{
#warning CONSTIFICATION this really needs to work some other way, since this supposed to be const
get_position(m_root_x, m_root_y);
get_size(m_width, m_height);
}
bool
Meterbridge::hide_window (GdkEventAny *ev)
{
if (!_visible) return 0;
get_window_pos_and_size();
_visible = false;
return just_hide_it(ev, static_cast<Gtk::Window *>(this));
}
@ -495,11 +486,6 @@ XMLNode&
Meterbridge::get_state () const
{
XMLNode* node = new XMLNode ("Meterbridge");
if (is_realized() && _visible) {
get_window_pos_and_size ();
}
XMLNode* geometry = new XMLNode ("geometry");
geometry->set_property(X_("x-size"), m_width);
geometry->set_property(X_("y-size"), m_height);
@ -774,3 +760,18 @@ Meterbridge::on_theme_changed ()
{
meter_clear_pattern_cache();
}
bool
Meterbridge::on_configure_event (GdkEventConfigure* conf)
{
bool ret = Gtk::Window::on_configure_event (conf);
Glib::RefPtr<const Gdk::Window> win = get_window();
if (win) {
win->get_size (m_width, m_height);
win->get_position (m_root_x, m_root_y);
}
return ret;
}

View File

@ -133,7 +133,6 @@ private:
mutable int m_root_x, m_root_y, m_width, m_height;
void set_window_pos_and_size ();
void get_window_pos_and_size () const;
bool on_key_press_event (GdkEventKey*);
bool on_key_release_event (GdkEventKey*);
@ -153,6 +152,8 @@ private:
int _mm_left, _mm_right;
ARDOUR::MeterType _mt_left, _mt_right;
bool on_configure_event (GdkEventConfigure* conf);
};
#endif