Started implementing uiArea on Haiku.

This commit is contained in:
Pietro Gagliardi 2015-11-23 18:08:34 -05:00
parent 14d2073f28
commit a7aa50ae2c
4 changed files with 60 additions and 8 deletions

View File

@ -1,17 +1,53 @@
// 18 november 2015
#include "uipriv_haiku.hpp"
// TODO scrollbars
class areaView : public BView {
public:
// C++11! Inherit constructors.
using BView::BView;
uiArea *a;
virtual void Draw(BRect updateRect);
};
struct uiArea {
uiHaikuControl c;
BStringView *dummy;
areaView *area;
uiAreaHandler *ah;
};
uiHaikuDefineControl(
uiArea, // type name
uiAreaType, // type function
dummy // handle
area // handle
)
void areaView::Draw(BRect updateRect)
{
uiAreaHandler *ah = this->a->ah;
uiAreaDrawParams dp;
BRect bounds;
dp.Context = newContext(this);
bounds = this->Bounds();
dp.ClientWidth = bounds.right - bounds.left;
dp.ClientHeight = bounds.bottom - bounds.top;
dp.ClipX = updateRect.left;
dp.ClipY = updateRect.top;
dp.ClipWidth = updateRect.right - updateRect.left;
dp.ClipHeight = updateRect.bottom - updateRect.top;
// TODO scroll positions
(*(ah->Draw))(ah, this->a, &dp);
freeContext(dp.Context);
}
void uiAreaUpdateScroll(uiArea *a)
{
// TODO
@ -19,7 +55,8 @@ void uiAreaUpdateScroll(uiArea *a)
void uiAreaQueueRedrawAll(uiArea *a)
{
// TODO
// TODO does this really /queue/ a redraw? or does it redraw right away, regardless of the drawing machinery?
a->area->Invalidate();
}
uiArea *uiNewArea(uiAreaHandler *ah)
@ -28,7 +65,19 @@ uiArea *uiNewArea(uiAreaHandler *ah)
a = (uiArea *) uiNewControl(uiAreaType());
a->dummy = new BStringView(NULL, "TODO uiArea not implemented");
a->ah = ah;
// TODO:
// - B_FULL_UPDATE_ON_RESIZE?
// - B_FRAME_EVENTS?
// - B_NAVIGABLE?
// - B_SUBPIXEL_PRECISE?
// - B_INVALIDATE_AFTER_LAYOUT?
a->area = new areaView(NULL,
B_WILL_DRAW | B_SUPPORTS_LAYOUT,
NULL);
a->area->a = a;
// TODO background color
uiHaikuFinishNewControl(a, uiArea);

View File

@ -20,7 +20,8 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
intmax_t uiComboboxSelected(uiCombobox *c)
{
// TODO
return -1;
// return 0 so the area test can work
return 0;
}
void uiComboboxSetSelected(uiCombobox *c, intmax_t n)

View File

@ -3,6 +3,8 @@
#include "uipriv_haiku.hpp"
using namespace std;
// TODO alpha doesn't work
struct uiDrawPath {
BShape *shape;
uiDrawFillMode fillMode;
@ -15,7 +17,7 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode)
p = uiNew(uiDrawPath);
p->shape = new BShape();
p->fillMode = mode;
p->fillMode = fillMode;
return p;
}
@ -106,7 +108,7 @@ static void drawArc(uiDrawPath *p, struct arc *a, void (*startFunction)(uiDrawPa
if (a->negative)
counterclockwise = true;
else
counterclockwise = false
counterclockwise = false;
// TODO explain the outer if
if (!a->negative)
if (a->sweep > M_PI)

View File

@ -24,5 +24,5 @@ extern void singleChildSetMargined(struct singleChild *s, float inset);
// TODO write helper functions?
// draw.cpp
extern uiDrawContext *newContext(BView *view)
extern uiDrawContext *newContext(BView *view);
extern void freeContext(uiDrawContext *c);