mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] overlay: add record indicator
This commit is contained in:
parent
97cef000fd
commit
1685249f3a
@ -141,6 +141,7 @@ set(SOURCES
|
|||||||
src/overlay/help.c
|
src/overlay/help.c
|
||||||
src/overlay/config.c
|
src/overlay/config.c
|
||||||
src/overlay/msg.c
|
src/overlay/msg.c
|
||||||
|
src/overlay/record.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Force cimgui to build as a static library.
|
# Force cimgui to build as a static library.
|
||||||
|
@ -150,6 +150,8 @@ void app_msgBoxClose(MsgBoxHandle handle);
|
|||||||
typedef struct KeybindHandle * KeybindHandle;
|
typedef struct KeybindHandle * KeybindHandle;
|
||||||
typedef void (*KeybindFn)(int sc, void * opaque);
|
typedef void (*KeybindFn)(int sc, void * opaque);
|
||||||
|
|
||||||
|
void app_showRecord(bool show);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a handler for the <super>+<key> combination
|
* Register a handler for the <super>+<key> combination
|
||||||
* @param sc The scancode to register
|
* @param sc The scancode to register
|
||||||
|
@ -673,6 +673,11 @@ void app_msgBoxClose(MsgBoxHandle handle)
|
|||||||
overlayMsg_close(handle);
|
overlayMsg_close(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void app_showRecord(bool show)
|
||||||
|
{
|
||||||
|
overlayRecord_show(show);
|
||||||
|
}
|
||||||
|
|
||||||
KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque, const char * description)
|
KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque, const char * description)
|
||||||
{
|
{
|
||||||
// don't allow duplicate binds
|
// don't allow duplicate binds
|
||||||
|
@ -1647,6 +1647,7 @@ int main(int argc, char * argv[])
|
|||||||
app_registerOverlay(&LGOverlayGraphs, NULL);
|
app_registerOverlay(&LGOverlayGraphs, NULL);
|
||||||
app_registerOverlay(&LGOverlayHelp , NULL);
|
app_registerOverlay(&LGOverlayHelp , NULL);
|
||||||
app_registerOverlay(&LGOverlayMsg , NULL);
|
app_registerOverlay(&LGOverlayMsg , NULL);
|
||||||
|
app_registerOverlay(&LGOverlayRecord, NULL);
|
||||||
|
|
||||||
|
|
||||||
// early renderer setup for option registration
|
// early renderer setup for option registration
|
||||||
|
86
client/src/overlay/record.c
Normal file
86
client/src/overlay/record.c
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* Looking Glass
|
||||||
|
* Copyright © 2017-2022 The Looking Glass Authors
|
||||||
|
* https://looking-glass.io
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||||
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "interface/overlay.h"
|
||||||
|
#include "cimgui.h"
|
||||||
|
#include "overlay_utils.h"
|
||||||
|
|
||||||
|
#include "common/stringutils.h"
|
||||||
|
|
||||||
|
#include "../main.h"
|
||||||
|
|
||||||
|
static bool recordShow = false;
|
||||||
|
static bool recordToggle = false;
|
||||||
|
static unsigned long long lastTick = 0;
|
||||||
|
|
||||||
|
static bool record_init(void ** udata, const void * params)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void record_free(void * udata)
|
||||||
|
{}
|
||||||
|
|
||||||
|
static int record_render(void * udata, bool interactive, struct Rect * windowRects,
|
||||||
|
int maxRects)
|
||||||
|
{
|
||||||
|
if (!recordShow || !recordToggle)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ImVec2 * screen = overlayGetScreenSize();
|
||||||
|
ImDrawList_AddCircleFilled(igGetBackgroundDrawList_Nil(),
|
||||||
|
(ImVec2) { screen->x - 20.0f, 20.0f },
|
||||||
|
5.0f, 0xFF0000FF, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
*windowRects = (struct Rect) {
|
||||||
|
.x = screen->x - 26, .y = 14, .w = 12, .h = 12
|
||||||
|
};
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool record_tick(void * udata, unsigned long long tickCount)
|
||||||
|
{
|
||||||
|
if (tickCount - lastTick >= 25)
|
||||||
|
{
|
||||||
|
recordToggle = !recordToggle;
|
||||||
|
lastTick = tickCount;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LG_OverlayOps LGOverlayRecord =
|
||||||
|
{
|
||||||
|
.name = "record",
|
||||||
|
.init = record_init,
|
||||||
|
.free = record_free,
|
||||||
|
.render = record_render,
|
||||||
|
.tick = record_tick,
|
||||||
|
};
|
||||||
|
|
||||||
|
void overlayRecord_show(bool show)
|
||||||
|
{
|
||||||
|
if (show == recordShow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
recordShow = show;
|
||||||
|
app_invalidateOverlay(true);
|
||||||
|
}
|
@ -39,6 +39,7 @@ extern struct LG_OverlayOps LGOverlayGraphs;
|
|||||||
extern struct LG_OverlayOps LGOverlayHelp;
|
extern struct LG_OverlayOps LGOverlayHelp;
|
||||||
extern struct LG_OverlayOps LGOverlayConfig;
|
extern struct LG_OverlayOps LGOverlayConfig;
|
||||||
extern struct LG_OverlayOps LGOverlayMsg;
|
extern struct LG_OverlayOps LGOverlayMsg;
|
||||||
|
extern struct LG_OverlayOps LGOverlayRecord;
|
||||||
|
|
||||||
void overlayAlert_show(LG_MsgAlert type, const char * fmt, va_list args);
|
void overlayAlert_show(LG_MsgAlert type, const char * fmt, va_list args);
|
||||||
|
|
||||||
@ -55,4 +56,6 @@ void overlayConfig_register(const char * title,
|
|||||||
void overlayConfig_registerTab(const char * title,
|
void overlayConfig_registerTab(const char * title,
|
||||||
void (*callback)(void * udata, int * id), void * udata);
|
void (*callback)(void * udata, int * id), void * udata);
|
||||||
|
|
||||||
|
void overlayRecord_show(bool show);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user