mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-24 20:22:10 +00:00
Widgets: Avoid redraws by reducing gtk calls
This commit is contained in:
parent
e1cf8f2475
commit
d8eae96e50
1 changed files with 9 additions and 6 deletions
|
@ -63,7 +63,7 @@ void Widget::CreateAndAddWidget(Widget* widget, GtkWidget* parentWidget)
|
|||
|
||||
void Widget::SetClass(const std::string& cssClass)
|
||||
{
|
||||
if (m_Widget)
|
||||
if (m_Widget && m_CssClass != cssClass)
|
||||
{
|
||||
auto style = gtk_widget_get_style_context(m_Widget);
|
||||
gtk_style_context_remove_class(style, m_CssClass.c_str());
|
||||
|
@ -287,11 +287,14 @@ Quad CairoArea::GetQuad()
|
|||
|
||||
void Sensor::SetValue(double val)
|
||||
{
|
||||
if (val != m_Val)
|
||||
{
|
||||
m_Val = val;
|
||||
if (m_Widget)
|
||||
{
|
||||
gtk_widget_queue_draw(m_Widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sensor::SetStyle(SensorStyle style)
|
||||
|
@ -492,11 +495,11 @@ void Revealer::SetRevealed(bool revealed)
|
|||
|
||||
void Text::SetText(const std::string& text)
|
||||
{
|
||||
m_Text = text;
|
||||
if (m_Widget)
|
||||
if (m_Widget && text != m_Text)
|
||||
{
|
||||
gtk_label_set_text((GtkLabel*)m_Widget, m_Text.c_str());
|
||||
}
|
||||
m_Text = text;
|
||||
}
|
||||
|
||||
void Text::Create()
|
||||
|
|
Loading…
Reference in a new issue