repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / ui_generic / LinkedBitmapView.cpp
blobc8ddea6ea48dc86e6a8cbe4653311c2bfe8363de
1 /*
2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
7 #include "LinkedBitmapView.h"
9 #include <Cursor.h>
12 LinkedBitmapView::LinkedBitmapView(const char* name, BMessage* message)
14 BitmapView(name),
15 BInvoker(message, NULL),
16 fEnabled(true),
17 fMouseInside(false)
22 void
23 LinkedBitmapView::AllAttached()
25 // We don't want to use BitmapView's default behavior here.
29 void
30 LinkedBitmapView::MouseMoved(BPoint where, uint32 transit,
31 const BMessage* dragMessage)
33 // TODO: Check that no buttons are pressed, don't indicate clickable
34 // link if a button is held.
35 if (transit == B_ENTERED_VIEW) {
36 fMouseInside = true;
37 _UpdateViewCursor();
38 } else if (transit == B_EXITED_VIEW) {
39 fMouseInside = false;
40 _UpdateViewCursor();
45 void
46 LinkedBitmapView::MouseDown(BPoint where)
48 if (fEnabled)
49 Invoke(Message());
53 void
54 LinkedBitmapView::SetEnabled(bool enabled)
56 if (fEnabled != enabled) {
57 fEnabled = enabled;
58 _UpdateViewCursor();
63 void
64 LinkedBitmapView::_UpdateViewCursor()
66 if (fEnabled && fMouseInside) {
67 BCursor cursor(B_CURSOR_ID_FOLLOW_LINK);
68 SetViewCursor(&cursor, true);
69 } else {
70 BCursor cursor(B_CURSOR_SYSTEM_DEFAULT);
71 SetViewCursor(&cursor, true);