Ticket #8670: improved_zoom.patch

File improved_zoom.patch, 2.0 KB (added by ejno1, 7 years ago)

Improved zoom behavior (modified)

  • src/apps/stylededit/StyledEditWindow.cpp

    From c5232cc8683a8b9a8ae3325785f5ee5c513da682 Mon Sep 17 00:00:00 2001
    From: ejno <none>
    Date: Wed, 26 Jun 2013 12:51:53 +0000
    Subject: [PATCH] improved Zoom behavior for StyleEdit
    
    ---
     src/apps/stylededit/StyledEditWindow.cpp |   27 +++++++++++++++++++++++++++
     src/apps/stylededit/StyledEditWindow.h   |    1 +
     2 files changed, 28 insertions(+)
    
    diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp
    index 4eee321..8532ae5 100644
    a b StyledEditWindow::QuitRequested()  
    157157
    158158
    159159void
     160StyledEditWindow::Zoom(BPoint origin, float fullWidth, float fullHeight)
     161{
     162    const float minDimension = 256.f;
     163
     164    float width = Bounds().right, height;
     165
     166    if (!fTextView->DoesWordWrap()) {
     167        width = 0.f;
     168        int32 numLines = fTextView->CountLines();
     169
     170        for (int32 i = 0; i < numLines; i++)
     171            width = max_c(fTextView->LineWidth(i), width);
     172
     173        width += 3.f * (fTextView->Frame().left - Bounds().left + Bounds().right - fTextView->Frame().right);
     174        width = min_c(max_c(width, minDimension), fullWidth);
     175    }
     176
     177    height = fTextView->TextHeight(0, fTextView->CountLines());
     178    height += 2.f * (fTextView->Frame().top - Bounds().top + Bounds().bottom - fTextView->Frame().bottom);
     179    height = min_c(max_c(height, minDimension), fullHeight);
     180
     181    MoveTo(origin);
     182    ResizeTo(width, height);
     183}
     184
     185
     186void
    160187StyledEditWindow::MessageReceived(BMessage* message)
    161188{
    162189    if (message->WasDropped()) {
  • src/apps/stylededit/StyledEditWindow.h

    diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h
    index bf239a6..4c31879 100644
    a b public:  
    3737
    3838    virtual void                Quit();
    3939    virtual bool                QuitRequested();
     40    virtual void                Zoom(BPoint origin, float width, float height);
    4041    virtual void                MessageReceived(BMessage* message);
    4142    virtual void                MenusBeginning();
    4243