Sfoglia il codice sorgente

LibGUI: GTabWidget can now return active tab index

`GTabWidget` now allows the user/caller to get the currently active
tab widget, meaning that actions that are applied globally (such as
an 'Apply' or 'OK' button) can now react to specific tabs etc.
Jesse Buhagiar 6 anni fa
parent
commit
3f05799e41
2 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 11 0
      Libraries/LibGUI/GTabWidget.cpp
  2. 1 0
      Libraries/LibGUI/GTabWidget.h

+ 11 - 0
Libraries/LibGUI/GTabWidget.cpp

@@ -208,3 +208,14 @@ void GTabWidget::set_tab_position(TabPosition tab_position)
         m_active_widget->set_relative_rect(child_rect_for_size(size()));
         m_active_widget->set_relative_rect(child_rect_for_size(size()));
     update();
     update();
 }
 }
+
+int GTabWidget::get_active_tab() const
+{
+    for(int i = 0; i < m_tabs.size(); i++)
+    {
+        if(m_tabs.at(i).widget == m_active_widget)
+            return i;
+    }
+
+    return -1;
+}

+ 1 - 0
Libraries/LibGUI/GTabWidget.h

@@ -15,6 +15,7 @@ public:
 
 
     TabPosition tab_position() const { return m_tab_position; }
     TabPosition tab_position() const { return m_tab_position; }
     void set_tab_position(TabPosition);
     void set_tab_position(TabPosition);
+    int get_active_tab() const;
 
 
     GWidget* active_widget() const { return m_active_widget; }
     GWidget* active_widget() const { return m_active_widget; }
     void set_active_widget(GWidget*);
     void set_active_widget(GWidget*);