TabView: Add TabViewPrivate class, actually fix non-layout SetView.
Thanks to Axel and Stephan for reviewing!
This commit is contained in:
@@ -52,7 +52,11 @@ public:
|
||||
virtual void DrawTab(BView* owner, BRect frame,
|
||||
tab_position position, bool full = true);
|
||||
|
||||
class Private;
|
||||
|
||||
private:
|
||||
friend class Private;
|
||||
|
||||
// FBC padding and forbidden methods
|
||||
virtual void _ReservedTab1();
|
||||
virtual void _ReservedTab2();
|
||||
@@ -70,8 +74,6 @@ private:
|
||||
BTab& operator=(const BTab&);
|
||||
|
||||
private:
|
||||
friend class BTabView;
|
||||
|
||||
bool fEnabled;
|
||||
bool fSelected;
|
||||
bool fFocus;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2015, Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Augustin Cavalier <waddlesplash>
|
||||
*/
|
||||
#ifndef TABVIEW_PRIVATE_H
|
||||
#define TABVIEW_PRIVATE_H
|
||||
|
||||
|
||||
#include <TabView.h>
|
||||
|
||||
|
||||
class BTab::Private {
|
||||
public:
|
||||
Private(BTab* tab)
|
||||
:
|
||||
fTab(tab)
|
||||
{
|
||||
}
|
||||
|
||||
void SetTabView(BTabView* tabView)
|
||||
{ fTab->fTabView = tabView; }
|
||||
|
||||
private:
|
||||
BTab* fTab;
|
||||
};
|
||||
|
||||
|
||||
#endif /* TABVIEW_PRIVATE_H */
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
|
||||
#include <TabView.h>
|
||||
#include <TabViewPrivate.h>
|
||||
|
||||
#include <new>
|
||||
#include <string.h>
|
||||
@@ -153,12 +154,12 @@ BTab::Select(BView* owner)
|
||||
{
|
||||
fSelected = true;
|
||||
|
||||
if (!owner || !View() || !owner->Window())
|
||||
if (!owner || !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)
|
||||
if (!owner->GetLayout() && View()->Parent() == NULL)
|
||||
owner->AddChild(fView);
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ BTab::SetView(BView* view)
|
||||
fView = view;
|
||||
|
||||
if (fTabView != NULL && fSelected) {
|
||||
Select(NULL);
|
||||
Select(fTabView->ContainerView());
|
||||
fTabView->Invalidate();
|
||||
}
|
||||
}
|
||||
@@ -1151,7 +1152,7 @@ BTabView::AddTab(BView* target, BTab* tab)
|
||||
fContainerView->GetLayout()->AddView(CountTabs(), target);
|
||||
|
||||
fTabList->AddItem(tab);
|
||||
tab->fTabView = this;
|
||||
BTab::Private(tab).SetTabView(this);
|
||||
|
||||
// When we haven't had a any tabs before, but are already attached to the
|
||||
// window, select this one.
|
||||
@@ -1171,7 +1172,7 @@ BTabView::RemoveTab(int32 index)
|
||||
return NULL;
|
||||
|
||||
tab->Deselect();
|
||||
tab->fTabView = NULL;
|
||||
BTab::Private(tab).SetTabView(NULL);
|
||||
|
||||
if (fContainerView->GetLayout())
|
||||
fContainerView->GetLayout()->RemoveItem(index);
|
||||
|
||||
Reference in New Issue
Block a user