[escher/view] Inline some view methods

This commit is contained in:
Léa Saviot
2019-10-02 10:49:40 +02:00
parent 1c668dca52
commit f85658f5e6
2 changed files with 8 additions and 30 deletions

View File

@@ -30,7 +30,7 @@ class View {
friend class TransparentView;
friend class Shared::RoundCursorView;
public:
View();
View() : m_frame(KDRectZero), m_superview(nullptr), m_dirtyRect(KDRectZero) {}
virtual ~View() {
for (int i = 0; i < numberOfSubviews(); i++) {
View * subview = subviewAtIndex(i);
@@ -49,7 +49,9 @@ public:
/* The drawRect method should be implemented by each View subclass. In a
* typical drawRect implementation, a subclass will make drawing calls to the
* Kandinsky library using the provided context. */
virtual void drawRect(KDContext * ctx, KDRect rect) const;
virtual void drawRect(KDContext * ctx, KDRect rect) const {
// By default, a view doesn't do anything, it's transparent
}
void setSize(KDSize size);
void setFrame(KDRect frame);
@@ -58,7 +60,7 @@ public:
KDRect bounds() const;
View * subview(int index);
virtual KDSize minimalSizeForOptimalDisplay() const;
virtual KDSize minimalSizeForOptimalDisplay() const { return KDSizeZero; }
#if ESCHER_VIEW_LOGGING
friend std::ostream &operator<<(std::ostream &os, View &view);
@@ -80,13 +82,9 @@ protected:
#endif
KDRect m_frame;
private:
virtual int numberOfSubviews() const {
return 0;
}
virtual View * subviewAtIndex(int index) {
return nullptr;
}
virtual void layoutSubviews();
virtual int numberOfSubviews() const { return 0; }
virtual View * subviewAtIndex(int index) { return nullptr; }
virtual void layoutSubviews(bool force = false) {}
virtual const Window * window() const;
KDRect redraw(KDRect rect, KDRect forceRedrawRect = KDRectZero);
KDPoint absoluteOrigin() const;

View File

@@ -3,18 +3,6 @@ extern "C" {
}
#include <escher/view.h>
View::View() :
m_frame(KDRectZero),
m_superview(nullptr),
m_dirtyRect(KDRectZero)
{
}
void View::drawRect(KDContext * ctx, KDRect rect) const {
// By default, a view doesn't do anything
// It's transparent!
}
const Window * View::window() const {
if (m_superview == nullptr) {
return nullptr;
@@ -167,14 +155,6 @@ KDRect View::absoluteVisibleFrame() const {
}
}
KDSize View::minimalSizeForOptimalDisplay() const {
return KDSizeZero;
}
void View::layoutSubviews() {
}
#if ESCHER_VIEW_LOGGING
const char * View::className() const {
return "View";