[haiku-commits] haiku: hrev49398 - src/kits/interface headers/os/interface

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 14 Jul 2015 03:35:23 +0200 (CEST)

hrev49398 adds 1 changeset to branch 'master'
old head: fb6c8a04795cf23e26ccd168de8b34ef864b4679
new head: 6031dea0cb44f6a3e512f35ded22dfb02b0ae753
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=6031dea0cb44+%5Efb6c8a04795c

----------------------------------------------------------------------------

6031dea0cb44: BTabView: Lots of fixes & cleanup.

* Address TODO about setting fSelected when nothing is done.
* Pass a pointer to the tab view to the BTab so that it can call
Invalidate().
(Checked against BeOS).
* Call Invalidate() from the BTab after SetView() & SetName().

Fixes #12108 & #12196.

[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49398
Commit: 6031dea0cb44f6a3e512f35ded22dfb02b0ae753
URL: http://cgit.haiku-os.org/haiku/commit/?id=6031dea0cb44
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Tue Jul 14 01:28:20 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12108
Ticket: https://dev.haiku-os.org/ticket/12196

----------------------------------------------------------------------------

2 files changed, 31 insertions(+), 14 deletions(-)
headers/os/interface/TabView.h | 8 +++++++-
src/kits/interface/TabView.cpp | 37 ++++++++++++++++++++++++-------------

----------------------------------------------------------------------------

diff --git a/headers/os/interface/TabView.h b/headers/os/interface/TabView.h
index 3bf12f3..90f193b 100644
--- a/headers/os/interface/TabView.h
+++ b/headers/os/interface/TabView.h
@@ -9,6 +9,9 @@
#include <View.h>


+class BTabView;
+
+
enum tab_position {
B_TAB_FIRST = 999,
B_TAB_FRONT,
@@ -67,12 +70,15 @@ private:
BTab& operator=(const BTab&);

private:
+ friend class BTabView;
+
bool fEnabled;
bool fSelected;
bool fFocus;
BView* fView;
+ BTabView* fTabView;

- uint32 _reserved[12];
+ uint32 _reserved[11];
};


diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp
index cb2db7c..50a6b97 100644
--- a/src/kits/interface/TabView.cpp
+++ b/src/kits/interface/TabView.cpp
@@ -52,7 +52,8 @@ BTab::BTab(BView* tabView)
fEnabled(true),
fSelected(false),
fFocus(false),
- fView(tabView)
+ fView(tabView),
+ fTabView(NULL)
{
}

@@ -62,7 +63,8 @@ BTab::BTab(BMessage* archive)
BArchivable(archive),
fSelected(false),
fFocus(false),
- fView(NULL)
+ fView(NULL),
+ fTabView(NULL)
{
bool disable;

@@ -133,6 +135,9 @@ BTab::SetLabel(const char* label)
return;

fView->SetName(label);
+
+ if (fTabView != NULL)
+ fTabView->Invalidate();
}


@@ -144,29 +149,28 @@ BTab::IsSelected() const


void
-BTab::Select(BView* owner)
+BTab::Select(BView*)
{
- // TODO: Shouldn't we still maintain fSelected like in Deselect()?
- if (!owner || !View() || !owner->Window())
+ fSelected = true;
+
+ if (!fTabView || !View())
return;

// NOTE: Views are not added/removed, if there is layout,
// they are made visible/invisible in that case.
- if (!owner->GetLayout() && View()->Parent() == NULL)
- owner->AddChild(fView);
-
- fSelected = true;
+ if (!fTabView->ContainerView()->GetLayout() && View()->Parent() ==
NULL)
+ fTabView->AddChild(fView);
}


void
BTab::Deselect()
{
- if (View()) {
+ if (View() && fTabView) {
// NOTE: Views are not added/removed, if there is layout,
// they are made visible/invisible in that case.
bool removeView = false;
- BView* container = View()->Parent();
+ BView* container = fTabView->ContainerView();
if (container)
removeView =

dynamic_cast<BCardLayout*>(container->GetLayout()) == NULL;
@@ -217,6 +221,11 @@ BTab::SetView(BView* view)
delete fView;
}
fView = view;
+
+ if (fTabView != NULL && fSelected) {
+ Select(NULL);
+ fTabView->Invalidate();
+ }
}


@@ -491,7 +500,7 @@ BTabView::AttachedToWindow()
{
BView::AttachedToWindow();

- if (fSelection < 0)
+ if (fSelection < 0 && CountTabs() > 0)
Select(0);
}

@@ -682,10 +691,10 @@ BTabView::Select(int32 index)
tab->Deselect();

tab = TabAt(index);
+ tab->Select(NULL);
if (tab && ContainerView()) {
if (index == 0)
fTabOffset = 0.0f;
- tab->Select(ContainerView());
fSelection = index;

// make the view visible through the layout if there is one
@@ -1142,6 +1151,7 @@ BTabView::AddTab(BView* target, BTab* tab)
fContainerView->GetLayout()->AddView(CountTabs(), target);

fTabList->AddItem(tab);
+ tab->fTabView = this;

// When we haven't had a any tabs before, but are already attached to
the
// window, select this one.
@@ -1161,6 +1171,7 @@ BTabView::RemoveTab(int32 index)
return NULL;

tab->Deselect();
+ tab->fTabView = NULL;

if (fContainerView->GetLayout())
fContainerView->GetLayout()->RemoveItem(index);


Other related posts: