Ticket #7177: Deskbar Disable Expand Options 1.diff

File Deskbar Disable Expand Options 1.diff, 3.0 KB (added by jscipione, 10 years ago)

Simplify conditional

  • src/apps/deskbar/BarApp.cpp

    diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
    index 532e1bc..2647068 100644
    a b TBarApp::MessageReceived(BMessage* message)  
    334334            ShowPreferencesWindow();
    335335            break;
    336336
     337        case kStateChanged:
     338            fPreferencesWindow->PostMessage(kStateChanged);
     339            break;
     340
    337341        case kShowBeMenu:
    338342            if (fBarWindow->Lock()) {
    339343                fBarWindow->ShowBeMenu();
  • src/apps/deskbar/BarView.cpp

    diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
    index f113e6a..70971c5 100644
    a b void  
    130130TBarView::Draw(BRect)
    131131{
    132132    BRect bounds(Bounds());
    133    
     133
    134134    rgb_color hilite = tint_color(ViewColor(), B_DARKEN_1_TINT);
    135135    rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT);
    136    
     136
    137137    SetHighColor(hilite);
    138138    if (AcrossTop())
    139139        StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
    TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)  
    433433{
    434434    bool vertSwap = (fVertical != vertical);
    435435    bool leftSwap = (fLeft != left);
     436    bool stateChanged = (fState != state);
    436437
    437438    fState = state;
    438439    fVertical = vertical;
    439440    fLeft = left;
    440441    fTop = top;
    441442
     443    // Send a message to the preferences window to let it know to enable
     444    // or disabled preference items
     445    if (stateChanged || vertSwap) {
     446        BMessage message(kStateChanged);
     447        be_app->PostMessage(&message);
     448    }
     449
    442450    BRect screenFrame = (BScreen(Window())).Frame();
    443451
    444452    PlaceBeMenu();
  • src/apps/deskbar/PreferencesWindow.cpp

    diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
    index e8fdf07..aecbba7 100644
    a b PreferencesWindow::MessageReceived(BMessage* message)  
    242242            be_app->PostMessage(message);
    243243            break;
    244244
     245        case kStateChanged:
     246            _EnableDisableDependentItems();
     247            break;
     248
    245249        default:
    246250            BWindow::MessageReceived(message);
    247251            break;
    PreferencesWindow::_UpdateRecentCounts()  
    275279void
    276280PreferencesWindow::_EnableDisableDependentItems()
    277281{
    278     if (fAppsShowExpanders->Value())
    279         fAppsExpandNew->SetEnabled(true);
    280     else
     282    TBarApp* barApp = static_cast<TBarApp*>(be_app);
     283    if (barApp->BarView()->Vertical()
     284        && barApp->BarView()->Expando()) {
     285        fAppsShowExpanders->SetEnabled(true);
     286        fAppsExpandNew->SetEnabled(fAppsShowExpanders->Value());
     287    } else {
     288        fAppsShowExpanders->SetEnabled(false);
    281289        fAppsExpandNew->SetEnabled(false);
     290    }
    282291
    283292    if (fMenuRecentDocuments->Value())
    284293        fMenuRecentDocumentCount->SetEnabled(true);
  • src/apps/deskbar/PreferencesWindow.h

    diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h
    index 77f641b..9bacafd 100644
    a b const uint32 kConfigShow = 'show';  
    1919const uint32 kConfigClose = 'canc';
    2020const uint32 kUpdateRecentCounts = 'upct';
    2121const uint32 kEditMenuInTracker = 'mtrk';
     22const uint32 kStateChanged = 'stch';
    2223
    2324
    2425class PreferencesWindow : public BWindow