Ticket #4146: magnify.diff

File magnify.diff, 2.2 KB (added by negusnyul, 13 years ago)
  • src/apps/magnify/Magnify.h

     
    169169        void            AddMenu();
    170170        void            SetMagView(TMagnify* magView);
    171171
     172        char            fInfoStr[64];
     173        char            fRGBStr[64];
     174        char            fCH1Str[64];
     175        char            fCH2Str[64];
     176
    172177    private:
    173178        float           fFontHeight;
    174179        TMagnify*       fMagView;
     
    183188
    184189        BPoint          fCH1Loc;
    185190        BPoint          fCH2Loc;
    186 
    187         char            fInfoStr[64];
    188         char            fRGBStr[64];
    189         char            fCH1Str[64];
    190         char            fCH2Str[64];
    191191};
    192192
    193193class TWindow : public BWindow {
     
    219219        void            ShowInfo(bool);
    220220        bool            InfoIsShowing();
    221221        void            UpdateInfo();
     222        void            UpdateInfoBarOnResize();
    222223
    223224        void            AddCrossHair();
    224225        void            RemoveCrossHair();
     
    240241        float           fFontHeight;
    241242
    242243        bool            fShowGrid;
     244        bool            fInfoBarState;
    243245
    244246        int32           fHPixelCount;
    245247        int32           fVPixelCount;
  • src/apps/magnify/Magnify.cpp

     
    277277            break;
    278278
    279279        case msg_show_info:
    280             if (active)
     280            if (active) {
     281                fInfoBarState = !fInfoBarState;
    281282                ShowInfo(!fShowInfo);
     283            }
    282284            break;
    283285
    284286        case msg_toggle_grid:
     
    466468DONE:
    467469    fShowGrid = showGrid;
    468470    fShowInfo = showInfo;
     471    fInfoBarState = showInfo;
    469472    fHPixelCount = (overridePixelCount == -1) ? hPixelCount : overridePixelCount;
    470473    fVPixelCount = (overridePixelCount == -1) ? vPixelCount : overridePixelCount;
    471474    fPixelSize = pixelSize;
     
    513516{
    514517    CalcViewablePixels();
    515518    fFatBits->InitBuffers(fHPixelCount, fVPixelCount, fPixelSize, ShowGrid());
     519    UpdateInfoBarOnResize();
    516520}
    517521
    518522
     
    677681
    678682
    679683void
     684TWindow::UpdateInfoBarOnResize()
     685{
     686    float width, height;
     687    GetPreferredSize(&width, &height);
     688
     689    if (fInfo->StringWidth(fInfo->fInfoStr) + 30 > width
     690        ||  fInfo->StringWidth(fInfo->fCH1Str) +
     691            fInfo->StringWidth(fInfo->fCH2Str) +
     692            fInfo->StringWidth(fInfo->fRGBStr) + 30 > width) {
     693        ShowInfo(false);
     694    } else if (fInfoBarState) {
     695        ShowInfo(true);
     696    }
     697}
     698
     699
     700void
    680701TWindow::AddCrossHair()
    681702{
    682703    fFatBits->AddCrossHair();