Ticket #8555: 0001-Ticket-8555-Underline-links-on-mouse-over.-B_UNDERSC.2.patch

File 0001-Ticket-8555-Underline-links-on-mouse-over.-B_UNDERSC.2.patch, 4.3 KB (added by sambuddhabasu1, 6 years ago)

Underline links on mouse over. B_UNDERSCORE_FACE is not implemented so B_ITALIC_FACE has been used on mouse over

  • src/apps/aboutsystem/HyperTextView.cpp

    From 02d1d5e08a0ff2b2542073915b7026ff978c6bb4 Mon Sep 17 00:00:00 2001
    From: Sambuddha Basu <sambuddhabasu1@gmail.com>
    Date: Wed, 4 Feb 2015 15:11:24 +0530
    Subject: [PATCH] Ticket 8555 Underline links on mouse over. B_UNDERSCORE_FACE
     is not implemented so B_ITALIC_FACE has been used
    
    ---
     src/apps/aboutsystem/HyperTextView.cpp | 50 +++++++++++++++++++++++++++++-----
     src/apps/aboutsystem/HyperTextView.h   |  7 +++++
     2 files changed, 50 insertions(+), 7 deletions(-)
    
    diff --git a/src/apps/aboutsystem/HyperTextView.cpp b/src/apps/aboutsystem/HyperTextView.cpp
    index d1bc4e6..8e80319 100644
    a b HyperTextAction::~HyperTextAction()  
    2727
    2828
    2929void
    30 HyperTextAction::MouseOver(HyperTextView* view, BPoint where, BMessage* message)
     30HyperTextAction::MouseOver(HyperTextView* view, BPoint where, int32 startOffset,
     31        int32 endOffset, BMessage* message)
    3132{
    3233    BCursor linkCursor(B_CURSOR_ID_FOLLOW_LINK);
    3334    view->SetViewCursor(&linkCursor);
     35
     36    BFont font;
     37    view->GetFont(&font);
     38    font.SetFace(B_ITALIC_FACE);
     39    view->SetFontAndColor(startOffset, endOffset, &font, B_FONT_FACE);
     40}
     41
     42
     43void
     44HyperTextAction::MouseAway(HyperTextView* view, BPoint where, int32 startOffset,
     45        int32 endOffset, BMessage* message)
     46{
     47    BFont font(be_plain_font);
     48    view->SetFontAndColor(startOffset, endOffset, &font, B_FONT_FACE);
    3449}
    3550
    3651
    HyperTextView::HyperTextView(const char* name, uint32 flags)  
    92107    BTextView(name, flags),
    93108    fActionInfos(new ActionInfoList(100, true))
    94109{
     110    this->fLastActionInfo = NULL;
    95111}
    96112
    97113
    HyperTextView::HyperTextView(BRect frame, const char* name, BRect textRect,  
    101117    BTextView(frame, name, textRect, resizeMask, flags),
    102118    fActionInfos(new ActionInfoList(100, true))
    103119{
     120    this->fLastActionInfo = NULL;
    104121}
    105122
    106123
    HyperTextView::MouseMoved(BPoint where, uint32 transit,  
    140157
    141158    uint32 buttons;
    142159    HyperTextAction* action;
     160    const ActionInfo* actionInfo;
     161    if ((actionInfo = this->fLastActionInfo) != NULL
     162        && (action = actionInfo->action) != NULL) {
     163            action->MouseAway(this, where, actionInfo->startOffset,
     164                actionInfo->endOffset, message);
     165            this->fLastActionInfo = NULL;
     166    }
     167
    143168    if (message->FindInt32("buttons", (int32*)&buttons) == B_OK
    144         && buttons == 0 && (action = _ActionAt(where)) != NULL) {
    145         action->MouseOver(this, where, message);
     169        && buttons == 0 && (action = _ActionAt(where)) != NULL
     170        && (actionInfo = _ActionInfoAt(where)) != NULL) {
     171        this->fLastActionInfo = actionInfo;
     172        action->MouseOver(this, where, actionInfo->startOffset,
     173                actionInfo->endOffset, message);
    146174        return;
    147175    }
    148176
    HyperTextView::InsertHyperText(const char* inText, int32 inLength,  
    190218}
    191219
    192220
    193 HyperTextAction*
    194 HyperTextView::_ActionAt(const BPoint& where) const
     221const HyperTextView::ActionInfo*
     222HyperTextView::_ActionInfoAt(const BPoint& where) const
    195223{
    196224    int32 offset = OffsetAt(where);
    197225
    198226    ActionInfo pointer(offset, offset + 1, NULL);
    199227
    200     const ActionInfo* action = fActionInfos->BinarySearch(pointer,
     228    const ActionInfo* action = fActionInfos->BinarySearch(pointer,
    201229            ActionInfo::CompareEqualIfIntersecting);
     230    return action;
     231}
     232
     233
     234HyperTextAction*
     235HyperTextView::_ActionAt(const BPoint& where) const
     236{
     237    const ActionInfo* action = _ActionInfoAt(where);
     238
    202239    if (action != NULL) {
    203240        // verify that the text region was hit
    204241        BRegion textRegion;
    HyperTextView::_ActionAt(const BPoint& where) const  
    209246
    210247    return NULL;
    211248}
    212 
  • src/apps/aboutsystem/HyperTextView.h

    diff --git a/src/apps/aboutsystem/HyperTextView.h b/src/apps/aboutsystem/HyperTextView.h
    index b9d6c2a..0d8e66d 100644
    a b public:  
    2121    virtual                     ~HyperTextAction();
    2222
    2323    virtual void                MouseOver(HyperTextView* view, BPoint where,
     24                                    int32 startOffset, int32 endOffset,
     25                                    BMessage* message);
     26    void                    MouseAway(HyperTextView* view, BPoint where,
     27                                    int32 startOffset, int32 endOffset,
    2428                                    BMessage* message);
    2529    virtual void                Clicked(HyperTextView* view, BPoint where,
    2630                                    BMessage* message);
    private:  
    5862            struct ActionInfo;
    5963            class ActionInfoList;
    6064
     65            const ActionInfo*   _ActionInfoAt(const BPoint& where) const;
     66
    6167            ActionInfoList*     fActionInfos;
     68            const ActionInfo*   fLastActionInfo;
    6269};
    6370
    6471