Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 增加 showwindow(), hidewindow() 函数, 支持窗口显示和隐藏 #161

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading