Skip to content

Commit

Permalink
feat: 增加 showwindow(), hidewindow() 函数, 支持窗口显示和隐藏 (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
yixy-only authored Apr 30, 2024
1 parent 557fa96 commit 86faf1b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/ege.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ void EGEAPI setcaption(LPCWSTR caption);
void EGEAPI seticon(int icon_id);
int EGEAPI attachHWND(HWND hWnd);

void EGEAPI showwindow();
void EGEAPI hidewindow();
void EGEAPI movewindow(int x, int y, bool redraw = true);
void EGEAPI resizewindow(int width, int height);
void EGEAPI flushwindow();
Expand Down
4 changes: 4 additions & 0 deletions src/ege_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace ege
extern struct _graph_setting graph_setting;
class egeControlBase; // 前置声明

int getinitmode();

void logoscene();

int dealmessage(_graph_setting* pg, bool force_update);

void guiupdate(_graph_setting* pg, egeControlBase* root);
Expand Down
1 change: 1 addition & 0 deletions src/ege_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ struct _graph_setting
bool lock_window;
bool timer_stop_mark;
bool skip_timer_mark;
bool first_show;

thread_queue<EGEMSG>*msgkey_queue, *msgmouse_queue;

Expand Down
1 change: 1 addition & 0 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ void initgraph(int* gdriver, int* gmode, const char* path)
setrendermode(RENDER_MANUAL);
}

pg->first_show = true;
pg->mouse_show = true;
}

Expand Down
54 changes: 54 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,60 @@ void seticon(int icon_id)
}
}

void showwindow()
{
struct _graph_setting* pg = &graph_setting;

bool showLogo = false;

PIMAGE background = NULL;
color_t bkColor = getbkcolor();

if (pg->first_show) {
pg->first_show = false;

int initmode = getinitmode();
if ((initmode & INIT_WITHLOGO) && (initmode & INIT_HIDE)) {
showLogo = true;
}
}

if (showLogo) {
background = newimage();
getimage(background, 0, 0, getwidth(), getheight());
setbkcolor_f(EGERGB(0, 0, 0));
cleardevice();
}

ShowWindow(pg->hwnd, SW_SHOWNORMAL);
BringWindowToTop(pg->hwnd);
SetForegroundWindow(pg->hwnd);

if (showLogo) {
bool isRenderManual = pg->lock_window;

logoscene();

setbkcolor_f(bkColor);

if (background != NULL) {
putimage(0, 0, background);
flushwindow();
delimage(background);
}

if (!isRenderManual) {
setrendermode(RENDER_AUTO);
}
}
}

void hidewindow()
{
struct _graph_setting* pg = &graph_setting;
ShowWindow(pg->hwnd, SW_HIDE);
}

void movewindow(int x, int y, bool redraw)
{
::MoveWindow(getHWnd(), x, y, getwidth(), getheight(), redraw);
Expand Down

0 comments on commit 86faf1b

Please sign in to comment.