Ticket #6407: patch

File patch, 78.1 KB (added by yourpalal, 9 years ago)

Patch for review

  • src/preferences/keymap/KeymapWindow.cpp

     
    508508        .Add(new BStringView("system", B_TRANSLATE("System:")))
    509509        .Add(systemScroller, 3)
    510510        .Add(new BStringView("user", B_TRANSLATE("User:")))
    511         .Add(userScroller);
     511        .Add(userScroller)
     512        .TopView();
    512513}
    513514
    514515
  • src/preferences/backgrounds/BackgroundsView.cpp

     
    144144        .AddGroup(B_VERTICAL, 20)
    145145            .AddGroup(B_HORIZONTAL, 0)
    146146                .AddGlue()
    147                 .AddGrid(0, 0)
     147                .AddGrid(0, 0, 1)
    148148                    .Add(fTopLeft, 0, 0)
    149149                    .Add(fTop, 1, 0)
    150150                    .Add(fTopRight, 2, 0)
  • src/libs/alm/BALMLayout.cpp

     
    2020 * Creates new layout engine.
    2121 */
    2222BALMLayout::BALMLayout()
    23     : BLayout(),
     23    :
     24    BAbstractLayout(),
    2425    LinearSpec()
    2526{
    2627    fLayoutStyle = FIT_TO_SIZE;
     
    189190{
    190191    InvalidateLayout();
    191192    if (content != NULL)
    192         View()->AddChild(content);
     193        TargetView()->AddChild(content);
    193194    Area* area = new Area(this, left, top, right, bottom, content, minContentSize);
    194195    fAreas->AddItem(area);
    195196    return area;
     
    211212{
    212213    InvalidateLayout();
    213214    if (content != NULL)
    214         View()->AddChild(content);
     215        TargetView()->AddChild(content);
    215216    Area* area = new Area(this, row, column, content, minContentSize);
    216217    fAreas->AddItem(area);
    217218    return area;
     
    234235{
    235236    InvalidateLayout();
    236237    if (content != NULL)
    237         View()->AddChild(content);
     238        TargetView()->AddChild(content);
    238239    Area* area = new Area(this, left, top, right, bottom, content, BSize(0, 0));
    239240    area->SetDefaultBehavior();
    240241    area->SetAutoPreferredContentSize(false);
     
    256257{
    257258    InvalidateLayout();
    258259    if (content != NULL)
    259         View()->AddChild(content);
     260        TargetView()->AddChild(content);
    260261    Area* area = new Area(this, row, column, content, BSize(0, 0));
    261262    area->SetDefaultBehavior();
    262263    area->SetAutoPreferredContentSize(false);
     
    435436
    436437
    437438/**
    438  * Sets and gets minimum size.
     439 * Gets minimum size.
    439440 */
    440 BSize BALMLayout::MinSize() {
     441BSize
     442BALMLayout::BaseMinSize() {
    441443    if (fMinSize == Area::kUndefinedSize)
    442444        fMinSize = CalculateMinSize();
    443445    return fMinSize;
     
    445447
    446448
    447449/**
    448  * Sets and gets maximum size.
     450 * Gets maximum size.
    449451 */
    450452BSize
    451 BALMLayout::MaxSize()
     453BALMLayout::BaseMaxSize()
    452454{
    453455    if (fMaxSize == Area::kUndefinedSize)
    454456        fMaxSize = CalculateMaxSize();
     
    457459
    458460
    459461/**
    460  * Sets and gets preferred size.
     462 * Gets preferred size.
    461463 */
    462464BSize
    463 BALMLayout::PreferredSize()
     465BALMLayout::BasePreferredSize()
    464466{
    465467    if (fPreferredSize == Area::kUndefinedSize)
    466468        fPreferredSize = CalculatePreferredSize();
     
    472474 * Gets the alignment.
    473475 */
    474476BAlignment
    475 BALMLayout::Alignment()
     477BALMLayout::BaseAlignment()
    476478{
    477479    BAlignment alignment;
    478480    alignment.SetHorizontal(B_ALIGN_HORIZONTAL_CENTER);
     
    492494
    493495
    494496/**
    495  * Sets whether the height of the layout depends on its width.
     497 * Gets height constraints for a given width.
    496498 */
    497499void
    498500BALMLayout::GetHeightForWidth(float width, float* min, float* max, float* preferred) {}
     
    503505 * Resets minimum/maximum/preferred size.
    504506 */
    505507void
    506 BALMLayout::InvalidateLayout()
     508BALMLayout::InvalidateLayout(bool children)
    507509{
     510    BLayout::InvalidateLayout(children);
    508511    fMinSize = Area::kUndefinedSize;
    509512    fMaxSize = Area::kUndefinedSize;
    510513    fPreferredSize = Area::kUndefinedSize;
     
    516519 * If no layout specification is given, a specification is reverse engineered automatically.
    517520 */
    518521void
    519 BALMLayout::LayoutView()
     522BALMLayout::DerivedLayoutItems()
    520523{
     524    // TODO: modify to allow for viewlessness
    521525    // make sure that layout events occuring during layout are ignored
    522     // i.e. activated is set to false during layout caluclation
     526    // i.e. activated is set to false during layout calculation
    523527    if (!fActivated)
    524528        return;
    525529    fActivated = false;
    526530
    527     if (View() == NULL)
     531    if (Owner() == NULL)
    528532        return;
    529533
    530534    // reverse engineer a layout specification if none was given
    531535    //~ if (this == NULL) RecoverLayout(View());
    532536
    533537    // if the layout engine is set to fit the GUI to the given size,
    534     // then the given size is enforced by setting absolute positions for Right and Bottom
     538    // then the given size is enforced by setting absolute positions
     539    // for Right and Bottom
    535540    if (fLayoutStyle == FIT_TO_SIZE) {
    536         Right()->SetRange(View()->Bounds().Width(), View()->Bounds().Width());
    537         Bottom()->SetRange(View()->Bounds().Height(), View()->Bounds().Height());
     541        BSize layoutSize(LayoutArea().Size());
     542        Right()->SetRange(layoutSize.width, layoutSize.width);
     543        Bottom()->SetRange(layoutSize.height, layoutSize.height);
    538544    }
    539545
    540546    SolveLayout();
     
    554560    // change the size of the GUI according to the calculated size
    555561    // if the layout engine was configured to do so
    556562    if (fLayoutStyle == ADJUST_SIZE) {
    557         View()->ResizeTo(floor(Right()->Value() - Left()->Value() + 0.5),
     563        Owner()->ResizeTo(floor(Right()->Value() - Left()->Value() + 0.5),
    558564                floor(Bottom()->Value() - Top()->Value() + 0.5));
    559565    }
    560566
  • src/kits/interface/AbstractLayout.cpp

     
     1/*
     2 * Copyright 2010, Haiku, Inc.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5
     6
     7#include <AbstractLayout.h>
     8#include <LayoutUtils.h>
     9#include <Message.h>
     10#include <View.h>
     11#include <ViewPrivate.h>
     12
     13
     14namespace {
     15    const char* const kSizesField = "BAbstractLayout:sizes";
     16        // kSizesField == {min, max, preferred}
     17    const char* const kAlignmentField = "BAbstractLayout:alignment";
     18    const char* const kFrameField = "BAbstractLayout:frame";
     19    const char* const kVisibleField = "BAbstractLayout:visible";
     20
     21    enum proxy_type { VIEW_PROXY_TYPE, DATA_PROXY_TYPE };
     22}
     23
     24
     25struct BAbstractLayout::Proxy {
     26
     27    Proxy(proxy_type type)
     28        :
     29        type(type)
     30    {
     31    }
     32
     33    virtual BSize       MinSize() const = 0;
     34    virtual void        SetMinSize(const BSize&) = 0;
     35
     36    virtual BSize       MaxSize() const = 0;
     37    virtual void        SetMaxSize(const BSize&) = 0;
     38
     39    virtual BSize       PreferredSize() const = 0;
     40    virtual void        SetPreferredSize(const BSize&) = 0;
     41
     42    virtual BAlignment  Alignment() const = 0;
     43    virtual void        SetAlignment(const BAlignment&) = 0;
     44
     45    virtual BRect       Frame() const = 0;
     46    virtual void        SetFrame(const BRect& frame) = 0;
     47
     48    virtual bool        IsVisible(bool ancestorHidden) const = 0;
     49    virtual void        SetVisible(bool visible) = 0;
     50   
     51    virtual status_t    AddDataToArchive(BMessage* archive,
     52                            bool ancestorHidden) = 0;
     53    virtual status_t    RestoreDataFromArchive(const BMessage* archive) = 0;
     54
     55            proxy_type  type;
     56};
     57
     58
     59struct BAbstractLayout::DataProxy : Proxy {
     60
     61    DataProxy()
     62        :
     63        Proxy(DATA_PROXY_TYPE),
     64        minSize(),
     65        maxSize(),
     66        preferredSize(),
     67        alignment(),
     68        frame(-1, -1, 0, 0),
     69        visible(true)
     70    {
     71    }
     72
     73    BSize MinSize() const
     74    {
     75        return minSize;
     76    }
     77
     78    void SetMinSize(const BSize& min)
     79    {
     80        minSize = min;
     81    }
     82
     83    BSize MaxSize() const
     84    {
     85        return maxSize;
     86    }
     87
     88    void SetMaxSize(const BSize& max)
     89    {
     90        maxSize = max;
     91    }
     92
     93    BSize PreferredSize() const
     94    {
     95        return preferredSize;
     96    }
     97
     98    void SetPreferredSize(const BSize& preferred)
     99    {
     100        preferredSize = preferred;
     101    }
     102
     103    BAlignment Alignment() const
     104    {
     105        return this->alignment;
     106    }
     107
     108    void SetAlignment(const BAlignment& align)
     109    {
     110        this->alignment = align;
     111    }
     112
     113    BRect Frame() const
     114    {
     115        return frame;
     116    }
     117
     118    void SetFrame(const BRect& frame)
     119    {
     120        if (frame == this->frame)
     121            return;
     122        this->frame = frame;
     123    }
     124
     125    bool IsVisible(bool) const
     126    {
     127        return visible;
     128    }
     129
     130    void SetVisible(bool visible)
     131    {
     132        this->visible = visible;
     133    }
     134
     135    status_t AddDataToArchive(BMessage* archive, bool ancestorHidden)
     136    {
     137        status_t err = archive->AddSize(kSizesField, minSize);
     138        if (err == B_OK)
     139            err = archive->AddSize(kSizesField, maxSize);
     140        if (err == B_OK)
     141            err = archive->AddSize(kSizesField, preferredSize);
     142        if (err == B_OK)
     143            err = archive->AddAlignment(kAlignmentField, alignment);
     144        if (err == B_OK)
     145            err = archive->AddRect(kFrameField, frame);
     146        if (err == B_OK)
     147            err = archive->AddBool(kVisibleField, visible);
     148
     149        return err;
     150    }
     151
     152    status_t RestoreDataFromArchive(const BMessage* archive)
     153    {
     154        status_t err = archive->FindSize(kSizesField, 0, &minSize);
     155        if (err == B_OK)
     156            err = archive->FindSize(kSizesField, 1, &maxSize);
     157        if (err == B_OK)
     158            err = archive->FindSize(kSizesField, 2, &preferredSize);
     159        if (err == B_OK)
     160            err = archive->FindAlignment(kAlignmentField, &alignment);
     161        if (err == B_OK)
     162            err = archive->FindRect(kFrameField, &frame);
     163        if (err == B_OK)
     164            err = archive->FindBool(kVisibleField, &visible);
     165
     166        return err;
     167    }
     168
     169    BSize       minSize;
     170    BSize       maxSize;
     171    BSize       preferredSize;
     172    BAlignment  alignment;
     173    BRect       frame;
     174    bool        visible;
     175};
     176
     177
     178struct BAbstractLayout::ViewProxy : Proxy {
     179    ViewProxy(BView* target)
     180        :
     181        Proxy(VIEW_PROXY_TYPE),
     182        view(target)
     183    {
     184    }
     185
     186    BSize MinSize() const
     187    {
     188        return view->ExplicitMinSize();
     189    }
     190
     191    void SetMinSize(const BSize& min)
     192    {
     193        view->SetExplicitMinSize(min);
     194    }
     195
     196    BSize MaxSize() const
     197    {
     198        return view->ExplicitMaxSize();
     199    }
     200
     201    void SetMaxSize(const BSize& min)
     202    {
     203        view->SetExplicitMaxSize(min);
     204    }
     205
     206    BSize PreferredSize() const
     207    {
     208        return view->ExplicitPreferredSize();
     209    }
     210
     211    void SetPreferredSize(const BSize& preferred)
     212    {
     213        view->SetExplicitPreferredSize(preferred);
     214    }
     215
     216    BAlignment Alignment() const
     217    {
     218        return view->ExplicitAlignment();
     219    }
     220
     221    void SetAlignment(const BAlignment& alignment)
     222    {
     223        view->SetExplicitAlignment(alignment);
     224    }
     225
     226    BRect Frame() const
     227    {
     228        return view->Frame();
     229    }
     230
     231    void SetFrame(const BRect& frame)
     232    {
     233        view->MoveTo(frame.LeftTop());
     234        view->ResizeTo(frame.Width(), frame.Height());
     235    }
     236
     237    bool IsVisible(bool ancestorsVisible) const
     238    {
     239        int16 showLevel = BView::Private(view).ShowLevel();
     240        return (showLevel - (ancestorsVisible) ? 0 : 1) <= 0;
     241    }
     242
     243    void SetVisible(bool visible)
     244    {
     245        // No need to check that we are not re-hiding, that is done
     246        // for us.
     247        if (visible)
     248            view->Show();
     249        else
     250            view->Hide();
     251    }
     252
     253    status_t AddDataToArchive(BMessage* archive, bool ancestorHidden)
     254    {
     255        return B_OK;
     256    }
     257
     258    status_t RestoreDataFromArchive(const BMessage* archive)
     259    {
     260        return B_OK;
     261    }
     262
     263    BView*  view;
     264};
     265
     266
     267BAbstractLayout::BAbstractLayout()
     268    :
     269    fExplicitData(new BAbstractLayout::DataProxy())
     270{
     271}
     272
     273
     274BAbstractLayout::BAbstractLayout(BMessage* from)
     275    :
     276    BLayout(BUnarchiver::PrepareArchive(from)),
     277    fExplicitData(new DataProxy())
     278{
     279    BUnarchiver(from).Finish();
     280}
     281
     282
     283BAbstractLayout::~BAbstractLayout()
     284{
     285    delete fExplicitData;
     286}
     287
     288
     289BSize
     290BAbstractLayout::MinSize()
     291{
     292    return BLayoutUtils::ComposeSize(fExplicitData->MinSize(), BaseMinSize());
     293}
     294
     295
     296BSize
     297BAbstractLayout::MaxSize()
     298{
     299    return BLayoutUtils::ComposeSize(fExplicitData->MaxSize(), BaseMaxSize());
     300}
     301
     302
     303BSize
     304BAbstractLayout::PreferredSize()
     305{
     306    return BLayoutUtils::ComposeSize(fExplicitData->PreferredSize(),
     307        BasePreferredSize());
     308}
     309
     310
     311BAlignment
     312BAbstractLayout::Alignment()
     313{
     314    return BLayoutUtils::ComposeAlignment(fExplicitData->Alignment(),
     315        BaseAlignment());
     316}
     317
     318
     319void
     320BAbstractLayout::SetExplicitMinSize(BSize size)
     321{
     322    fExplicitData->SetMinSize(size);
     323}
     324
     325
     326void
     327BAbstractLayout::SetExplicitMaxSize(BSize size)
     328{
     329    fExplicitData->SetMaxSize(size);
     330}
     331
     332
     333void
     334BAbstractLayout::SetExplicitPreferredSize(BSize size)
     335{
     336    fExplicitData->SetPreferredSize(size);
     337}
     338
     339
     340void
     341BAbstractLayout::SetExplicitAlignment(BAlignment alignment)
     342{
     343    fExplicitData->SetAlignment(alignment);
     344}
     345
     346
     347BSize
     348BAbstractLayout::BaseMinSize()
     349{
     350    return BSize(0, 0);
     351}
     352
     353
     354BSize
     355BAbstractLayout::BaseMaxSize()
     356{
     357    return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
     358}
     359
     360
     361BSize
     362BAbstractLayout::BasePreferredSize()
     363{
     364    return BSize(0, 0);
     365}
     366
     367
     368BAlignment
     369BAbstractLayout::BaseAlignment()
     370{
     371    return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
     372}
     373
     374
     375BRect
     376BAbstractLayout::Frame()
     377{
     378    return fExplicitData->Frame();
     379}
     380
     381
     382void
     383BAbstractLayout::SetFrame(BRect frame)
     384{
     385    if (frame != fExplicitData->Frame()) {
     386        fExplicitData->SetFrame(frame);
     387        if (!Owner())
     388            Relayout();
     389    }
     390}
     391
     392
     393bool
     394BAbstractLayout::IsVisible()
     395{
     396    return fExplicitData->IsVisible(AncestorsVisible());
     397}
     398
     399
     400void
     401BAbstractLayout::SetVisible(bool visible)
     402{
     403    if (visible != fExplicitData->IsVisible(AncestorsVisible())) {
     404        fExplicitData->SetVisible(visible);
     405        if (Layout())
     406            Layout()->InvalidateLayout(false);
     407        VisibilityChanged(visible);
     408    }
     409}
     410
     411
     412status_t
     413BAbstractLayout::Archive(BMessage* into, bool deep) const
     414{
     415    BArchiver archiver(into);
     416    status_t err = BLayout::Archive(into, deep);
     417
     418    return archiver.Finish(err);
     419}
     420
     421
     422status_t
     423BAbstractLayout::AllUnarchived(const BMessage* from)
     424{
     425    if (Owner()) {
     426        ViewProxy* proxy = dynamic_cast<ViewProxy*>(fExplicitData);
     427        if (!proxy) {
     428            delete fExplicitData;
     429            proxy = new ViewProxy(Owner());
     430        }
     431        proxy->view = Owner();
     432    } else {
     433        fExplicitData = new DataProxy();
     434        return fExplicitData->RestoreDataFromArchive(from);
     435    }
     436
     437    return BLayout::AllUnarchived(from);
     438}
     439
     440
     441void
     442BAbstractLayout::OwnerChanged(BView* was)
     443{
     444    if (was) {
     445        static_cast<ViewProxy*>(fExplicitData)->view = Owner();
     446        return;
     447    }
     448
     449    delete fExplicitData;
     450    fExplicitData = new ViewProxy(Owner());
     451}
     452
     453
     454void
     455BAbstractLayout::AncestorVisibilityChanged(bool shown)
     456{
     457    if (AncestorsVisible() == shown)
     458        return;
     459
     460    if (BView* owner = Owner()) {
     461        if (shown)
     462            owner->Show();
     463        else
     464            owner->Hide();
     465    }
     466    BLayout::AncestorVisibilityChanged(shown);
     467}
     468
  • src/kits/interface/ViewLayoutItem.h

     
    3636
    3737    virtual BView*              View();
    3838
    39     virtual void                InvalidateLayout();
     39    virtual void                InvalidateLayout(bool children = false);
     40    virtual void                Relayout(bool immediate = false);
    4041
    4142    virtual status_t            Archive(BMessage* into, bool deep = true) const;
    4243    virtual status_t            AllArchived(BMessage* into) const;
    4344    virtual status_t            AllUnarchived(const BMessage* from);
    4445    static  BArchivable*        Instantiate(BMessage* from);
    4546
     47protected:
     48    virtual void                AncestorVisibilityChanged(bool shown);
     49
    4650private:
    4751            BView*              fView;
     52            int32               fAncestorsVisible;
    4853};
    4954
    5055#endif  //  _VIEW_LAYOUT_ITEM_H
  • src/kits/interface/View.cpp

     
    648648        err = unarchiver.FindObject(kLayoutField, layout);
    649649        if (err == B_OK && layout) {
    650650            fFlags |= B_SUPPORTS_LAYOUT;
    651             fLayoutData->fLayout->BLayout::SetView(this);
     651            fLayoutData->fLayout->SetOwner(this);
    652652        }
    653653    }
    654654
     
    997997    fShowLevel++;
    998998
    999999    if (fShowLevel == 1 && fParent)
    1000         fParent->InvalidateLayout();
     1000        _InvalidateParentLayout();
    10011001}
    10021002
    10031003
     
    10121012    }
    10131013
    10141014    if (fShowLevel == 0 && fParent)
    1015         fParent->InvalidateLayout();
     1015        _InvalidateParentLayout();
    10161016}
    10171017
    10181018
     
    40204020BView::RemoveSelf()
    40214021{
    40224022    if (fParent && fParent->fLayoutData->fLayout)
    4023         return fParent->fLayoutData->fLayout->RemoveView(this);
     4023        return fParent->fLayoutData->fLayout->RemoveViewRecursive(this);
    40244024
    40254025    return _RemoveSelf();
    40264026}
     
    46434643    if (layout == fLayoutData->fLayout)
    46444644        return;
    46454645
     4646    if (layout && layout->Layout())
     4647        debugger("BView::SetLayout() failed, layout is already in use.");
     4648
    46464649    fFlags |= B_SUPPORTS_LAYOUT;
    46474650
    46484651    // unset and delete the old layout
    46494652    if (fLayoutData->fLayout) {
    4650         fLayoutData->fLayout->SetView(NULL);
     4653        fLayoutData->fLayout->SetOwner(NULL);
    46514654        delete fLayoutData->fLayout;
    46524655    }
    46534656
    46544657    fLayoutData->fLayout = layout;
    46554658
    46564659    if (fLayoutData->fLayout) {
    4657         fLayoutData->fLayout->SetView(this);
     4660        fLayoutData->fLayout->SetOwner(this);
    46584661
    46594662        // add all children
    46604663        int count = CountChildren();
     
    46764679void
    46774680BView::InvalidateLayout(bool descendants)
    46784681{
     4682    // printf("BView(%p)::InvalidateLayout(%i), valid: %i, inProgress: %i\n",
     4683    //  this, descendants, fLayoutData->fLayoutValid,
     4684    //  fLayoutData->fLayoutInProgress);
     4685
    46794686    if (fLayoutData->fMinMaxValid && !fLayoutData->fLayoutInProgress
    4680         && fLayoutData->fLayoutInvalidationDisabled == 0) {
    4681         if (fParent && fParent->fLayoutData->fMinMaxValid)
    4682             fParent->InvalidateLayout(false);
     4687        && fLayoutData->fLayoutInvalidationDisabled == 0) {
    46834688
    46844689        fLayoutData->fLayoutValid = false;
    46854690        fLayoutData->fMinMaxValid = false;
    46864691
    4687         if (fLayoutData->fLayout)
    4688             fLayoutData->fLayout->InvalidateLayout();
    4689 
    46904692        if (descendants) {
    4691             int count = CountChildren();
    4692             for (int i = 0; i < count; i++)
    4693                 ChildAt(i)->InvalidateLayout(descendants);
     4693            for (BView* child = fFirstChild;
     4694                child; child = child->fNextSibling) {
     4695                child->InvalidateLayout(descendants);
     4696            }
    46944697        }
    46954698
     4699        if (fLayoutData->fLayout && fLayoutData->fLayout->InvalidationLegal())
     4700            fLayoutData->fLayout->InvalidateLayout(descendants);
     4701        else if (!fLayoutData->fLayout && fParent) {
     4702            _InvalidateParentLayout();
     4703        }
     4704
    46964705        if (fTopLevelView) {
    46974706            // trigger layout process
    46984707            if (fOwner)
     
    47244733}
    47254734
    47264735
    4727 /*! \brief Service call for BLayout derived classes reenabling
     4736/*! \brief Service call for BView derived classes reenabling
    47284737    InvalidateLayout() notifications.
    4729     BView::InvalidateLayout() invokes InvalidateLayout() on its layout the first
    4730     time, but suppresses further calls until Layout()/Relayout() has been
    4731     invoked. This method will reenable the notification for the next call of
    4732     BView::InvalidateLayout().
    47334738
    4734     If the layout caches internal layout information and updates those
    4735     information also in methods other than LayoutView(), it has to invoke this
     4739    BLayout & BView will avoid calling InvalidateLayout on views that have
     4740    already been invalidated, but if the view caches internal layout information
     4741    which it updates in methds other than DoLayout(), it has to invoke this
    47364742    method, when it has done so, since otherwise the information might become
    47374743    obsolete without the layout noticing.
    47384744*/
     
    47634769{
    47644770    if (fLayoutData->fLayoutValid && !fLayoutData->fLayoutInProgress) {
    47654771        fLayoutData->fNeedsRelayout = true;
     4772        if (fLayoutData->fLayout)
     4773            fLayoutData->fLayout->RequireLayout();
    47664774
    47674775        // Layout() is recursive, that is if the parent view is currently laid
    47684776        // out, we don't call layout() on this view, but wait for the parent's
     
    47774785BView::DoLayout()
    47784786{
    47794787    if (fLayoutData->fLayout)
    4780         fLayoutData->fLayout->LayoutView();
     4788        fLayoutData->fLayout->_LayoutWithinContext(false, LayoutContext());
    47814789}
    47824790
    47834791
     
    48814889        fLayoutData->fNeedsRelayout = false;
    48824890
    48834891        // layout children
    4884         int32 childCount = CountChildren();
    4885         for (int32 i = 0; i < childCount; i++) {
    4886             BView* child = ChildAt(i);
     4892        for(BView* child = fFirstChild; child; child = child->fNextSibling) {
    48874893            if (!child->IsHidden(child))
    48884894                child->_Layout(force, context);
    48894895        }
     
    48974903}
    48984904
    48994905
     4906void
     4907BView::_LayoutLeft(BLayout* deleted)
     4908{
     4909    // If our layout is added to another layout (via BLayout::AddItem())
     4910    // then we share ownership of our layout. In the event that our layout gets
     4911    // deleted by the layout it has been added to, this method is called so
     4912    // that we don't double-delete our layout.
     4913    if (fLayoutData->fLayout == deleted)
     4914        fLayoutData->fLayout = NULL;
     4915    InvalidateLayout();
     4916}
     4917
     4918
     4919void
     4920BView::_InvalidateParentLayout()
     4921{
     4922    BLayout* layout = fLayoutData->fLayout;
     4923    BLayout* layoutParent = layout ? layout->Layout() : NULL;
     4924    if (layoutParent && layoutParent->InvalidationLegal()) {
     4925        layout->Layout()->InvalidateLayout();
     4926    } else if (fParent && fParent->fLayoutData->fLayout) {
     4927        fParent->fLayoutData->fLayout->InvalidateLayoutsForView(this);
     4928    } else if (fParent) {
     4929        fParent->InvalidateLayout();
     4930    }
     4931}
     4932
     4933
    49004934//  #pragma mark - Private Functions
    49014935
    49024936
     
    59205954        }
    59215955    }
    59225956}
     5957
     5958
     5959// #pragma mark -
     5960
     5961
     5962bool
     5963BView::Private::MinMaxValid()
     5964{
     5965    return fView->fLayoutData->fMinMaxValid;
     5966}
  • src/kits/interface/Layout.cpp

     
    77
    88#include <Layout.h>
    99
     10#include <algorithm>
     11#include <new>
    1012#include <syslog.h>
    11 #include <new>
    1213
     14#include <LayoutContext.h>
    1315#include <Message.h>
    1416#include <View.h>
     17#include <ViewPrivate.h>
    1518
    1619#include "ViewLayoutItem.h"
    1720
    1821
    1922using std::nothrow;
     23using std::swap;
    2024
    2125
    2226namespace {
     27    // flags for our state
     28    const uint32 B_LAYOUT_INVALID = 0x80000000UL; // needs layout
     29    const uint32 B_LAYOUT_CACHE_INVALID = 0x40000000UL; // needs recalculation
     30    const uint32 B_LAYOUT_REQUIRED = 0x20000000UL; // needs layout
     31    const uint32 B_LAYOUT_IN_PROGRESS = 0x10000000UL;
     32    const uint32 B_LAYOUT_ALL_CLEAR = 0UL;
     33
     34    // handy masks to check various states
     35    const uint32 B_LAYOUT_INVALIDATION_ILLEGAL
     36        = B_LAYOUT_CACHE_INVALID | B_LAYOUT_IN_PROGRESS;
     37    const uint32 B_LAYOUT_NECESSARY
     38        = B_LAYOUT_INVALID | B_LAYOUT_REQUIRED | B_LAYOUT_CACHE_INVALID;
     39    const uint32 B_RELAYOUT_NOT_OK
     40        = B_LAYOUT_INVALID | B_LAYOUT_IN_PROGRESS;
     41
    2342    const char* const kLayoutItemField = "BLayout:items";
    2443}
    2544
    2645
    2746BLayout::BLayout()
    2847    :
    29     fView(NULL),
     48    fState(B_LAYOUT_ALL_CLEAR),
     49    fAncestorsVisible(true),
     50    fInvalidationDisabled(0),
     51    fContext(NULL),
     52    fOwner(NULL),
     53    fTarget(NULL),
    3054    fItems(20)
    3155{
    3256}
     
    3458
    3559BLayout::BLayout(BMessage* from)
    3660    :
    37     BArchivable(BUnarchiver::PrepareArchive(from)),
    38     fView(NULL),
     61    BLayoutItem(BUnarchiver::PrepareArchive(from)),
     62    fState(B_LAYOUT_ALL_CLEAR),
     63    fAncestorsVisible(true),
     64    fInvalidationDisabled(0),
     65    fContext(NULL),
     66    fOwner(NULL),
     67    fTarget(NULL),
    3968    fItems(20)
    4069{
    4170    BUnarchiver unarchiver(from);
     
    4877
    4978BLayout::~BLayout()
    5079{
    51     // this deletes all items
    52     SetView(NULL);
     80    // in case we have a view, but have been added to a layout as a BLayoutItem
     81    // we will get deleted before our view, so we should tell it that we're
     82    // going, so that we aren't double-freed.
     83    if (fOwner && this == fOwner->GetLayout())
     84        fOwner->_LayoutLeft(this);
     85
     86    // removes and deletes all items
     87    if (fTarget)
     88        SetTarget(NULL);
    5389}
    5490
    5591
    5692BView*
    57 BLayout::View() const
     93BLayout::Owner() const
    5894{
    59     return fView;
     95    return fOwner;
    6096}
    6197
    6298
     99BView*
     100BLayout::TargetView() const
     101{
     102    return fTarget;
     103}
     104
     105
     106BView*
     107BLayout::View()
     108{
     109    return fOwner;
     110}
     111
     112
    63113BLayoutItem*
    64114BLayout::AddView(BView* child)
    65115{
     
    70120BLayoutItem*
    71121BLayout::AddView(int32 index, BView* child)
    72122{
    73     if (BViewLayoutItem* item = new(nothrow) BViewLayoutItem(child)) {
    74         if (AddItem(index, item))
    75             return item;
     123    BLayoutItem* item = child->GetLayout();
     124    if (!item)
     125        item = new(nothrow) BViewLayoutItem(child);
     126
     127    if (item && AddItem(index, item))
     128        return item;
     129
     130    if (!child->GetLayout())
    76131        delete item;
    77     }
    78132    return NULL;
    79133}
    80134
     
    89143bool
    90144BLayout::AddItem(int32 index, BLayoutItem* item)
    91145{
    92     if (!fView || !item || fItems.HasItem(item))
     146    if (!fTarget || !item || fItems.HasItem(item))
    93147        return false;
    94148
    95149    // if the item refers to a BView, we make sure it is added to the parent
    96150    // view
    97151    bool addedView = false;
    98152    BView* view = item->View();
    99     if (view && view->fParent != fView
    100         && !(addedView = fView->_AddChild(view, NULL)))
     153    if (view && view->fParent != fTarget
     154        && !(addedView = fTarget->_AddChild(view, NULL)))
    101155        return false;
    102156
    103157    // validate the index
     
    106160
    107161    if (fItems.AddItem(item, index) && ItemAdded(item, index)) {
    108162        item->SetLayout(this);
     163        if (!fAncestorsVisible)
     164            item->AncestorVisibilityChanged(fAncestorsVisible);
    109165        InvalidateLayout();
    110166        return true;
    111167    } else {
     
    160216    // if the item refers to a BView, we make sure, it is removed from the
    161217    // parent view
    162218    BView* view = item->View();
    163     if (view && view->fParent == fView)
     219    if (view && view->fParent == fTarget)
    164220        view->_RemoveSelf();
    165221
     222    ItemRemoved(item, index);
    166223    item->SetLayout(NULL);
    167     ItemRemoved(item, index);
    168224    InvalidateLayout();
    169225
    170226    return item;
     
    206262}
    207263
    208264
     265bool
     266BLayout::AncestorsVisible()
     267{
     268    return fAncestorsVisible;
     269}
     270
     271
    209272void
    210 BLayout::InvalidateLayout()
     273BLayout::InvalidateLayout(bool children)
    211274{
    212     if (fView)
    213         fView->InvalidateLayout();
     275    // printf("BLayout(%p)::InvalidateLayout(%i) : state %x, disabled %li\n",
     276    // this, children, (unsigned int)fState, fInvalidationDisabled);
     277
     278    if (!InvalidationLegal())
     279        return;
     280
     281    fState |= B_LAYOUT_NECESSARY;
     282
     283    if (children) {
     284        for (int32 i = CountItems() - 1; i >= 0; i--)
     285            ItemAt(i)->InvalidateLayout(children); 
     286    }
     287
     288    if (fOwner && BView::Private(fOwner).MinMaxValid())
     289        fOwner->InvalidateLayout(children);
     290
     291    if (BLayout* nestedIn = Layout()) {
     292        if (nestedIn->InvalidationLegal())
     293            nestedIn->InvalidateLayout();
     294    } else if (fOwner) {
     295        // If we weren't added as a BLayoutItem, we still have to invalidate
     296        // whatever layout our owner is in.
     297        BView* ownerParent = fOwner->fParent;
     298        if (ownerParent) {
     299            BLayout* layout = ownerParent->GetLayout();
     300            if (layout && layout->fNestedLayouts.CountItems() > 0)
     301                layout->InvalidateLayoutsForView(fOwner);
     302            else if (BView::Private(ownerParent).MinMaxValid())
     303                ownerParent->InvalidateLayout(false);
     304        }
     305    }
    214306}
    215307
    216308
     309void
     310BLayout::RequireLayout()
     311{
     312    fState |= B_LAYOUT_REQUIRED;
     313}
     314
     315
     316bool
     317BLayout::IsValid()
     318{
     319    return (fState & B_LAYOUT_INVALID) == 0;
     320}
     321
     322
     323void
     324BLayout::DisableLayoutInvalidation()
     325{
     326    fInvalidationDisabled++;
     327}
     328
     329
     330void
     331BLayout::EnableLayoutInvalidation()
     332{
     333    if (fInvalidationDisabled > 0)
     334        fInvalidationDisabled--;
     335}
     336
     337
     338void
     339BLayout::LayoutItems(bool force)
     340{
     341    if ((fState & B_LAYOUT_NECESSARY) == 0 && !force)
     342        return;
     343
     344    if (Layout() && (Layout()->fState & B_LAYOUT_IN_PROGRESS) != 0)
     345        return; // wait for parent layout to lay us out.
     346
     347    if (fTarget && fTarget->LayoutContext())
     348        return;
     349
     350    BLayoutContext context;
     351    _LayoutWithinContext(force, &context);
     352}
     353
     354
     355void
     356BLayout::Relayout(bool immediate)
     357{
     358    if ((fState & B_RELAYOUT_NOT_OK) == 0 || immediate) {
     359        fState |= B_LAYOUT_REQUIRED;
     360        LayoutItems(false);
     361    }
     362}
     363
     364
     365   
     366void
     367BLayout::_LayoutWithinContext(bool force, BLayoutContext* context)
     368{
     369// printf("BLayout(%p)::_LayoutWithinContext(%i, %p), state %x, fContext %p\n",
     370// this, force, context, (unsigned int)fState, fContext);
     371
     372    if ((fState & B_LAYOUT_NECESSARY) == 0 && !force)
     373        return;
     374
     375    BLayoutContext* oldContext = fContext;
     376    fContext = context;
     377
     378    if (fOwner && fOwner->LayoutContext() != context) {
     379        // in this case, let our owner decide whether or not to have us
     380        // do our layout, if they do, we won't end up here again.
     381        fOwner->_Layout(force, context);
     382    } else {
     383        fState |= B_LAYOUT_IN_PROGRESS;
     384        DerivedLayoutItems();
     385        // we must ensure that all items are laid out, layouts with a view will
     386        // have their layout process triggered by their view, but nested
     387        // view-less layouts must have their layout triggered here (if it hasn't
     388        // already been triggered).
     389        int32 nestedLayoutCount = fNestedLayouts.CountItems();
     390        for (int32 i = 0; i < nestedLayoutCount; i++) {
     391            BLayout* layout = (BLayout*)fNestedLayouts.ItemAt(i);
     392            if ((layout->fState & B_LAYOUT_NECESSARY) != 0)
     393                layout->_LayoutWithinContext(force, context);
     394        }
     395        fState = B_LAYOUT_ALL_CLEAR;
     396    }
     397
     398    fContext = oldContext;
     399}
     400
     401
     402BRect
     403BLayout::LayoutArea()
     404{
     405    BRect area(Frame());
     406    if (fOwner)
     407        area.OffsetTo(B_ORIGIN);
     408    return area;
     409}
     410
     411
    217412status_t
    218413BLayout::Archive(BMessage* into, bool deep) const
    219414{
    220415    BArchiver archiver(into);
    221     status_t err = BArchivable::Archive(into, deep);
     416    status_t err = BLayoutItem::Archive(into, deep);
    222417
    223418    if (deep) {
    224419        int32 count = CountItems();
     
    242437BLayout::AllUnarchived(const BMessage* from)
    243438{
    244439    BUnarchiver unarchiver(from);
    245     status_t err = BArchivable::AllUnarchived(from);
     440    status_t err = BLayoutItem::AllUnarchived(from);
    246441    if (err != B_OK)
    247442        return err;
    248443
     
    304499
    305500
    306501void
    307 BLayout::SetView(BView* view)
     502BLayout::OwnerChanged(BView* was)
    308503{
    309     if (view != fView) {
    310         fView = NULL;
     504}
    311505
     506
     507void
     508BLayout::AttachedToLayout()
     509{
     510    if (!fOwner) {
     511        Layout()->fNestedLayouts.AddItem(this);
     512        SetTarget(Layout()->TargetView());
     513    }
     514}
     515
     516
     517void
     518BLayout::DetachedFromLayout(BLayout* from)
     519{
     520    if (!fOwner) {
     521        from->fNestedLayouts.RemoveItem(this);
     522        SetTarget(NULL);
     523    }
     524}
     525
     526
     527void
     528BLayout::AncestorVisibilityChanged(bool shown)
     529{
     530    if (fAncestorsVisible == shown)
     531        return;
     532
     533    fAncestorsVisible = shown;
     534    VisibilityChanged(shown);
     535}
     536
     537
     538void
     539BLayout::VisibilityChanged(bool show)
     540{
     541    if (fOwner)
     542        return;
     543
     544    for (int32 i = CountItems() - 1; i >= 0; i--)
     545        ItemAt(i)->AncestorVisibilityChanged(show);
     546}
     547
     548
     549void
     550BLayout::ResetLayoutInvalidation()
     551{
     552    fState &= ~B_LAYOUT_CACHE_INVALID;
     553}
     554
     555
     556BLayoutContext*
     557BLayout::LayoutContext()
     558{
     559    return fContext;
     560}
     561
     562
     563bool
     564BLayout::RemoveViewRecursive(BView* view)
     565{
     566    bool removed = RemoveView(view);
     567    for (int32 i = fNestedLayouts.CountItems() - 1; i >= 0; i--) {
     568        BLayout* nested = (BLayout*)fNestedLayouts.ItemAt(i);
     569        removed |= nested->RemoveViewRecursive(view);
     570    }
     571    return removed;
     572}
     573
     574
     575bool
     576BLayout::InvalidateLayoutsForView(BView* view)
     577{
     578    bool found = false;
     579    for (int32 i = fNestedLayouts.CountItems() - 1; i >= 0; i--) {
     580        BLayout* layout = (BLayout*)fNestedLayouts.ItemAt(i);
     581        found |= layout->InvalidateLayoutsForView(view);
     582    }
     583
     584    if (found)
     585        return found;
     586
     587    if (!InvalidationLegal())
     588        return false;
     589
     590    for (int32 i = CountItems() - 1; i >= 0; i--) {
     591        if (ItemAt(i)->View() == view) {
     592            InvalidateLayout();
     593            return true;
     594        }
     595    }
     596    return found;
     597}
     598
     599
     600bool
     601BLayout::InvalidationLegal()
     602{
     603    return fInvalidationDisabled <= 0
     604        && (fState & B_LAYOUT_INVALIDATION_ILLEGAL) == 0;
     605}
     606
     607
     608void
     609BLayout::SetOwner(BView* owner)
     610{
     611    if (fOwner == owner)
     612        return;
     613
     614    SetTarget(owner);
     615    swap(fOwner, owner);
     616
     617    OwnerChanged(owner);
     618        // call hook
     619}
     620
     621
     622void
     623BLayout::SetTarget(BView* target)
     624{
     625    if (fTarget != target) {
     626        fTarget = NULL;
     627            // only remove items, not views
     628
    312629        // remove and delete all items
    313630        for (int32 i = CountItems() - 1; i >= 0; i--)
    314631            delete RemoveItem(i);
    315632
    316         fView = view;
     633        fTarget = target;
    317634
    318635        InvalidateLayout();
    319636    }
  • src/kits/interface/ViewLayoutItem.cpp

     
    1111
    1212#include <Layout.h>
    1313#include <View.h>
     14#include <ViewPrivate.h>
    1415
    1516
    1617namespace {
     
    2021
    2122BViewLayoutItem::BViewLayoutItem(BView* view)
    2223    :
    23     fView(view)
     24    fView(view),
     25    fAncestorsVisible(true)
    2426{
    2527}
    2628
     
    2830BViewLayoutItem::BViewLayoutItem(BMessage* from)
    2931    :
    3032    BLayoutItem(BUnarchiver::PrepareArchive(from)),
    31     fView(NULL)
     33    fView(NULL),
     34    fAncestorsVisible(true)
    3235{
    3336    BUnarchiver unarchiver(from);
    3437    unarchiver.Finish(unarchiver.FindObject<BView>(kViewField, 0,
     
    100103bool
    101104BViewLayoutItem::IsVisible()
    102105{
    103     return !fView->IsHidden(fView);
     106    int16 showLevel = BView::Private(fView).ShowLevel();
     107    return showLevel - (fAncestorsVisible ? 0 : 1) <= 0;
    104108}
    105109
    106110
     
    154158
    155159
    156160void
    157 BViewLayoutItem::InvalidateLayout()
     161BViewLayoutItem::InvalidateLayout(bool children)
    158162{
    159     fView->InvalidateLayout();
     163    fView->InvalidateLayout(children);
    160164}
    161165
    162166
     167void
     168BViewLayoutItem::Relayout(bool immediate)
     169{
     170    if (immediate)
     171        fView->Layout(false);
     172    else
     173        fView->Relayout();
     174}
     175
     176
    163177status_t
    164178BViewLayoutItem::Archive(BMessage* into, bool deep) const
    165179{
     
    204218        return new(std::nothrow) BViewLayoutItem(from);
    205219    return NULL;
    206220}
     221
     222
     223void
     224BViewLayoutItem::AncestorVisibilityChanged(bool shown)
     225{
     226    if (fAncestorsVisible == shown)
     227        return;
     228
     229    fAncestorsVisible = shown;
     230    if (shown)
     231        fView->Show();
     232    if (!shown)
     233        fView->Hide();
     234}
     235
  • src/kits/interface/LayoutItem.cpp

     
    88
    99#include <Layout.h>
    1010#include <LayoutUtils.h>
     11#include <View.h>
    1112
     13#include <algorithm>
    1214
     15
    1316BLayoutItem::BLayoutItem()
    1417    :
    1518    fLayout(NULL),
     
    3033
    3134BLayoutItem::~BLayoutItem()
    3235{
     36    if (fLayout)
     37        fLayout->RemoveItem(this);
    3338}
    3439
    3540
     
    6469
    6570
    6671void
    67 BLayoutItem::InvalidateLayout()
     72BLayoutItem::InvalidateLayout(bool children)
    6873{
    6974    if (fLayout)
    70         fLayout->InvalidateLayout();
     75        fLayout->InvalidateLayout(children);
    7176}
    7277
    7378
     79void
     80BLayoutItem::Relayout(bool immediate)
     81{
     82    BView* view = View();
     83    if (view && !immediate)
     84        view->Relayout();
     85    else if (view && immediate)
     86        view->Layout(false);
     87}
     88
     89
    7490void*
    7591BLayoutItem::LayoutData() const
    7692{
     
    144160void
    145161BLayoutItem::SetLayout(BLayout* layout)
    146162{
    147     fLayout = layout;
     163    if (layout == fLayout)
     164        return;
     165
     166    std::swap(fLayout, layout);
     167    if (layout)
     168        DetachedFromLayout(layout);
     169       
     170    if (fLayout)
     171        AttachedToLayout();
    148172}
     173
     174
     175void
     176BLayoutItem::AttachedToLayout()
     177{
     178    // hook method
     179}
     180
     181
     182void
     183BLayoutItem::DetachedFromLayout(BLayout* oldLayout)
     184{
     185    // hook method
     186}
     187
     188
     189void
     190BLayoutItem::AncestorVisibilityChanged(bool shown)
     191{
     192    // hook method
     193}
     194
  • src/kits/interface/SplitLayout.h

     
    66#define _SPLIT_LAYOUT_H
    77
    88
    9 #include <Layout.h>
     9#include <AbstractLayout.h>
    1010#include <Point.h>
    1111
    1212
     
    2121using BPrivate::Layout::LayoutInfo;
    2222
    2323
    24 class BSplitLayout : public BLayout {
     24class BSplitLayout : public BAbstractLayout {
    2525public:
    2626                                BSplitLayout(enum orientation orientation,
    2727                                    float spacing = 0.0f);
     
    6666            void                SetCollapsible(int32 first, int32 last,
    6767                                    bool collapsible);
    6868
    69     virtual BSize               MinSize();
    70     virtual BSize               MaxSize();
    71     virtual BSize               PreferredSize();
    72     virtual BAlignment          Alignment();
     69    virtual BSize               BaseMinSize();
     70    virtual BSize               BaseMaxSize();
     71    virtual BSize               BasePreferredSize();
     72    virtual BAlignment          BaseAlignment();
    7373
    7474    virtual bool                HasHeightForWidth();
    7575    virtual void                GetHeightForWidth(float width, float* min,
    7676                                    float* max, float* preferred);
    7777
    78     virtual void                InvalidateLayout();
     78    virtual void                InvalidateLayout(bool children = false);
    7979
    80     virtual void                LayoutView();
     80    virtual void                DerivedLayoutItems();
    8181
    8282    // interface for BSplitView
    8383            BRect               SplitterItemFrame(int32 index) const;
     
    106106            class ValueRange;
    107107            class SplitterItem;
    108108
    109             void                _InvalidateLayout(bool invalidateView);
     109            void                _InvalidateLayout(bool invalidateView,
     110                                    bool children = false);
    110111            void                _InvalidateCachedHeightForWidth();
    111112
    112113            SplitterItem*       _SplitterItemAt(const BPoint& point,
  • src/kits/interface/GroupLayoutBuilder.cpp

     
    2828    _PushLayout(fRootLayout);
    2929}
    3030
    31 
    3231// constructor
    3332BGroupLayoutBuilder::BGroupLayoutBuilder(BGroupView* view)
    3433    : fRootLayout(view->GroupLayout())
     
    6463BView*
    6564BGroupLayoutBuilder::TopView() const
    6665{
    67     return TopLayout()->View();
     66    return TopLayout()->Owner();
    6867}
    6968
    7069// GetTopView
     
    7271BGroupLayoutBuilder::GetTopView(BView** _view)
    7372{
    7473    if (BGroupLayout* layout = TopLayout())
    75         *_view = layout->View();
     74        *_view = layout->Owner();
    7675    else
    7776        *_view = NULL;
    7877
     
    181180    return fRootLayout;
    182181}
    183182
    184 // cast operator BView*
    185 BGroupLayoutBuilder::operator BView*()
    186 {
    187     return fRootLayout->View();
    188 }
    189 
    190183// _PushLayout
    191184bool
    192185BGroupLayoutBuilder::_PushLayout(BGroupLayout* layout)
  • src/kits/interface/CardLayout.cpp

     
    1717
    1818BCardLayout::BCardLayout()
    1919    :
    20     BLayout(),
     20    BAbstractLayout(),
    2121    fMin(0, 0),
    2222    fMax(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED),
    2323    fPreferred(0, 0),
     
    2929
    3030BCardLayout::BCardLayout(BMessage* from)
    3131    :
    32     BLayout(BUnarchiver::PrepareArchive(from)),
     32    BAbstractLayout(BUnarchiver::PrepareArchive(from)),
    3333    fMin(0, 0),
    3434    fMax(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED),
    3535    fPreferred(0, 0),
     
    8383    if (fVisibleItem != NULL) {
    8484        fVisibleItem->SetVisible(true);
    8585
    86         LayoutView();
     86        Relayout();
    8787    }
    8888}
    8989
    9090
    9191BSize
    92 BCardLayout::MinSize()
     92BCardLayout::BaseMinSize()
    9393{
    9494    _ValidateMinMax();
    9595    return fMin;
     
    9797
    9898
    9999BSize
    100 BCardLayout::MaxSize()
     100BCardLayout::BaseMaxSize()
    101101{
    102102    _ValidateMinMax();
    103103    return fMax;
     
    105105
    106106
    107107BSize
    108 BCardLayout::PreferredSize()
     108BCardLayout::BasePreferredSize()
    109109{
    110110    _ValidateMinMax();
    111111    return fPreferred;
     
    113113
    114114
    115115BAlignment
    116 BCardLayout::Alignment()
     116BCardLayout::BaseAlignment()
    117117{
    118118    return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
    119119}
     
    174174
    175175
    176176void
    177 BCardLayout::InvalidateLayout()
     177BCardLayout::InvalidateLayout(bool children)
    178178{
    179     BLayout::InvalidateLayout();
     179    BLayout::InvalidateLayout(children);
    180180
    181181    fMinMaxValid = false;
    182182}
    183183
    184184
    185185void
    186 BCardLayout::LayoutView()
     186BCardLayout::DerivedLayoutItems()
    187187{
    188188    _ValidateMinMax();
    189189
    190     BSize size = View()->Bounds().Size();
    191     size.width = max_c(size.width, fMin.width);
    192     size.height = max_c(size.height, fMin.height);
     190    BSize size(LayoutArea().Size());
    193191
    194     if (fVisibleItem != NULL)
    195         fVisibleItem->AlignInFrame(BRect(0, 0, size.width, size.height));
     192    // this cannot be done when we are viewless, as our children
     193    // would not get cut off in the right place.
     194    if (Owner()) {
     195        size.width = max_c(size.width, fMin.width);
     196        size.height = max_c(size.height, fMin.height);
     197    }
     198 
     199    if (fVisibleItem != NULL)
     200        fVisibleItem->AlignInFrame(BRect(LayoutArea().LeftTop(), size));
    196201}
    197202
    198203
     
    200205BCardLayout::Archive(BMessage* into, bool deep) const
    201206{
    202207    BArchiver archiver(into);
    203     status_t err = BLayout::Archive(into, deep);
     208    status_t err = BAbstractLayout::Archive(into, deep);
    204209
    205210    if (err == B_OK && deep)
    206211        err = into->AddInt32(kVisibleItemField, IndexOfItem(fVisibleItem));
     
    292297    fPreferred.height = min_c(fPreferred.height, fMax.height);
    293298
    294299    fMinMaxValid = true;
    295 
    296     if (BView* view = View())
    297         view->ResetLayoutInvalidation();
     300    ResetLayoutInvalidation();
    298301}
  • src/kits/interface/Jamfile

     
    3131SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
    3232
    3333MergeObject <libbe>interface_kit.o :
     34    AbstractLayout.cpp
    3435    AbstractLayoutItem.cpp
    3536    AffineTransform.cpp
    3637    Alert.cpp
  • src/kits/interface/SplitLayout.cpp

     
    196196
    197197BSplitLayout::BSplitLayout(BMessage* from)
    198198    :
    199     BLayout(BUnarchiver::PrepareArchive(from)),
     199    BAbstractLayout(BUnarchiver::PrepareArchive(from)),
    200200    fSplitterItems(),
    201201    fVisibleItems(),
    202202    fMin(),
     
    340340BLayoutItem*
    341341BSplitLayout::AddView(BView* child)
    342342{
    343     return BLayout::AddView(child);
     343    return BAbstractLayout::AddView(child);
    344344}
    345345
    346346
    347347BLayoutItem*
    348348BSplitLayout::AddView(int32 index, BView* child)
    349349{
    350     return BLayout::AddView(index, child);
     350    return BAbstractLayout::AddView(index, child);
    351351}
    352352
    353353
     
    372372bool
    373373BSplitLayout::AddItem(BLayoutItem* item)
    374374{
    375     return BLayout::AddItem(item);
     375    return BAbstractLayout::AddItem(item);
    376376}
    377377
    378378
    379379bool
    380380BSplitLayout::AddItem(int32 index, BLayoutItem* item)
    381381{
    382     return BLayout::AddItem(index, item);
     382    return BAbstractLayout::AddItem(index, item);
    383383}
    384384
    385385
     
    480480
    481481
    482482BSize
    483 BSplitLayout::MinSize()
     483BSplitLayout::BaseMinSize()
    484484{
    485485    _ValidateMinMax();
    486486
     
    489489
    490490
    491491BSize
    492 BSplitLayout::MaxSize()
     492BSplitLayout::BaseMaxSize()
    493493{
    494494    _ValidateMinMax();
    495495
     
    498498
    499499
    500500BSize
    501 BSplitLayout::PreferredSize()
     501BSplitLayout::BasePreferredSize()
    502502{
    503503    _ValidateMinMax();
    504504
     
    507507
    508508
    509509BAlignment
    510 BSplitLayout::Alignment()
     510BSplitLayout::BaseAlignment()
    511511{
    512     return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
     512    return BAbstractLayout::BaseAlignment();
    513513}
    514514
    515515
     
    536536
    537537
    538538void
    539 BSplitLayout::InvalidateLayout()
     539BSplitLayout::InvalidateLayout(bool children)
    540540{
    541     _InvalidateLayout(true);
     541    _InvalidateLayout(true, children);
    542542}
    543543
    544544
    545545void
    546 BSplitLayout::LayoutView()
     546BSplitLayout::DerivedLayoutItems()
    547547{
    548548    _ValidateMinMax();
    549549
    550550    // layout the elements
    551     BSize size = _SubtractInsets(View()->Bounds().Size());
     551    BSize size = _SubtractInsets(LayoutArea().Size());
    552552    fHorizontalLayouter->Layout(fHorizontalLayoutInfo, size.width);
    553553
    554554    Layouter* verticalLayouter;
     
    647647        return false;
    648648
    649649    // Things shouldn't be draggable, if we have a >= max layout.
    650     BSize size = _SubtractInsets(View()->Frame().Size());
     650    BSize size = _SubtractInsets(LayoutArea().Size());
    651651    if ((fOrientation == B_HORIZONTAL && size.width >= fMax.width)
    652652        || (fOrientation == B_VERTICAL && size.height >= fMax.height)) {
    653653        return false;
     
    655655
    656656    int32 index = -1;
    657657    if (_SplitterItemAt(point, &index) != NULL) {
    658         fDraggingStartPoint = View()->ConvertToScreen(point);
     658        fDraggingStartPoint = Owner()->ConvertToScreen(point);
    659659        fDraggingStartValue = _SplitterValue(index);
    660660        fDraggingCurrentValue = fDraggingStartValue;
    661661        fDraggingSplitterIndex = index;
     
    673673    if (fDraggingSplitterIndex < 0)
    674674        return false;
    675675
    676     point = View()->ConvertToScreen(point);
     676    point = Owner()->ConvertToScreen(point);
    677677
    678678    int32 valueDiff;
    679679    if (fOrientation == B_HORIZONTAL)
     
    712712BSplitLayout::Archive(BMessage* into, bool deep) const
    713713{
    714714    BArchiver archiver(into);
    715     status_t err = BLayout::Archive(into, deep);
     715    status_t err = BAbstractLayout::Archive(into, deep);
    716716
    717717    if (err == B_OK)
    718718        err = into->AddBool(kIsVerticalField, fOrientation == B_VERTICAL);
     
    811811
    812812
    813813void
    814 BSplitLayout::_InvalidateLayout(bool invalidateView)
     814BSplitLayout::_InvalidateLayout(bool invalidateView, bool children)
    815815{
    816816    if (invalidateView)
    817         BLayout::InvalidateLayout();
     817        BAbstractLayout::InvalidateLayout(children);
    818818
    819819    delete fHorizontalLayouter;
    820820    delete fVerticalLayouter;
     
    929929    info->max = item->MaxSize();
    930930
    931931    if (item->HasHeightForWidth()) {
    932         BSize size = _SubtractInsets(View()->Frame().Size());
     932        BSize size = _SubtractInsets(LayoutArea().Size());
    933933        float minHeight, maxHeight;
    934934        item->GetHeightForWidth(size.width, &minHeight, &maxHeight, NULL);
    935935        info->min.height = max_c(info->min.height, minHeight);
     
    958958    item->AlignInFrame(info->layoutFrame);
    959959
    960960    // if the item became visible, we need to update its internal layout
    961     if (visibilityChanged) {
    962         if (BView* itemView = item->View())
    963             itemView->Layout(false);
     961    if (visibilityChanged && fOrientation != B_HORIZONTAL
     962        && !HasHeightForWidth()) {
     963        item->Relayout(true);
    964964    }
    965965}
    966966
     
    12161216    }
    12171217
    12181218    // Just updating the splitter weights is fine in principle. The next
    1219     // LayoutView() will use the correct values. But, if our orientation is
     1219    // LayoutItems() will use the correct values. But, if our orientation is
    12201220    // vertical, the cached height for width info needs to be flushed, or the
    12211221    // obsolete cached values will be used.
    12221222    if (fOrientation == B_VERTICAL)
     
    12931293    if (fHeightForWidthItems.IsEmpty())
    12941294        fVerticalLayoutInfo = fVerticalLayouter->CreateLayoutInfo();
    12951295
    1296     if (BView* view = View())
    1297         view->ResetLayoutInvalidation();
     1296    ResetLayoutInvalidation();
    12981297}
    12991298
    13001299
  • src/kits/interface/TwoDimensionalLayout.cpp

     
    258258
    259259BTwoDimensionalLayout::BTwoDimensionalLayout(BMessage* from)
    260260    :
    261     BLayout(from),
     261    BAbstractLayout(from),
    262262    fLeftInset(0),
    263263    fRightInset(0),
    264264    fTopInset(0),
     
    324324
    325325
    326326BSize
    327 BTwoDimensionalLayout::MinSize()
     327BTwoDimensionalLayout::BaseMinSize()
    328328{
    329329    _ValidateMinMax();
    330330    return AddInsets(fLocalLayouter->MinSize());
     
    332332
    333333
    334334BSize
    335 BTwoDimensionalLayout::MaxSize()
     335BTwoDimensionalLayout::BaseMaxSize()
    336336{
    337337    _ValidateMinMax();
    338338    return AddInsets(fLocalLayouter->MaxSize());
     
    340340
    341341
    342342BSize
    343 BTwoDimensionalLayout::PreferredSize()
     343BTwoDimensionalLayout::BasePreferredSize()
    344344{
    345345    _ValidateMinMax();
    346346    return AddInsets(fLocalLayouter->PreferredSize());
     
    348348
    349349
    350350BAlignment
    351 BTwoDimensionalLayout::Alignment()
     351BTwoDimensionalLayout::BaseAlignment()
    352352{
    353     return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
     353    return BAbstractLayout::BaseAlignment();
    354354}
    355355
    356356
     
    377377
    378378
    379379void
    380 BTwoDimensionalLayout::InvalidateLayout()
     380BTwoDimensionalLayout::SetFrame(BRect frame)
    381381{
    382     BLayout::InvalidateLayout();
    383 
    384     fLocalLayouter->InvalidateLayout();
     382    BAbstractLayout::SetFrame(frame);
    385383}
    386384
    387385
    388386void
    389 BTwoDimensionalLayout::LayoutView()
     387BTwoDimensionalLayout::InvalidateLayout(bool children)
    390388{
    391     _ValidateMinMax();
    392 
    393     // layout the horizontal/vertical elements
    394     BSize size = SubtractInsets(View()->Frame().Size());
    395 
    396 #ifdef DEBUG_LAYOUT
    397 printf("BTwoDimensionalLayout::LayoutView(%p): size: (%.1f, %.1f)\n",
    398 View(), size.width, size.height);
    399 #endif
    400 
    401     fLocalLayouter->Layout(size);
    402 
    403     // layout the items
    404     int itemCount = CountItems();
    405     for (int i = 0; i < itemCount; i++) {
    406         BLayoutItem* item = ItemAt(i);
    407         if (item->IsVisible()) {
    408             Dimensions itemDimensions;
    409             GetItemDimensions(item, &itemDimensions);
    410             BRect frame = fLocalLayouter->ItemFrame(itemDimensions);
    411             frame.left += fLeftInset;
    412             frame.top += fTopInset;
    413             frame.right += fLeftInset;
    414             frame.bottom += fTopInset;
    415 {
    416 #ifdef DEBUG_LAYOUT
    417 printf("  frame for item %2d (view: %p): ", i, item->View());
    418 frame.PrintToStream();
    419 #endif
    420 //BSize min(item->MinSize());
    421 //BSize max(item->MaxSize());
    422 //printf("    min: (%.1f, %.1f), max: (%.1f, %.1f)\n", min.width, min.height,
    423 //  max.width, max.height);
    424 //if (item->HasHeightForWidth()) {
    425 //float minHeight, maxHeight, preferredHeight;
    426 //item->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
    427 //  &preferredHeight);
    428 //printf("    hfw: min: %.1f, max: %.1f, pref: %.1f\n", minHeight, maxHeight,
    429 //  preferredHeight);
    430 //}
     389    BLayout::InvalidateLayout(children);
     390    fLocalLayouter->InvalidateLayout();
    431391}
    432392
    433             item->AlignInFrame(frame);
    434         }
    435 //else
    436 //printf("  item %2d not visible", i);
    437     }
    438 }
    439393
    440 
    441394status_t
    442395BTwoDimensionalLayout::Archive(BMessage* into, bool deep) const
    443396{
    444397    BArchiver archiver(into);
    445     status_t err = BLayout::Archive(into, deep);
     398    status_t err = BAbstractLayout::Archive(into, deep);
    446399
    447400    if (err == B_OK) {
    448401        BRect insets(fLeftInset, fTopInset, fRightInset, fBottomInset);
     
    487440}
    488441
    489442
     443void
     444BTwoDimensionalLayout::DerivedLayoutItems()
     445{
     446    _ValidateMinMax();
     447
     448    // layout the horizontal/vertical elements
     449    BSize size(SubtractInsets(LayoutArea().Size()));
     450
     451#ifdef DEBUG_LAYOUT
     452printf("BTwoDimensionalLayout::DerivedLayoutItems(): view: %p"
     453    " size: (%.1f, %.1f)\n", View(), size.Width(), size.Height());
     454#endif
     455
     456    fLocalLayouter->Layout(size);
     457
     458    // layout the items
     459    BPoint itemOffset(LayoutArea().LeftTop());
     460    int itemCount = CountItems();
     461    for (int i = 0; i < itemCount; i++) {
     462        BLayoutItem* item = ItemAt(i);
     463        if (item->IsVisible()) {
     464            Dimensions itemDimensions;
     465            GetItemDimensions(item, &itemDimensions);
     466            BRect frame = fLocalLayouter->ItemFrame(itemDimensions);
     467            frame.left += fLeftInset;
     468            frame.top += fTopInset;
     469            frame.right += fLeftInset;
     470            frame.bottom += fTopInset;
     471            frame.OffsetBy(itemOffset);
     472{
     473#ifdef DEBUG_LAYOUT
     474printf("  frame for item %2d (view: %p): ", i, item->View());
     475frame.PrintToStream();
     476#endif
     477//BSize min(item->MinSize());
     478//BSize max(item->MaxSize());
     479//printf("    min: (%.1f, %.1f), max: (%.1f, %.1f)\n", min.width, min.height,
     480//  max.width, max.height);
     481//if (item->HasHeightForWidth()) {
     482//float minHeight, maxHeight, preferredHeight;
     483//item->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
     484//  &preferredHeight);
     485//printf("    hfw: min: %.1f, max: %.1f, pref: %.1f\n", minHeight, maxHeight,
     486//  preferredHeight);
     487//}
     488}
     489
     490            item->AlignInFrame(frame);
     491        }
     492//else
     493//printf("  item %2d not visible", i);
     494    }
     495}
     496
     497
    490498BSize
    491499BTwoDimensionalLayout::AddInsets(BSize size)
    492500{
     
    547555BTwoDimensionalLayout::_ValidateMinMax()
    548556{
    549557    fLocalLayouter->ValidateMinMax();
    550 
    551     if (BView* view = View())
    552         view->ResetLayoutInvalidation();
    553558}
    554559
    555560
    556 BLayoutContext*
    557 BTwoDimensionalLayout::_CurrentLayoutContext()
    558 {
    559     BView* view = View();
    560     return (view ? view->LayoutContext() : NULL);
    561 }
    562 
    563 
    564561// #pragma mark - CompoundLayouter
    565562
    566563
     
    10601057BTwoDimensionalLayout::LocalLayouter::Layout(BSize size)
    10611058{
    10621059    DoHorizontalLayout(size.width);
    1063     fVLayouter->Layout(size.height, this, fLayout->_CurrentLayoutContext());
     1060    fVLayouter->Layout(size.height, this, fLayout->LayoutContext());
    10641061}
    10651062
    10661063
     
    10921089
    10931090    fHLayouter->ValidateMinMax();
    10941091    fVLayouter->ValidateMinMax();
     1092    fLayout->ResetLayoutInvalidation();
    10951093}
    10961094
    10971095
    10981096void
    10991097BTwoDimensionalLayout::LocalLayouter::DoHorizontalLayout(float width)
    11001098{
    1101     BLayoutContext* context = fLayout->_CurrentLayoutContext();
     1099    BLayoutContext* context = fLayout->LayoutContext();
    11021100    if (fHorizontalLayoutContext != context
    11031101            || width != fHorizontalLayoutWidth) {
    11041102        _SetHorizontalLayoutContext(context, width);
  • src/kits/interface/Window.cpp

     
    543543}
    544544
    545545
     546void
     547BWindow::AddChild(BLayoutItem* child)
     548{
     549    BAutolock locker(this);
     550    if (locker.IsLocked())
     551        fTopView->AddChild(child);
     552}
     553
     554
    546555bool
    547556BWindow::RemoveChild(BView* child)
    548557{
  • src/kits/interface/GridLayoutBuilder.cpp

     
    4545BView*
    4646BGridLayoutBuilder::View() const
    4747{
    48     return fLayout->View();
     48    return fLayout->Owner();
    4949}
    5050
    5151// GetGridLayout
     
    6060BGridLayoutBuilder&
    6161BGridLayoutBuilder::GetView(BView** _view)
    6262{
    63     *_view = fLayout->View();
     63    *_view = fLayout->Owner();
    6464    return *this;
    6565}
    6666
     
    112112    return fLayout;
    113113}
    114114
    115 // cast operator BView*
    116 BGridLayoutBuilder::operator BView*()
    117 {
    118     return fLayout->View();
    119 }
  • headers/os/interface/TwoDimensionalLayout.h

     
    66#define _TWO_DIMENSIONAL_LAYOUT_H
    77
    88
    9 #include <Layout.h>
     9#include <AbstractLayout.h>
    1010
    1111class BLayoutContext;
    1212
    1313
    14 class BTwoDimensionalLayout : public BLayout {
     14class BTwoDimensionalLayout : public BAbstractLayout {
    1515public:
    1616                                BTwoDimensionalLayout();
    1717                                BTwoDimensionalLayout(BMessage* from);
     
    2525            void                AlignLayoutWith(BTwoDimensionalLayout* other,
    2626                                    enum orientation orientation);
    2727
    28     virtual BSize               MinSize();
    29     virtual BSize               MaxSize();
    30     virtual BSize               PreferredSize();
    31     virtual BAlignment          Alignment();
     28    virtual BSize               BaseMinSize();
     29    virtual BSize               BaseMaxSize();
     30    virtual BSize               BasePreferredSize();
     31    virtual BAlignment          BaseAlignment();
    3232
    3333    virtual bool                HasHeightForWidth();
    3434    virtual void                GetHeightForWidth(float width, float* min,
    3535                                    float* max, float* preferred);
    3636
    37     virtual void                InvalidateLayout();
     37    virtual void                SetFrame(BRect frame);
    3838
    39     virtual void                LayoutView();
     39    virtual void                InvalidateLayout(bool children = false);
    4040
    4141    virtual status_t            Archive(BMessage* into, bool deep = true) const;
    4242    virtual status_t            AllArchived(BMessage* into) const;
     
    5656                int32   height;
    5757            };
    5858
     59    virtual void                DerivedLayoutItems();
     60
    5961            BSize               AddInsets(BSize size);
    6062            void                AddInsets(float* minHeight, float* maxHeight,
    6163                                    float* preferredHeight);
     
    8284            friend class LocalLayouter;
    8385
    8486            void                _ValidateMinMax();
    85             BLayoutContext*     _CurrentLayoutContext();
    8687
    8788protected:
    8889            float               fLeftInset;
  • headers/os/interface/Layout.h

     
    88
    99#include <Alignment.h>
    1010#include <Archivable.h>
     11#include <LayoutItem.h>
    1112#include <List.h>
    1213#include <Size.h>
    1314
    1415
     16class BLayoutContext;
    1517class BLayoutItem;
    1618class BView;
    1719
    1820
    19 class BLayout : public BArchivable {
     21class BLayout : public BLayoutItem {
    2022public:
    2123                                BLayout();
    2224                                BLayout(BMessage* archive);
    2325    virtual                     ~BLayout();
    2426
    25             BView*              View() const;
     27            BView*              Owner() const;
     28            BView*              TargetView() const;
     29    virtual BView*              View(); // from BLayoutItem
    2630
     31    // methods dealing with items
    2732    virtual BLayoutItem*        AddView(BView* child);
    2833    virtual BLayoutItem*        AddView(int32 index, BView* child);
    2934
     
    3944            int32               IndexOfItem(const BLayoutItem* item) const;
    4045            int32               IndexOfView(BView* child) const;
    4146
    42     virtual BSize               MinSize() = 0;
    43     virtual BSize               MaxSize() = 0;
    44     virtual BSize               PreferredSize() = 0;
    45     virtual BAlignment          Alignment() = 0;
     47            bool                AncestorsVisible();
    4648
    47     virtual bool                HasHeightForWidth() = 0;
    48     virtual void                GetHeightForWidth(float width, float* min,
    49                                     float* max, float* preferred) = 0;
     49    // Layouting related methods
    5050
    51     virtual void                InvalidateLayout();
     51    virtual void                InvalidateLayout(bool children = false);
     52    virtual void                Relayout(bool immediate = false);
     53            void                RequireLayout();
     54            bool                IsValid();
     55            void                EnableLayoutInvalidation();
     56            void                DisableLayoutInvalidation();
    5257
    53     virtual void                LayoutView() = 0;
     58            void                LayoutItems(bool force = false);
     59            BRect               LayoutArea();
     60            BLayoutContext*     LayoutContext();
    5461
     62    // Archiving methods
     63
    5564    virtual status_t            Archive(BMessage* into, bool deep = true) const;
    5665    virtual status_t            AllUnarchived(const BMessage* from);
    5766
     
    5968                                    int32 index) const;
    6069    virtual status_t            ItemUnarchived(const BMessage* from,
    6170                                    BLayoutItem* item, int32 index);
     71
    6272protected:
     73    // BLayout hook methods
    6374    virtual bool                ItemAdded(BLayoutItem* item, int32 atIndex);
    6475    virtual void                ItemRemoved(BLayoutItem* item, int32 fromIndex);
     76    virtual void                DerivedLayoutItems() = 0;
     77    virtual void                OwnerChanged(BView* was);
    6578
     79    // BLayoutItem hook methods
     80    virtual void                AttachedToLayout();
     81    virtual void                DetachedFromLayout(BLayout* layout);
     82    virtual void                AncestorVisibilityChanged(bool shown);
     83
     84    // To be called by sub-classes in SetVisible().
     85            void                VisibilityChanged(bool show);
     86    // To be called when layout data is known to be good
     87            void                ResetLayoutInvalidation();
     88
    6689private:
    6790            friend class BView;
    6891
    69             void                SetView(BView* view);
     92            bool                RemoveViewRecursive(BView* view);
     93            bool                InvalidateLayoutsForView(BView* view);
     94            bool                InvalidationLegal();
     95            void                SetOwner(BView* owner);
     96            void                SetTarget(BView* target);
    7097
    71             BView*              fView;
     98            void                _LayoutWithinContext(bool force,
     99                                    BLayoutContext* context);
     100
     101            uint32              fState;
     102            bool                fAncestorsVisible;
     103            int32               fInvalidationDisabled;
     104            BLayoutContext*     fContext;
     105            BView*              fOwner;
     106            BView*              fTarget;
    72107            BList               fItems;
     108            BList               fNestedLayouts;
    73109};
    74110
    75111
  • headers/os/interface/LayoutBuilder.h

     
    3333public:
    3434    inline  void                SetParent(ParentBuilder* parent);
    3535        // conceptually private
    36 
    3736    inline  ParentBuilder&      End();
    3837
    3938protected:
     
    7170
    7271    inline  GroupBuilder        AddGroup(enum orientation orientation,
    7372                                    float spacing = 0.0f, float weight = 1.0f);
     73    inline  GroupBuilder        AddGroup(BGroupView* groupView,
     74                                    float weight = 1.0f);
     75    inline  GroupBuilder        AddGroup(BGroupLayout* groupLayout,
     76                                    float weight = 1.0f);
     77
    7478    inline  GridBuilder         AddGrid(float horizontalSpacing = 0.0f,
    7579                                    float verticalSpacing = 0.0f,
    7680                                    float weight = 1.0f);
     81    inline  GridBuilder         AddGrid(BGridLayout* gridLayout,
     82                                    float weight = 1.0f);
     83    inline  GridBuilder         AddGrid(BGridView* gridView,
     84                                    float weight = 1.0f);
     85
    7786    inline  SplitBuilder        AddSplit(enum orientation orientation,
    7887                                    float spacing = 0.0f, float weight = 1.0f);
     88    inline  SplitBuilder        AddSplit(BSplitView* splitView,
     89                                    float weight = 1.0f);
    7990
    8091    inline  ThisBuilder&        AddGlue(float weight = 1.0f);
    8192    inline  ThisBuilder&        AddStrut(float size);
     
    8495                                    float bottom);
    8596
    8697    inline                      operator BGroupLayout*();
    87     inline                      operator BView*();
    8898
    8999private:
    90100            BGroupLayout*       fLayout;
     
    131141    inline  GroupBuilder        AddGroup(enum orientation orientation,
    132142                                    float spacing, int32 column, int32 row,
    133143                                    int32 columnCount = 1, int32 rowCount = 1);
     144    inline  GroupBuilder        AddGroup(BGroupView* groupView, int32 column,
     145                                    int32 row, int32 columnCount = 1,
     146                                    int32 rowCount = 1);
     147    inline  GroupBuilder        AddGroup(BGroupLayout* groupLayout,
     148                                    int32 column, int32 row,
     149                                    int32 columnCount = 1, int32 rowCount = 1);
     150
    134151    inline  GridBuilder         AddGrid(float horizontalSpacing,
    135152                                    float verticalSpacing, int32 column,
    136153                                    int32 row, int32 columnCount = 1,
    137154                                    int32 rowCount = 1);
     155    inline  GridBuilder         AddGrid(BGridLayout* gridLayout,
     156                                    int32 column, int32 row,
     157                                    int32 columnCount = 1, int32 rowCount = 1);
     158    inline  GridBuilder         AddGrid(BGridView* gridView,
     159                                    int32 column, int32 row,
     160                                    int32 columnCount = 1, int32 rowCount = 1);
     161
    138162    inline  SplitBuilder        AddSplit(enum orientation orientation,
    139163                                    float spacing, int32 column, int32 row,
    140164                                    int32 columnCount = 1, int32 rowCount = 1);
     165    inline  SplitBuilder        AddSplit(BSplitView* splitView, int32 column,
     166                                    int32 row, int32 columnCount = 1,
     167                                    int32 rowCount = 1);
    141168
    142169    inline  ThisBuilder&        SetColumnWeight(int32 column, float weight);
    143170    inline  ThisBuilder&        SetRowWeight(int32 row, float weight);
     
    146173                                    float bottom);
    147174
    148175    inline                      operator BGridLayout*();
    149     inline                      operator BView*();
    150176
    151177private:
    152178            BGridLayout*        fLayout;
     
    168194    inline                      Split(BSplitView* view);
    169195
    170196    inline  BSplitView*         View() const;
    171     inline  ThisBuilder&        GetView(BSplitView** _view);
     197    inline  ThisBuilder&        GetView(BView** _view);
     198    inline  ThisBuilder&        GetSplitView(BSplitView** _view);
    172199
    173200    inline  ThisBuilder&        Add(BView* view);
    174201    inline  ThisBuilder&        Add(BView* view, float weight);
     
    177204
    178205    inline  GroupBuilder        AddGroup(enum orientation orientation,
    179206                                    float spacing = 0.0f, float weight = 1.0f);
     207    inline  GroupBuilder        AddGroup(BGroupView* groupView,
     208                                    float weight = 1.0f);
     209    inline  GroupBuilder        AddGroup(BGroupLayout* groupLayout,
     210                                    float weight = 1.0f);
     211
    180212    inline  GridBuilder         AddGrid(float horizontalSpacing = 0.0f,
    181213                                    float verticalSpacing = 0.0f,
    182214                                    float weight = 1.0f);
     215    inline  GridBuilder         AddGrid(BGridView* gridView,
     216                                    float weight = 1.0f);
     217    inline  GridBuilder         AddGrid(BGridLayout* gridLayout,
     218                                    float weight = 1.0f);
     219
    183220    inline  SplitBuilder        AddSplit(enum orientation orientation,
    184221                                    float spacing = 0.0f, float weight = 1.0f);
     222    inline  SplitBuilder        AddSplit(BSplitView* splitView,
     223                                    float weight = 1.0f);
    185224
    186225    inline  ThisBuilder&        SetCollapsible(bool collapsible);
    187226    inline  ThisBuilder&        SetCollapsible(int32 index, bool collapsible);
     
    244283{
    245284    window->SetLayout(fLayout);
    246285
    247     fLayout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
     286    fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    248287        // TODO: we get a white background if we don't do this
    249288}
    250289
     
    277316BView*
    278317Group<ParentBuilder>::View() const
    279318{
    280     return fLayout->View();
     319    return fLayout->Owner();
    281320}
    282321
    283322
     
    294333typename Group<ParentBuilder>::ThisBuilder&
    295334Group<ParentBuilder>::GetView(BView** _view)
    296335{
    297     *_view = fLayout->View();
     336    *_view = fLayout->Owner();
    298337    return *this;
    299338}
    300339
     
    340379Group<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
    341380    float weight)
    342381{
    343     GroupBuilder builder(orientation, spacing);
     382    GroupBuilder builder(new BGroupLayout(orientation, spacing));
    344383    builder.SetParent(this);
    345     fLayout->AddView(builder.View(), weight);
     384    fLayout->AddItem(builder.Layout(), weight);
    346385    return builder;
    347386}
    348387
    349388
    350389template<typename ParentBuilder>
     390typename Group<ParentBuilder>::GroupBuilder
     391Group<ParentBuilder>::AddGroup(BGroupView* groupView, float weight)
     392{
     393    GroupBuilder builder(groupView);
     394    builder.SetParent(this);
     395    fLayout->AddItem(builder.Layout(), weight);
     396    return builder;
     397}
     398
     399
     400template<typename ParentBuilder>
     401typename Group<ParentBuilder>::GroupBuilder
     402Group<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, float weight)
     403{
     404    GroupBuilder builder(groupLayout);
     405    builder.SetParent(this);
     406    fLayout->AddItem(builder.Layout(), weight);
     407    return builder;
     408}
     409
     410
     411template<typename ParentBuilder>
    351412typename Group<ParentBuilder>::GridBuilder
    352 Group<ParentBuilder>::AddGrid(float horizontalSpacing, float verticalSpacing,
    353     float weight)
     413Group<ParentBuilder>::AddGrid(float horizontalSpacing,
     414    float verticalSpacing, float weight)
    354415{
    355     GridBuilder builder(horizontalSpacing, verticalSpacing);
     416    GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
    356417    builder.SetParent(this);
    357     fLayout->AddView(builder.View(), weight);
     418    fLayout->AddItem(builder.Layout(), weight);
    358419    return builder;
    359420}
    360421
    361422
    362423template<typename ParentBuilder>
     424typename Group<ParentBuilder>::GridBuilder
     425Group<ParentBuilder>::AddGrid(BGridLayout* gridLayout, float weight)
     426{
     427    GridBuilder builder(gridLayout);
     428    builder.SetParent(this);
     429    fLayout->AddItem(builder.Layout(), weight);
     430    return builder;
     431}
     432
     433
     434template<typename ParentBuilder>
     435typename Group<ParentBuilder>::GridBuilder
     436Group<ParentBuilder>::AddGrid(BGridView* gridView, float weight)
     437{
     438    GridBuilder builder(gridView);
     439    builder.SetParent(this);
     440    fLayout->AddItem(builder.Layout(), weight);
     441    return builder;
     442}
     443
     444
     445template<typename ParentBuilder>
    363446typename Group<ParentBuilder>::SplitBuilder
    364447Group<ParentBuilder>::AddSplit(enum orientation orientation, float spacing,
    365448    float weight)
     
    372455
    373456
    374457template<typename ParentBuilder>
     458typename Group<ParentBuilder>::SplitBuilder
     459Group<ParentBuilder>::AddSplit(BSplitView* splitView, float weight)
     460{
     461    SplitBuilder builder(splitView);
     462    builder.SetParent(this);
     463    fLayout->AddView(builder.View(), weight);
     464    return builder;
     465}
     466
     467
     468template<typename ParentBuilder>
    375469typename Group<ParentBuilder>::ThisBuilder&
    376470Group<ParentBuilder>::AddGlue(float weight)
    377471{
     
    410504}
    411505
    412506
    413 template<typename ParentBuilder>
    414 Group<ParentBuilder>::operator BView*()
    415 {
    416     return fLayout->View();
    417 }
    418 
    419 
    420507// #pragma mark - Grid
    421508
    422509
     
    436523{
    437524    window->SetLayout(fLayout);
    438525
    439     fLayout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
     526    fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    440527        // TODO: we get a white background if we don't do this
    441528}
    442529
     
    469556BView*
    470557Grid<ParentBuilder>::View() const
    471558{
    472     return fLayout->View();
     559    return fLayout->Owner();
    473560}
    474561
    475562
     
    486573typename Grid<ParentBuilder>::ThisBuilder&
    487574Grid<ParentBuilder>::GetView(BView** _view)
    488575{
    489     *_view = fLayout->View();
     576    *_view = fLayout->Owner();
    490577    return *this;
    491578}
    492579
     
    546633Grid<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
    547634    int32 column, int32 row, int32 columnCount, int32 rowCount)
    548635{
    549     GroupBuilder builder(orientation, spacing);
     636    GroupBuilder builder(new BGroupLayout(orientation, spacing));
    550637    builder.SetParent(this);
    551     fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
     638    fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
    552639    return builder;
    553640}
    554641
    555642
    556643template<typename ParentBuilder>
     644typename Grid<ParentBuilder>::GroupBuilder
     645Grid<ParentBuilder>::AddGroup(BGroupView* groupView, int32 column, int32 row,
     646    int32 columnCount, int32 rowCount)
     647{
     648    GroupBuilder builder(groupView);
     649    builder.SetParent(this);
     650    fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
     651    return builder;
     652}
     653
     654
     655template<typename ParentBuilder>
     656typename Grid<ParentBuilder>::GroupBuilder
     657Grid<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, int32 column,
     658    int32 row, int32 columnCount, int32 rowCount)
     659{
     660    GroupBuilder builder(groupLayout);
     661    builder.SetParent(this);
     662    fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
     663    return builder;
     664}
     665
     666
     667template<typename ParentBuilder>
    557668typename Grid<ParentBuilder>::GridBuilder
    558669Grid<ParentBuilder>::AddGrid(float horizontalSpacing, float verticalSpacing,
    559670    int32 column, int32 row, int32 columnCount, int32 rowCount)
    560671{
    561     GridBuilder builder(horizontalSpacing, verticalSpacing);
     672    GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
    562673    builder.SetParent(this);
     674    fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
     675    return builder;
     676}
     677
     678
     679template<typename ParentBuilder>
     680typename Grid<ParentBuilder>::GridBuilder
     681Grid<ParentBuilder>::AddGrid(BGridView* gridView, int32 column, int32 row,
     682    int32 columnCount, int32 rowCount)
     683{
     684    GridBuilder builder(gridView);
     685    builder.SetParent(this);
    563686    fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
    564687    return builder;
    565688}
     
    574697    builder.SetParent(this);
    575698    fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
    576699    return builder;
    577 }
     700} 
    578701
    579702
    580703template<typename ParentBuilder>
     704typename Grid<ParentBuilder>::SplitBuilder
     705Grid<ParentBuilder>::AddSplit(BSplitView* splitView, int32 column, int32 row,
     706    int32 columnCount, int32 rowCount)
     707{
     708    SplitBuilder builder(splitView);
     709    builder.SetParent(this);
     710    fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
     711    return builder;
     712}
     713
     714
     715template<typename ParentBuilder>
    581716typename Grid<ParentBuilder>::ThisBuilder&
    582717Grid<ParentBuilder>::SetColumnWeight(int32 column, float weight)
    583718{
     
    612747}
    613748
    614749
    615 template<typename ParentBuilder>
    616 Grid<ParentBuilder>::operator BView*()
    617 {
    618     return fLayout->View();
    619 }
    620 
    621 
    622750// #pragma mark - Split
    623751
    624752
     
    648776
    649777template<typename ParentBuilder>
    650778typename Split<ParentBuilder>::ThisBuilder&
    651 Split<ParentBuilder>::GetView(BSplitView** _view)
     779Split<ParentBuilder>::GetView(BView** _view)
    652780{
    653781    *_view = fView;
    654782    return *this;
     
    657785
    658786template<typename ParentBuilder>
    659787typename Split<ParentBuilder>::ThisBuilder&
     788Split<ParentBuilder>::GetSplitView(BSplitView** _view)
     789{
     790    *_view = fView;
     791    return *this;
     792}
     793
     794
     795template<typename ParentBuilder>
     796typename Split<ParentBuilder>::ThisBuilder&
    660797Split<ParentBuilder>::Add(BView* view)
    661798{
    662799    fView->AddChild(view);
     
    696833Split<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
    697834    float weight)
    698835{
    699     GroupBuilder builder(orientation, spacing);
     836    GroupBuilder builder(new BGroupLayout(orientation, spacing));
    700837    builder.SetParent(this);
    701     fView->AddChild(builder.View(), weight);
     838    fView->AddChild(builder.Layout(), weight);
    702839    return builder;
    703840}
    704841
    705842
    706843template<typename ParentBuilder>
     844typename Split<ParentBuilder>::GroupBuilder
     845Split<ParentBuilder>::AddGroup(BGroupView* groupView, float weight)
     846{
     847    GroupBuilder builder(groupView);
     848    builder.SetParent(this);
     849    fView->AddChild(builder.Layout(), weight);
     850    return builder;
     851}
     852
     853
     854template<typename ParentBuilder>
     855typename Split<ParentBuilder>::GroupBuilder
     856Split<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, float weight)
     857{
     858    GroupBuilder builder(groupLayout);
     859    builder.SetParent(this);
     860    fView->AddChild(builder.Layout(), weight);
     861    return builder;
     862}
     863
     864
     865template<typename ParentBuilder>
    707866typename Split<ParentBuilder>::GridBuilder
    708867Split<ParentBuilder>::AddGrid(float horizontalSpacing, float verticalSpacing,
    709868    float weight)
    710869{
    711     GridBuilder builder(horizontalSpacing, verticalSpacing);
     870    GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
    712871    builder.SetParent(this);
    713     fView->AddChild(builder.View(), weight);
     872    fView->AddChild(builder.Layout(), weight);
    714873    return builder;
    715874}
    716875
    717876
    718877template<typename ParentBuilder>
     878typename Split<ParentBuilder>::GridBuilder
     879Split<ParentBuilder>::AddGrid(BGridView* gridView, float weight)
     880{
     881    GridBuilder builder(gridView);
     882    builder.SetParent(this);
     883    fView->AddChild(builder.Layout(), weight);
     884    return builder;
     885}
     886
     887
     888template<typename ParentBuilder>
     889typename Split<ParentBuilder>::GridBuilder
     890Split<ParentBuilder>::AddGrid(BGridLayout* layout, float weight)
     891{
     892    GridBuilder builder(layout);
     893    builder.SetParent(this);
     894    fView->AddChild(builder.Layout(), weight);
     895    return builder;
     896}
     897
     898
     899template<typename ParentBuilder>
    719900typename Split<ParentBuilder>::SplitBuilder
    720901Split<ParentBuilder>::AddSplit(enum orientation orientation, float spacing,
    721902    float weight)
  • headers/os/interface/GridLayoutBuilder.h

     
    1616                                BGridLayoutBuilder(BGridView* view);
    1717
    1818            BGridLayout*        GridLayout() const;
    19             BView*              View() const;
    2019            BGridLayoutBuilder& GetGridLayout(BGridLayout** _layout);
    21             BGridLayoutBuilder& GetView(BView** _view);
     20            BView*              View() const;
     21            BGridLayoutBuilder& GetView(BView** _view);
    2222
    2323            BGridLayoutBuilder& Add(BView* view, int32 column, int32 row,
    2424                                    int32 columnCount = 1, int32 rowCount = 1);
     
    3232                                    float bottom);
    3333
    3434                                operator BGridLayout*();
    35                                 operator BView*();
    3635
    3736private:
    3837            BGridLayout*        fLayout;
  • headers/os/interface/GroupLayoutBuilder.h

     
    11/*
    2  * Copyright 2006, Haiku, Inc. All rights reserved.
     2 * Copyright 2006-2010, Haiku, Inc. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 */
    55#ifndef _GROUP_LAYOUT_BUILDER_H
     
    3939                                    float bottom);
    4040
    4141                                operator BGroupLayout*();
    42                                 operator BView*();
    4342
    4443private:
    4544            bool                _PushLayout(BGroupLayout* layout);
  • headers/os/interface/CardLayout.h

     
    55#ifndef _CARD_LAYOUT_H
    66#define _CARD_LAYOUT_H
    77
    8 #include <Layout.h>
     8#include <AbstractLayout.h>
    99
    1010
    11 class BCardLayout : public BLayout {
     11class BCardLayout : public BAbstractLayout {
    1212public:
    1313                                BCardLayout();
    1414                                BCardLayout(BMessage* from);
     
    1919            void                SetVisibleItem(int32 index);
    2020            void                SetVisibleItem(BLayoutItem* item);
    2121
    22     virtual BSize               MinSize();
    23     virtual BSize               MaxSize();
    24     virtual BSize               PreferredSize();
    25     virtual BAlignment          Alignment();
     22    virtual BSize               BaseMinSize();
     23    virtual BSize               BaseMaxSize();
     24    virtual BSize               BasePreferredSize();
     25    virtual BAlignment          BaseAlignment();
    2626
    2727    virtual bool                HasHeightForWidth();
    2828    virtual void                GetHeightForWidth(float width, float* min,
    2929                                    float* max, float* preferred);
    3030
    31     virtual void                InvalidateLayout();
    32     virtual void                LayoutView();
     31    virtual void                InvalidateLayout(bool children = false);
    3332
    3433    virtual status_t            Archive(BMessage* into, bool deep = true) const;
    3534    virtual status_t            AllUnarchived(const BMessage* from);
    3635    static  BArchivable*        Instantiate(BMessage* from);
    3736
    3837protected:
     38    virtual void                DerivedLayoutItems();
    3939    virtual bool                ItemAdded(BLayoutItem* item, int32 atIndex);
    4040    virtual void                ItemRemoved(BLayoutItem* item, int32 fromIndex);
    4141
  • headers/os/interface/Window.h

     
    103103            void                Close() { Quit(); }
    104104
    105105            void                AddChild(BView* child, BView* before = NULL);
     106            void                AddChild(BLayoutItem* child);
    106107            bool                RemoveChild(BView* child);
    107108            int32               CountChildren() const;
    108109            BView*              ChildAt(int32 index) const;
  • headers/os/interface/View.h

     
    562562            void                Layout(bool force);
    563563            void                Relayout();
    564564
     565    class Private;
     566
    565567protected:
    566568    virtual void                DoLayout();
    567569
     
    580582
    581583private:
    582584            void                _Layout(bool force, BLayoutContext* context);
     585            void                _LayoutLeft(BLayout* deleted);
     586            void                _InvalidateParentLayout();
    583587
    584588private:
    585589    // FBC padding and forbidden methods
     
    595599private:
    596600    struct LayoutData;
    597601
     602    friend class Private;
    598603    friend class BBitmap;
    599604    friend class BLayout;
    600605    friend class BPrintJob;
  • headers/os/interface/LayoutItem.h

     
    1616class BView;
    1717
    1818
    19 class BLayoutItem: public BArchivable {
     19class BLayoutItem : public BArchivable {
    2020public:
    2121                                BLayoutItem();
    2222                                BLayoutItem(BMessage* from);
     
    4646
    4747    virtual BView*              View();
    4848
    49     virtual void                InvalidateLayout();
     49    virtual void                InvalidateLayout(bool children = false);
     50    virtual void                Relayout(bool immediate = false);
    5051
    5152            void*               LayoutData() const;
    5253            void                SetLayoutData(void* data);
     
    5758    virtual status_t            AllArchived(BMessage* into) const;
    5859    virtual status_t            AllUnarchived(const BMessage* from);
    5960
     61protected:
     62
     63            void                SetLayout(BLayout* layout);
     64
     65    // hook methods
     66    virtual void                AttachedToLayout();
     67    virtual void                DetachedFromLayout(BLayout* layout);
     68
     69    virtual void                AncestorVisibilityChanged(bool shown);
     70
    6071private:
    6172            friend class BLayout;
    6273
    63             void                SetLayout(BLayout* layout);
    64 
    6574            BLayout*            fLayout;
    6675            void*               fLayoutData;
    6776};
  • headers/os/interface/AbstractLayout.h

     
     1/*
     2 * Copyright 2010, Haiku, Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _ABSTRACT_LAYOUT_H
     6#define _ABSTRACT_LAYOUT_H
     7
     8#include <Alignment.h>
     9#include <Layout.h>
     10#include <Size.h>
     11
     12class BAbstractLayout : public BLayout {
     13public:
     14                                BAbstractLayout();
     15                                BAbstractLayout(BMessage* from);
     16    virtual                     ~BAbstractLayout();
     17
     18    virtual BSize               MinSize();
     19    virtual BSize               MaxSize();
     20    virtual BSize               PreferredSize();
     21    virtual BAlignment          Alignment();
     22
     23    virtual void                SetExplicitMinSize(BSize size);
     24    virtual void                SetExplicitMaxSize(BSize size);
     25    virtual void                SetExplicitPreferredSize(BSize size);
     26    virtual void                SetExplicitAlignment(BAlignment alignment);
     27
     28    virtual BSize               BaseMinSize();
     29    virtual BSize               BaseMaxSize();
     30    virtual BSize               BasePreferredSize();
     31    virtual BAlignment          BaseAlignment();
     32
     33    virtual BRect               Frame();
     34    virtual void                SetFrame(BRect frame); 
     35
     36    virtual bool                IsVisible();
     37    virtual void                SetVisible(bool visible);
     38
     39    virtual status_t            Archive(BMessage* into, bool deep = true) const;
     40    virtual status_t            AllUnarchived(const BMessage* from);
     41
     42protected:
     43    virtual void                OwnerChanged(BView* was);
     44    virtual void                AncestorVisibilityChanged(bool shown);
     45
     46private:
     47            struct  Proxy;
     48            struct  ViewProxy;
     49            struct  DataProxy;
     50
     51            Proxy*              fExplicitData;
     52};
     53
     54#endif  //  _ABSTRACT_LAYOUT_ITEM_H
  • headers/libs/alm/BALMLayout.h

     
    77#ifndef BALM_LAYOUT_H
    88#define BALM_LAYOUT_H
    99
     10#include <AbstractLayout.h>
    1011#include <File.h>
    11 #include <Layout.h>
    1212#include <List.h>
    1313#include <Size.h>
    1414#include <SupportDefs.h>
     
    2929/**
    3030 * A GUI layout engine using the ALM.
    3131 */
    32 class BALMLayout : public BLayout, public LinearSpec {
     32class BALMLayout : public BAbstractLayout, public LinearSpec {
    3333       
    3434public:
    3535                        BALMLayout();
     
    7070    bool                RemoveItem(BLayoutItem* item);
    7171    BLayoutItem*        RemoveItem(int32 index);
    7272
    73     BSize               MinSize();
    74     BSize               MaxSize();
    75     BSize               PreferredSize();
    76     BAlignment          Alignment();
     73    BSize               BaseMinSize();
     74    BSize               BaseMaxSize();
     75    BSize               BasePreferredSize();
     76    BAlignment          BaseAlignment();
    7777    bool                HasHeightForWidth();
    7878    void                GetHeightForWidth(float width, float* min,
    7979                                float* max, float* preferred);
    80     void                InvalidateLayout();
    81     void                LayoutView();
     80    void                InvalidateLayout(bool children = false);
     81    virtual void        DerivedLayoutItems();
    8282   
    8383    char*               PerformancePath() const;
    8484    void                SetPerformancePath(char* path);
  • headers/private/interface/ViewPrivate.h

     
    1616#include <Rect.h>
    1717#include <Region.h>
    1818#include <ServerProtocolStructs.h>
     19#include <View.h>
    1920
    2021const static uint32 kDeleteReplicant = 'JAHA';
    2122
     
    4849};
    4950
    5051
     52class BView::Private {
     53public:
     54    Private(BView* view)
     55        :
     56        fView(view)
     57    {
     58    }
     59
     60    int16 ShowLevel()
     61    {
     62        return fView->fShowLevel;
     63    }
     64
     65    bool MinMaxValid();
     66
     67    BView* fView;
     68};
     69
     70
    5171namespace BPrivate {
    5272
    5373class PortLink;