-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,586 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <component.h> | ||
|
||
void draw_frame(graphic_t *g, context_t *contex, frame_t *frame) | ||
{ | ||
int x = contex->rect.p.x; | ||
int y = contex->rect.p.y; | ||
rect_t frect = frame->rect; | ||
rect_t realrect = RECT(x+frect.p.x, y+frect.p.y, frect.width, frect.height); | ||
g->fill_rect(realrect, frame->bgc); | ||
g->draw_rect(realrect, frame->frc); | ||
} | ||
|
||
void draw_button(graphic_t *g, context_t *contex, button_t *button) | ||
{ | ||
draw_frame(g, contex, &button->frame); | ||
rect_t frect = button->frame.rect; | ||
int x1 = contex->rect.p.x + frect.p.x; | ||
int y1 = contex->rect.p.y + frect.p.y; | ||
int x2 = x1 + frect.width-1; | ||
int y2 = y1 + frect.height-1; | ||
g->draw_line(POINT(x1, y1),POINT(x2, y2), button->btc); | ||
g->draw_line(POINT(x1, y2),POINT(x2, y1), button->btc); | ||
} | ||
|
||
void draw_list(graphic_t *g, context_t *contex, list_t *list) | ||
{ | ||
draw_frame(g, contex, &list->frame); | ||
rect_t frect = list->frame.rect; | ||
int x1 = contex->rect.p.x + frect.p.x; | ||
int y1 = contex->rect.p.y + frect.p.y; | ||
for (size_t i = 0; i < list->n; i++) { | ||
g->draw_line(POINT(x1, y1), POINT(x1+frect.width, y1), list->sepc); | ||
y1 += LIST_H; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <types.h> | ||
#include <graphic.h> | ||
#include <window.h> | ||
|
||
/* | ||
point or rect of the component are all relative | ||
for example: | ||
if the point of window is (xw, yw) and the point of frame is (xf, yf) | ||
then the real position of frame is (xw+xf, yw+yf) | ||
*/ | ||
|
||
|
||
typedef struct frame_s | ||
{ | ||
rect_t rect; // relative rect | ||
rgb_t bgc; // background color | ||
rgb_t frc; // frame color | ||
} frame_t; | ||
void draw_frame(graphic_t *g, context_t *contex, frame_t *frame); | ||
|
||
typedef struct button_s | ||
{ | ||
frame_t frame; // button frame | ||
rgb_t btc; // button color | ||
} button_t; | ||
void draw_button(graphic_t *g, context_t *contex, button_t *button); | ||
|
||
typedef struct list_s | ||
{ | ||
frame_t frame; // list frame | ||
rgb_t sepc; // separator color | ||
uint32_t n; // n list item | ||
} list_t; | ||
void draw_list(graphic_t *g, context_t *contex, list_t *list); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.