File Prompt.hpp changed (mode: 100644) (index 9cd2332..bde6780) |
... |
... |
private: |
44 |
44 |
// Updates state of this widget to be published on the screen. |
// Updates state of this widget to be published on the screen. |
45 |
45 |
virtual void draw() override; |
virtual void draw() override; |
46 |
46 |
|
|
|
47 |
|
// Moves hardware cursor onto this widget. |
|
48 |
|
virtual void updateCursor() override; |
|
49 |
|
|
47 |
50 |
// Retrieves vertical size policy. |
// Retrieves vertical size policy. |
48 |
51 |
// Positive number or zero means exactly that much. |
// Positive number or zero means exactly that much. |
49 |
52 |
// Negative number means at least that much in magnitude. |
// Negative number means at least that much in magnitude. |
File Screen.cpp changed (mode: 100644) (index 2b1d4f5..14cc234) |
24 |
24 |
#include "guts/Pos.hpp" |
#include "guts/Pos.hpp" |
25 |
25 |
#include "guts/Size.hpp" |
#include "guts/Size.hpp" |
26 |
26 |
#include "guts/Widget.hpp" |
#include "guts/Widget.hpp" |
|
27 |
|
#include "guts/WindowWidget.hpp" |
27 |
28 |
|
|
28 |
29 |
using namespace cursed; |
using namespace cursed; |
29 |
30 |
using namespace cursed::guts; |
using namespace cursed::guts; |
|
... |
... |
Screen::draw() |
77 |
78 |
for (Widget *widget : mainWidgets) { |
for (Widget *widget : mainWidgets) { |
78 |
79 |
widget->draw(); |
widget->draw(); |
79 |
80 |
} |
} |
|
81 |
|
|
|
82 |
|
if (cursorWidget != nullptr) { |
|
83 |
|
cursorWidget->updateCursor(); |
|
84 |
|
} |
|
85 |
|
|
80 |
86 |
doupdate(); |
doupdate(); |
81 |
87 |
} |
} |
82 |
88 |
|
|
83 |
89 |
bool |
bool |
84 |
|
Screen::showCursor() |
|
|
90 |
|
Screen::showCursor(guts::WindowWidget *w) |
85 |
91 |
{ |
{ |
|
92 |
|
cursorWidget = w; |
86 |
93 |
return (curs_set(1) == 0); |
return (curs_set(1) == 0); |
87 |
94 |
} |
} |
88 |
95 |
|
|
89 |
96 |
bool |
bool |
90 |
97 |
Screen::hideCursor() |
Screen::hideCursor() |
91 |
98 |
{ |
{ |
|
99 |
|
cursorWidget = nullptr; |
92 |
100 |
return (curs_set(0) != 0); |
return (curs_set(0) != 0); |
93 |
101 |
} |
} |
94 |
102 |
|
|
File Screen.hpp changed (mode: 100644) (index 37c0a07..f5d3c06) |
... |
... |
namespace cursed { |
25 |
25 |
|
|
26 |
26 |
namespace guts { |
namespace guts { |
27 |
27 |
class Widget; |
class Widget; |
|
28 |
|
class WindowWidget; |
28 |
29 |
} |
} |
29 |
30 |
|
|
30 |
31 |
// Provides information about the whole screen. |
// Provides information about the whole screen. |
|
... |
... |
public: |
45 |
46 |
// Draws main widget and makes screen updates visible on physical screen. |
// Draws main widget and makes screen updates visible on physical screen. |
46 |
47 |
void draw(); |
void draw(); |
47 |
48 |
|
|
48 |
|
// Makes cursor visible. Returns `true` if cursor was hidden before the |
|
49 |
|
// call. |
|
50 |
|
bool showCursor(); |
|
|
49 |
|
// Makes cursor visible. Optionally sets widget that owns the cursor. |
|
50 |
|
// Returns `true` if cursor was hidden before the call. |
|
51 |
|
bool showCursor(guts::WindowWidget *w = nullptr); |
51 |
52 |
// Makes cursor invisible. Returns `true` if cursor was visible before the |
// Makes cursor invisible. Returns `true` if cursor was visible before the |
52 |
53 |
// call. |
// call. |
53 |
54 |
bool hideCursor(); |
bool hideCursor(); |
|
... |
... |
public: |
58 |
59 |
private: |
private: |
59 |
60 |
// Roots of all currently displayed layers of widgets. |
// Roots of all currently displayed layers of widgets. |
60 |
61 |
std::vector<guts::Widget *> mainWidgets; |
std::vector<guts::Widget *> mainWidgets; |
|
62 |
|
// Widget that has the cursor. |
|
63 |
|
guts::WindowWidget *cursorWidget = nullptr; |
61 |
64 |
}; |
}; |
62 |
65 |
|
|
63 |
66 |
} |
} |
File guts/WindowWidget.hpp changed (mode: 100644) (index 5ab1efd..dbf9c98) |
... |
... |
public: |
36 |
36 |
// with attributes and/or foreground). |
// with attributes and/or foreground). |
37 |
37 |
void setBackground(Format format); |
void setBackground(Format format); |
38 |
38 |
|
|
|
39 |
|
// Moves hardware cursor onto this widget. |
|
40 |
|
virtual void updateCursor(); |
|
41 |
|
|
39 |
42 |
protected: |
protected: |
40 |
43 |
// Resizes and moves window. |
// Resizes and moves window. |
41 |
44 |
virtual void placed(Pos newPos, Size newSize) override; |
virtual void placed(Pos newPos, Size newSize) override; |
|
... |
... |
protected: |
44 |
47 |
Window win; // Window object. |
Window win; // Window object. |
45 |
48 |
}; |
}; |
46 |
49 |
|
|
|
50 |
|
inline void |
|
51 |
|
WindowWidget::updateCursor() |
|
52 |
|
{ } |
|
53 |
|
|
47 |
54 |
inline void |
inline void |
48 |
55 |
WindowWidget::setBackground(Format format) |
WindowWidget::setBackground(Format format) |
49 |
56 |
{ win.setBackground(std::move(format)); } |
{ win.setBackground(std::move(format)); } |