Add new color theme.
parent
0a426f981b
commit
9736aaf5e6
87
src/editor.c
87
src/editor.c
|
@ -19,15 +19,18 @@
|
||||||
#define ED_MODE_EDIT 0
|
#define ED_MODE_EDIT 0
|
||||||
#define ED_MODE_ANIMATION 1
|
#define ED_MODE_ANIMATION 1
|
||||||
|
|
||||||
#define ED_BACKGROUND_COLOR 0x141414
|
#define ED_BACKGROUND_COLOR 0x141414 //0x111111
|
||||||
|
|
||||||
#define ED_SIDEBAR_WIDTH 400
|
#define ED_SIDEBAR_WIDTH 400
|
||||||
#define ED_SPACING 10
|
#define ED_SPACING 10
|
||||||
|
|
||||||
#define ED_TOPBAR_HEIGHT 100
|
#define ED_MENU_HEIGHT ((float)glwImLineHeight(win))
|
||||||
#define ED_TOOLBAR_HEIGHT (glwImLineHeight(win) * 1.2)
|
|
||||||
|
|
||||||
#define ED_GL_BACKGROUND_COLOR GLW_BACKGROUND_COLOR
|
#define ED_TOPBAR_HEIGHT (ED_MENU_HEIGHT + ED_SPACING + glwImLineHeight(win) + ED_SPACING)
|
||||||
|
#define ED_TOOLBAR_HEIGHT ((float)glwImLineHeight(win) * 1.2)
|
||||||
|
|
||||||
|
#define ED_GL_BACKGROUND_COLOR 0x242424
|
||||||
|
#define ED_GL_BORDER_SIZE 7
|
||||||
|
|
||||||
#define ED_BONE_COLOR 0xffff00
|
#define ED_BONE_COLOR 0xffff00
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ typedef struct editor {
|
||||||
float cameraAngleX;
|
float cameraAngleX;
|
||||||
float cameraAngleY;
|
float cameraAngleY;
|
||||||
float cameraDistance;
|
float cameraDistance;
|
||||||
int newImId;
|
int selectedMenu;
|
||||||
int showBoneChecked;
|
int showBoneChecked;
|
||||||
int showBallChecked;
|
int showBallChecked;
|
||||||
int showMeshChecked;
|
int showMeshChecked;
|
||||||
|
@ -103,12 +106,41 @@ static void display(glwWin *win) {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
{
|
{
|
||||||
char *list[] = {"Open..", "New..", "Save As..", 0};
|
char *titles[] = {"File", "Window", "Help", 0};
|
||||||
glwImButtonGroup(win, GEN_ID, 100, 30, 300, list, -1);
|
ed->selectedMenu = glwImMenu(win, GEN_ID, 0, 0, ed->width,
|
||||||
|
glwImLineHeight(win), titles, ed->selectedMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
char *titles[] = {"Tool", 0};
|
char *titles[] = {"New..", "Open..", "Save As..", "Save", 0};
|
||||||
|
int icons[] = {ICON_FILE, 0, 0, 0, 0};
|
||||||
|
glwImButtonGroup(win, GEN_ID, ED_SPACING / 2,
|
||||||
|
ED_TOPBAR_HEIGHT - ED_SPACING - glwImLineHeight(win), titles, icons, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *titles[] = {"Add Ball", 0};
|
||||||
|
int icons[] = {ICON_PLUS, 0};
|
||||||
|
glwImButtonGroup(win, GEN_ID, glwImNextX(win) + ED_SPACING,
|
||||||
|
glwImNextY(win), titles, icons, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *titles[] = {"Del Ball", "Del All", 0};
|
||||||
|
int icons[] = {ICON_TRASH, 0, 0};
|
||||||
|
glwImButtonGroup(win, GEN_ID, glwImNextX(win) + ED_SPACING,
|
||||||
|
glwImNextY(win), titles, icons, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *titles[] = {"Start", "Pause", "Stop", 0};
|
||||||
|
int icons[] = {ICON_PLAY, ICON_PAUSE, ICON_STOP, 0};
|
||||||
|
glwImButtonGroup(win, GEN_ID, glwImNextX(win) + ED_SPACING,
|
||||||
|
glwImNextY(win), titles, icons, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *titles[] = {"Property", 0};
|
||||||
int icons[] = {ICON_TOOL, 0};
|
int icons[] = {ICON_TOOL, 0};
|
||||||
glwImTabBox(win, GEN_ID, ED_SPACING / 2, ED_TOPBAR_HEIGHT, ED_SIDEBAR_WIDTH,
|
glwImTabBox(win, GEN_ID, ED_SPACING / 2, ED_TOPBAR_HEIGHT, ED_SIDEBAR_WIDTH,
|
||||||
ed->height - ED_TOPBAR_HEIGHT - ED_SPACING / 2,
|
ed->height - ED_TOPBAR_HEIGHT - ED_SPACING / 2,
|
||||||
|
@ -120,34 +152,36 @@ static void display(glwWin *win) {
|
||||||
int y = ED_TOPBAR_HEIGHT;
|
int y = ED_TOPBAR_HEIGHT;
|
||||||
int width = ed->width - ED_SIDEBAR_WIDTH - ED_SPACING / 2 - ED_SPACING - ED_SPACING / 2;
|
int width = ed->width - ED_SIDEBAR_WIDTH - ED_SPACING / 2 - ED_SPACING - ED_SPACING / 2;
|
||||||
int height = ed->height - ED_TOPBAR_HEIGHT - ED_SPACING / 2;
|
int height = ed->height - ED_TOPBAR_HEIGHT - ED_SPACING / 2;
|
||||||
char *titles[] = {"Skeleton", "Animation", "Config", 0};
|
char *titles[] = {"Model", 0};
|
||||||
int icons[] = {ICON_MONITOR, ICON_PENCIL, ICON_EYE, 0};
|
int icons[] = {ICON_MONITOR, 0};
|
||||||
ed->mode = glwImTabBox(win, GEN_ID,
|
ed->mode = glwImTabBox(win, GEN_ID,
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
titles, icons, ed->mode);
|
titles, icons, ed->mode);
|
||||||
if (ED_MODE_EDIT == ed->mode) {
|
if (ED_MODE_EDIT == ed->mode) {
|
||||||
int toolBarY = glwImNextY(win) - 1;
|
int toolBarY = glwImNextY(win) - 1;
|
||||||
int glWinY = toolBarY + ED_TOOLBAR_HEIGHT;
|
int glWinY = toolBarY + ED_TOOLBAR_HEIGHT;
|
||||||
|
int toolBarContentY = toolBarY +
|
||||||
|
(ED_TOOLBAR_HEIGHT - glwImLineHeight(win));
|
||||||
glwImToolBar(win, GEN_ID, x, toolBarY, width, ED_TOOLBAR_HEIGHT);
|
glwImToolBar(win, GEN_ID, x, toolBarY, width, ED_TOOLBAR_HEIGHT);
|
||||||
ed->showBallChecked = glwImCheck(win, GEN_ID, x + ED_SPACING + ED_SPACING,
|
ed->showBallChecked = glwImCheck(win, GEN_ID, x + ED_SPACING + ED_SPACING,
|
||||||
toolBarY + (ED_TOOLBAR_HEIGHT - glwImLineHeight(win)) / 2 + 2,
|
toolBarContentY,
|
||||||
"Ball",
|
"Ball",
|
||||||
ed->showBallChecked);
|
ed->showBallChecked);
|
||||||
ed->showBoneChecked = glwImCheck(win, GEN_ID,
|
ed->showBoneChecked = glwImCheck(win, GEN_ID,
|
||||||
glwImNextX(win) + ED_SPACING,
|
glwImNextX(win) + ED_SPACING,
|
||||||
toolBarY + (ED_TOOLBAR_HEIGHT - glwImLineHeight(win)) / 2 + 2,
|
toolBarContentY,
|
||||||
"Bone",
|
"Bone",
|
||||||
ed->showBoneChecked);
|
ed->showBoneChecked);
|
||||||
ed->showMeshChecked = glwImCheck(win, GEN_ID,
|
ed->showMeshChecked = glwImCheck(win, GEN_ID,
|
||||||
glwImNextX(win) + ED_SPACING,
|
glwImNextX(win) + ED_SPACING,
|
||||||
toolBarY + (ED_TOOLBAR_HEIGHT - glwImLineHeight(win)) / 2 + 2,
|
toolBarContentY,
|
||||||
"Mesh",
|
"Mesh",
|
||||||
ed->showMeshChecked);
|
ed->showMeshChecked);
|
||||||
|
|
||||||
ed->renderLeft = x + 1;
|
ed->renderLeft = x + 1 + ED_GL_BORDER_SIZE;
|
||||||
ed->renderTop = glWinY;
|
ed->renderTop = glWinY + ED_GL_BORDER_SIZE;
|
||||||
ed->renderWidth = width - 3;
|
ed->renderWidth = width - 3 - ED_GL_BORDER_SIZE * 2;
|
||||||
ed->renderHeight = height - ED_TOOLBAR_HEIGHT;
|
ed->renderHeight = height - (glWinY - y) - 3 - ED_GL_BORDER_SIZE * 2;
|
||||||
|
|
||||||
if (0 == ed->skl) {
|
if (0 == ed->skl) {
|
||||||
ed->skl = skeletonCreate();
|
ed->skl = skeletonCreate();
|
||||||
|
@ -179,17 +213,19 @@ static void display(glwWin *win) {
|
||||||
bmeshGenerate(ed->bm);
|
bmeshGenerate(ed->bm);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
|
||||||
glScissor(ed->renderLeft, ED_SPACING / 2 + 1,
|
|
||||||
ed->renderWidth, ed->renderHeight);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(ed->renderLeft, ed->renderTop, 0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
glColor3f(glwR(ED_GL_BACKGROUND_COLOR),
|
glColor3f(glwR(ED_GL_BACKGROUND_COLOR),
|
||||||
glwG(ED_GL_BACKGROUND_COLOR),
|
glwG(ED_GL_BACKGROUND_COLOR),
|
||||||
glwB(ED_GL_BACKGROUND_COLOR));
|
glwB(ED_GL_BACKGROUND_COLOR));
|
||||||
glRecti(0, 0, ed->renderWidth, ed->renderHeight);*/
|
glRecti(ed->renderLeft,
|
||||||
|
ed->renderTop,
|
||||||
|
ed->renderLeft + ed->renderWidth,
|
||||||
|
ed->renderTop + ed->renderHeight);
|
||||||
|
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glScissor(ed->renderLeft, ed->height - (ed->renderTop + ed->renderHeight),
|
||||||
|
ed->renderWidth, ed->renderHeight);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(ed->renderLeft, ed->renderTop, 0);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -302,6 +338,7 @@ int main(int argc, char *argv[]) {
|
||||||
ed.cameraAngleY = -312;
|
ed.cameraAngleY = -312;
|
||||||
ed.cameraDistance = 14.4;
|
ed.cameraDistance = 14.4;
|
||||||
ed.showMeshChecked = 1;
|
ed.showMeshChecked = 1;
|
||||||
|
ed.selectedMenu = -1;
|
||||||
|
|
||||||
ed.win = glwCreateWindow(0, 0, 600, 480);
|
ed.win = glwCreateWindow(0, 0, 600, 480);
|
||||||
glwSetUserData(ed.win, &ed);
|
glwSetUserData(ed.win, &ed);
|
||||||
|
|
154
src/glw.c
154
src/glw.c
|
@ -12,6 +12,12 @@
|
||||||
#define M_PI 3.14159265
|
#define M_PI 3.14159265
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define glwSwapColor(color1, color2) do {\
|
||||||
|
unsigned int tmp = color1;\
|
||||||
|
color1 = color2;\
|
||||||
|
color2 = tmp;\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
void glwDrawSystemText(glwWin *win, int x, int y, char *text,
|
void glwDrawSystemText(glwWin *win, int x, int y, char *text,
|
||||||
unsigned int color) {
|
unsigned int color) {
|
||||||
int vleft, vwidth;
|
int vleft, vwidth;
|
||||||
|
@ -478,26 +484,37 @@ void glwDrawRoundedRectGradientFill(float x, float y, float width, float height,
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glwDrawButtonBackground(float x, float y, float width, float height,
|
static void glwDrawGradientBackground(float x, float y, float width, float height,
|
||||||
glwCtrlState state) {
|
glwCtrlState state, int sunken) {
|
||||||
|
unsigned int topColor = 0;
|
||||||
|
unsigned int bottomColor = 0;
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case GLW_CTRL_STATE_PRESS:
|
case GLW_CTRL_STATE_PRESS:
|
||||||
glwDrawRoundedRectGradientFill(x, y, width, height,
|
topColor = GLW_FILL_GRADIENT_COLOR_1_H;
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
bottomColor = GLW_FILL_GRADIENT_COLOR_2_H;
|
||||||
GLW_FILL_GRADIENT_COLOR_1_H, GLW_FILL_GRADIENT_COLOR_2_H);
|
|
||||||
break;
|
break;
|
||||||
case GLW_CTRL_STATE_NORMAL:
|
case GLW_CTRL_STATE_NORMAL:
|
||||||
default:
|
default:
|
||||||
glwDrawRoundedRectGradientFill(x, y, width, height,
|
topColor = GLW_FILL_GRADIENT_COLOR_1;
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
bottomColor = GLW_FILL_GRADIENT_COLOR_2;
|
||||||
GLW_FILL_GRADIENT_COLOR_1, GLW_FILL_GRADIENT_COLOR_2);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (sunken) {
|
||||||
|
glwSwapColor(topColor, bottomColor);
|
||||||
|
}
|
||||||
|
glwDrawRoundedRectGradientFill(x, y, width, height,
|
||||||
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
|
topColor, bottomColor);
|
||||||
glwDrawRoundedRectBorder(x, y, width, height,
|
glwDrawRoundedRectBorder(x, y, width, height,
|
||||||
GLW_BUTTON_CORNER_RADIUS, GLW_BORDER_COLOR_2);
|
GLW_BUTTON_CORNER_RADIUS, GLW_BORDER_COLOR_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glwDrawButtonBackground(float x, float y, float width, float height,
|
||||||
|
glwCtrlState state) {
|
||||||
|
glwDrawGradientBackground(x, y, width, height, state, 0);
|
||||||
|
}
|
||||||
|
|
||||||
glwSize glwMeasureSystemText(glwWin *win, char *text) {
|
glwSize glwMeasureSystemText(glwWin *win, char *text) {
|
||||||
glwSystemFontTexture *systemFontTexture = glwGetSystemFontTexture(win);
|
glwSystemFontTexture *systemFontTexture = glwGetSystemFontTexture(win);
|
||||||
glwSize size = {0, systemFontTexture->originSize.height};
|
glwSize size = {0, systemFontTexture->originSize.height};
|
||||||
|
@ -528,7 +545,7 @@ static void glwImGUIActiveIdCheck(glwImGui *imGUI, int id, int x, int y,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int glwImButton(glwWin *win, int id, int x, int y, char *text) {
|
int glwImButton(glwWin *win, int id, int x, int y, char *text, int icon) {
|
||||||
glwImGui *imGUI = glwGetImGUI(win);
|
glwImGui *imGUI = glwGetImGUI(win);
|
||||||
glwSize textSize = glwMeasureSystemText(win, text);
|
glwSize textSize = glwMeasureSystemText(win, text);
|
||||||
int width = textSize.width * (1 + GLW_HOR_AUTO_MARGIN * 2);
|
int width = textSize.width * (1 + GLW_HOR_AUTO_MARGIN * 2);
|
||||||
|
@ -544,6 +561,30 @@ int glwImButton(glwWin *win, int id, int x, int y, char *text) {
|
||||||
return imGUI->activeId == id;
|
return imGUI->activeId == id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static glwSize glwMeasureLabel(glwWin *win, char *text, int icon) {
|
||||||
|
glwSize size = glwMeasureSystemText(win, text);
|
||||||
|
int padding = glwGetLineHeight(win) / 2;
|
||||||
|
size.width += padding + padding + padding;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void glwDrawLabel(glwWin *win, int x, int y, char *text, int icon,
|
||||||
|
unsigned int color) {
|
||||||
|
int lineHeight = glwGetLineHeight(win);
|
||||||
|
int padding = glwGetLineHeight(win) / 2;
|
||||||
|
if (icon) {
|
||||||
|
int iconIdx = icon - 1;
|
||||||
|
glwDrawSystemIcon(win, x + padding,
|
||||||
|
y + lineHeight * GLW_VER_AUTO_MARGIN, icon, color);
|
||||||
|
glwDrawSystemText(win, x + padding +
|
||||||
|
iconTable[iconIdx][ICON_ITEM_ORIGINAL_WIDTH] + padding / 2,
|
||||||
|
y + lineHeight * GLW_VER_AUTO_MARGIN, text, color);
|
||||||
|
} else {
|
||||||
|
glwDrawSystemText(win, x + padding,
|
||||||
|
y + lineHeight * GLW_VER_AUTO_MARGIN, text, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int glwImDropdownBox(glwWin *win, int id, int x, int y, char *text) {
|
int glwImDropdownBox(glwWin *win, int id, int x, int y, char *text) {
|
||||||
glwImGui *imGUI = glwGetImGUI(win);
|
glwImGui *imGUI = glwGetImGUI(win);
|
||||||
glwSize textSize = glwMeasureSystemText(win, text);
|
glwSize textSize = glwMeasureSystemText(win, text);
|
||||||
|
@ -569,14 +610,16 @@ int glwImCheck(glwWin *win, int id, int x, int y, char *text, int checked) {
|
||||||
glwImGui *imGUI = glwGetImGUI(win);
|
glwImGui *imGUI = glwGetImGUI(win);
|
||||||
glwSize textSize = glwMeasureSystemText(win, text);
|
glwSize textSize = glwMeasureSystemText(win, text);
|
||||||
int height = textSize.height;
|
int height = textSize.height;
|
||||||
int boxWidth = height;
|
int boxWidth = height * 0.8;
|
||||||
|
int boxHeight = boxWidth;
|
||||||
int width = boxWidth + textSize.height * (1 + GLW_HOR_AUTO_MARGIN * 2) +
|
int width = boxWidth + textSize.height * (1 + GLW_HOR_AUTO_MARGIN * 2) +
|
||||||
textSize.width;
|
textSize.width;
|
||||||
int oldActiveId = imGUI->activeId;
|
int oldActiveId = imGUI->activeId;
|
||||||
glwImGUIActiveIdCheck(imGUI, id, x, y, width, height);
|
glwImGUIActiveIdCheck(imGUI, id, x, y, width, height);
|
||||||
glwDrawButtonBackground(x, y, boxWidth, height,
|
glwDrawGradientBackground(x, y + (height - boxHeight) / 2,
|
||||||
|
boxWidth, boxHeight,
|
||||||
(imGUI->activeId == id || checked) ?
|
(imGUI->activeId == id || checked) ?
|
||||||
GLW_CTRL_STATE_PRESS : GLW_CTRL_STATE_NORMAL);
|
GLW_CTRL_STATE_PRESS : GLW_CTRL_STATE_NORMAL, 1);
|
||||||
glwDrawSystemText(win, x + textSize.height * GLW_HOR_AUTO_MARGIN + boxWidth,
|
glwDrawSystemText(win, x + textSize.height * GLW_HOR_AUTO_MARGIN + boxWidth,
|
||||||
y, text, GLW_SYSTEM_FONT_COLOR);
|
y, text, GLW_SYSTEM_FONT_COLOR);
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
@ -594,8 +637,8 @@ static int glwCalcListMaxWidth(glwWin *win, char **titles, int *icons,
|
||||||
int maxItemWidth = 0;
|
int maxItemWidth = 0;
|
||||||
|
|
||||||
for (i = 0; titles[i]; ++i) {
|
for (i = 0; titles[i]; ++i) {
|
||||||
glwSize textSize = glwMeasureSystemText(win, titles[i]);
|
glwSize textSize = glwMeasureLabel(win, titles[i], icons ? icons[i] : 0);
|
||||||
itemWidth = textSize.width * (1 + GLW_HOR_AUTO_MARGIN * 2);
|
itemWidth = textSize.width;
|
||||||
if (icons && icons[i]) {
|
if (icons && icons[i]) {
|
||||||
itemWidth += iconTable[icons[i]][ICON_ITEM_ORIGINAL_WIDTH];
|
itemWidth += iconTable[icons[i]][ICON_ITEM_ORIGINAL_WIDTH];
|
||||||
}
|
}
|
||||||
|
@ -610,15 +653,11 @@ static int glwCalcListMaxWidth(glwWin *win, char **titles, int *icons,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxItemWidth < GLW_MIN_TAB_WIDTH) {
|
|
||||||
maxItemWidth = GLW_MIN_TAB_WIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxItemWidth;
|
return maxItemWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int glwImButtonGroup(glwWin *win, int id, int x, int y, int parentWidth,
|
int glwImButtonGroup(glwWin *win, int id, int x, int y, char **titles,
|
||||||
char **list, int sel) {
|
int *icons, int sel) {
|
||||||
glwImGui *imGUI = glwGetImGUI(win);
|
glwImGui *imGUI = glwGetImGUI(win);
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
@ -627,16 +666,16 @@ int glwImButtonGroup(glwWin *win, int id, int x, int y, int parentWidth,
|
||||||
int listLen = 0;
|
int listLen = 0;
|
||||||
int offset;
|
int offset;
|
||||||
int maxItemWidth = 0;
|
int maxItemWidth = 0;
|
||||||
maxItemWidth = glwCalcListMaxWidth(win, list, 0, &height, &listLen);
|
unsigned int topColor = 0;
|
||||||
|
unsigned int bottomColor = 0;
|
||||||
|
maxItemWidth = glwCalcListMaxWidth(win, titles, icons, &height, &listLen);
|
||||||
width = maxItemWidth * listLen;
|
width = maxItemWidth * listLen;
|
||||||
left = listLen > 1 ? x + (parentWidth - width) / 2 :
|
left = x;
|
||||||
x + maxItemWidth * GLW_HOR_AUTO_MARGIN;
|
|
||||||
glwImGUIActiveIdCheck(imGUI, id, left, y, width, height);
|
glwImGUIActiveIdCheck(imGUI, id, left, y, width, height);
|
||||||
glwDrawRoundedRectGradientFill(left, y, width, height,
|
glwDrawRoundedRectGradientFill(left, y, width, height,
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
GLW_FILL_GRADIENT_COLOR_1, GLW_FILL_GRADIENT_COLOR_2);
|
GLW_FILL_GRADIENT_COLOR_1, GLW_FILL_GRADIENT_COLOR_2);
|
||||||
for (i = 0, offset = left; list[i]; ++i) {
|
for (i = 0, offset = left; titles[i]; ++i) {
|
||||||
glwSize textSize = glwMeasureSystemText(win, list[i]);
|
|
||||||
if (imGUI->activeId == id) {
|
if (imGUI->activeId == id) {
|
||||||
int hit = glwPointTest(imGUI->mouseX, imGUI->mouseY, offset, y,
|
int hit = glwPointTest(imGUI->mouseX, imGUI->mouseY, offset, y,
|
||||||
maxItemWidth, height, 0);
|
maxItemWidth, height, 0);
|
||||||
|
@ -645,33 +684,38 @@ int glwImButtonGroup(glwWin *win, int id, int x, int y, int parentWidth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sel == i) {
|
if (sel == i) {
|
||||||
|
topColor = GLW_FILL_GRADIENT_COLOR_1_H;
|
||||||
|
bottomColor = GLW_FILL_GRADIENT_COLOR_2_H;
|
||||||
|
if (imGUI->activeId == id) {
|
||||||
|
glwSwapColor(topColor, bottomColor);
|
||||||
|
}
|
||||||
if (1 == listLen) {
|
if (1 == listLen) {
|
||||||
glwDrawRoundedRectGradientFill(left, y, width, height,
|
glwDrawRoundedRectGradientFill(left, y, width, height,
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
GLW_FILL_GRADIENT_COLOR_1_H, GLW_FILL_GRADIENT_COLOR_2_H);
|
topColor, bottomColor);
|
||||||
} else {
|
} else {
|
||||||
if (0 == i) {
|
if (0 == i) {
|
||||||
glwDrawLeftRoundedRectGradientFill(offset, y,
|
glwDrawLeftRoundedRectGradientFill(offset, y,
|
||||||
maxItemWidth, height,
|
maxItemWidth, height,
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
GLW_FILL_GRADIENT_COLOR_1_H, GLW_FILL_GRADIENT_COLOR_2_H);
|
topColor, bottomColor);
|
||||||
} else if (listLen - 1 == i) {
|
} else if (listLen - 1 == i) {
|
||||||
glwDrawRightRoundedRectGradientFill(offset, y,
|
glwDrawRightRoundedRectGradientFill(offset, y,
|
||||||
maxItemWidth, height,
|
maxItemWidth, height,
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
GLW_FILL_GRADIENT_COLOR_1_H, GLW_FILL_GRADIENT_COLOR_2_H);
|
topColor, bottomColor);
|
||||||
} else {
|
} else {
|
||||||
glwDrawRectGradientFill(offset, y,
|
glwDrawRectGradientFill(offset, y,
|
||||||
maxItemWidth, height,
|
maxItemWidth, height,
|
||||||
GLW_FILL_GRADIENT_COLOR_1_H, GLW_FILL_GRADIENT_COLOR_2_H);
|
topColor, bottomColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 != i) {
|
if (0 != i) {
|
||||||
glwDrawVLine(offset, y, 1, height, GLW_BORDER_COLOR_2);
|
glwDrawVLine(offset, y, 1, height, GLW_BORDER_COLOR_2);
|
||||||
}
|
}
|
||||||
glwDrawSystemText(win, offset + (maxItemWidth - textSize.width) / 2,
|
glwDrawLabel(win, offset, y, titles[i], icons ? icons[i] : 0,
|
||||||
y + height * 0.1, list[i], GLW_SYSTEM_FONT_COLOR);
|
GLW_SYSTEM_FONT_COLOR);
|
||||||
offset += maxItemWidth;
|
offset += maxItemWidth;
|
||||||
}
|
}
|
||||||
imGUI->nextX = offset;
|
imGUI->nextX = offset;
|
||||||
|
@ -692,6 +736,9 @@ int glwImTabBox(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
int offset;
|
int offset;
|
||||||
int maxItemWidth = 0;
|
int maxItemWidth = 0;
|
||||||
maxItemWidth = glwCalcListMaxWidth(win, titles, icons, &tabHeight, &listLen);
|
maxItemWidth = glwCalcListMaxWidth(win, titles, icons, &tabHeight, &listLen);
|
||||||
|
if (maxItemWidth < GLW_MIN_TAB_WIDTH) {
|
||||||
|
maxItemWidth = GLW_MIN_TAB_WIDTH;
|
||||||
|
}
|
||||||
tabWidth = maxItemWidth * listLen;
|
tabWidth = maxItemWidth * listLen;
|
||||||
left = x;
|
left = x;
|
||||||
imGUI->nextX = x;
|
imGUI->nextX = x;
|
||||||
|
@ -707,7 +754,6 @@ int glwImTabBox(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
glwDrawVLine(x + width - 1, y + tabHeight, 1, height - tabHeight,
|
glwDrawVLine(x + width - 1, y + tabHeight, 1, height - tabHeight,
|
||||||
GLW_BORDER_COLOR_1);
|
GLW_BORDER_COLOR_1);
|
||||||
for (i = 0, offset = left; titles[i]; ++i) {
|
for (i = 0, offset = left; titles[i]; ++i) {
|
||||||
glwSize textSize = glwMeasureSystemText(win, titles[i]);
|
|
||||||
if (imGUI->activeId == id) {
|
if (imGUI->activeId == id) {
|
||||||
int hit = glwPointTest(imGUI->mouseX, imGUI->mouseY, offset, y,
|
int hit = glwPointTest(imGUI->mouseX, imGUI->mouseY, offset, y,
|
||||||
maxItemWidth, tabHeight, 0);
|
maxItemWidth, tabHeight, 0);
|
||||||
|
@ -724,17 +770,8 @@ int glwImTabBox(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
GLW_BUTTON_CORNER_RADIUS,
|
GLW_BUTTON_CORNER_RADIUS,
|
||||||
GLW_TAB_FILL_GRADIENT_COLOR_1, GLW_TAB_FILL_GRADIENT_COLOR_2);
|
GLW_TAB_FILL_GRADIENT_COLOR_1, GLW_TAB_FILL_GRADIENT_COLOR_2);
|
||||||
}
|
}
|
||||||
if (icons && icons[i]) {
|
glwDrawLabel(win, offset, y, titles[i], icons ? icons[i] : 0,
|
||||||
int iconIdx = icons[i] - 1;
|
GLW_SYSTEM_FONT_COLOR);
|
||||||
glwDrawSystemIcon(win, offset + textSize.height / 2,
|
|
||||||
y + tabHeight * GLW_VER_AUTO_MARGIN, icons[i], GLW_SYSTEM_FONT_COLOR);
|
|
||||||
glwDrawSystemText(win, offset + textSize.height / 2 +
|
|
||||||
iconTable[iconIdx][ICON_ITEM_ORIGINAL_WIDTH] + textSize.height / 2,
|
|
||||||
y + tabHeight * GLW_VER_AUTO_MARGIN, titles[i], GLW_SYSTEM_FONT_COLOR);
|
|
||||||
} else {
|
|
||||||
glwDrawSystemText(win, offset + (maxItemWidth - textSize.width) / 2,
|
|
||||||
y + tabHeight * GLW_VER_AUTO_MARGIN, titles[i], GLW_SYSTEM_FONT_COLOR);
|
|
||||||
}
|
|
||||||
offset += maxItemWidth;
|
offset += maxItemWidth;
|
||||||
}
|
}
|
||||||
return sel;
|
return sel;
|
||||||
|
@ -836,4 +873,33 @@ int glwMouseY(glwWin *win) {
|
||||||
return ctx->y;
|
return ctx->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int glwImMenu(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
|
char **titles, int sel) {
|
||||||
|
glwImGui *imGUI = glwGetImGUI(win);
|
||||||
|
int left = 0;
|
||||||
|
int i;
|
||||||
|
int listLen = 0;
|
||||||
|
int offset;
|
||||||
|
int maxItemWidth = 0;
|
||||||
|
maxItemWidth = glwCalcListMaxWidth(win, titles, 0, &height, &listLen);
|
||||||
|
left = x + glwGetLineHeight(win) / 2;
|
||||||
|
glwImGUIActiveIdCheck(imGUI, id, left, y, width, height);
|
||||||
|
glwDrawRectGradientFill(x, y, width, height,
|
||||||
|
GLW_MENU_BACKGROUND_COLOR, GLW_MENU_BACKGROUND_COLOR);
|
||||||
|
for (i = 0, offset = left; titles[i]; ++i) {
|
||||||
|
if (imGUI->activeId == id) {
|
||||||
|
int hit = glwPointTest(imGUI->mouseX, imGUI->mouseY, offset, y,
|
||||||
|
maxItemWidth, height, 0);
|
||||||
|
if (hit) {
|
||||||
|
sel = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glwDrawLabel(win, offset, y, titles[i], 0, sel == i ?
|
||||||
|
GLW_SYSTEM_FONT_COLOR_H : GLW_SYSTEM_FONT_COLOR);
|
||||||
|
offset += maxItemWidth;
|
||||||
|
}
|
||||||
|
glwDrawHLine(x, y + height - 1, width, 1, GLW_BORDER_COLOR_1);
|
||||||
|
imGUI->nextX = x;
|
||||||
|
imGUI->nextY = y + height;
|
||||||
|
return sel;
|
||||||
|
}
|
||||||
|
|
|
@ -48,11 +48,11 @@ void glwWheelFunc(glwWin *win, void(*func)(glwWin *win, float delta));
|
||||||
#define glwR(rgb) ((float)(((rgb) >> 16) & 0xff) / 255)
|
#define glwR(rgb) ((float)(((rgb) >> 16) & 0xff) / 255)
|
||||||
#define glwG(rgb) ((float)(((rgb) >> 8) & 0xff) / 255)
|
#define glwG(rgb) ((float)(((rgb) >> 8) & 0xff) / 255)
|
||||||
#define glwB(rgb) ((float)(((rgb)) & 0xff) / 255)
|
#define glwB(rgb) ((float)(((rgb)) & 0xff) / 255)
|
||||||
int glwImButton(glwWin *win, int id, int x, int y, char *text);
|
int glwImButton(glwWin *win, int id, int x, int y, char *text, int icon);
|
||||||
int glwImCheck(glwWin *win, int id, int x, int y, char *text, int checked);
|
int glwImCheck(glwWin *win, int id, int x, int y, char *text, int checked);
|
||||||
int glwImDropdownBox(glwWin *win, int id, int x, int y, char *text);
|
int glwImDropdownBox(glwWin *win, int id, int x, int y, char *text);
|
||||||
int glwImButtonGroup(glwWin *win, int id, int x, int y, int parentWidth,
|
int glwImButtonGroup(glwWin *win, int id, int x, int y, char **titles,
|
||||||
char **list, int sel);
|
int *icons, int sel);
|
||||||
int glwImPanel(glwWin *win, int id, int x, int y, int width, int height);
|
int glwImPanel(glwWin *win, int id, int x, int y, int width, int height);
|
||||||
int glwImTabBox(glwWin *win, int id, int x, int y, int width, int height,
|
int glwImTabBox(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
char **titles, int *icons, int sel);
|
char **titles, int *icons, int sel);
|
||||||
|
@ -65,6 +65,8 @@ int glwPointTest(int x, int y, int left, int top, int width, int height,
|
||||||
int allowOffset);
|
int allowOffset);
|
||||||
int glwMouseX(glwWin *win);
|
int glwMouseX(glwWin *win);
|
||||||
int glwMouseY(glwWin *win);
|
int glwMouseY(glwWin *win);
|
||||||
|
int glwImMenu(glwWin *win, int id, int x, int y, int width, int height,
|
||||||
|
char **titles, int sel);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,22 @@
|
||||||
#define GLW_SYSTEM_FONT_WEIGHT 10
|
#define GLW_SYSTEM_FONT_WEIGHT 10
|
||||||
#define GLW_SYSTEM_FONT_SIZE 20
|
#define GLW_SYSTEM_FONT_SIZE 20
|
||||||
#define GLW_SYSTEM_FONT_COLOR 0xb9b9b9
|
#define GLW_SYSTEM_FONT_COLOR 0xb9b9b9
|
||||||
|
#define GLW_SYSTEM_FONT_COLOR_H 0xffffff
|
||||||
|
|
||||||
#define GLW_SMALL_ROUNDED_CORNER_SLICES 5
|
#define GLW_SMALL_ROUNDED_CORNER_SLICES 5
|
||||||
|
|
||||||
#define GLW_BORDER_COLOR_1 0x000000
|
#define GLW_BORDER_COLOR_1 0x000000
|
||||||
#define GLW_BORDER_COLOR_2 0x000000
|
#define GLW_BORDER_COLOR_2 0x000000
|
||||||
|
|
||||||
#define GLW_FILL_GRADIENT_COLOR_1 0x424242
|
#define GLW_FILL_GRADIENT_COLOR_1 0x2f2f2f //0x424242
|
||||||
#define GLW_FILL_GRADIENT_COLOR_2 0x242424
|
#define GLW_FILL_GRADIENT_COLOR_2 0x1f1f1f //0x111111 //0x242424
|
||||||
|
|
||||||
#define GLW_FILL_GRADIENT_COLOR_1_H 0x3795fa
|
#define GLW_FILL_GRADIENT_COLOR_1_H 0xf77100
|
||||||
#define GLW_FILL_GRADIENT_COLOR_2_H 0x242424
|
#define GLW_FILL_GRADIENT_COLOR_2_H 0x713300
|
||||||
|
|
||||||
#define GLW_BUTTON_CORNER_RADIUS 5
|
#define GLW_BUTTON_CORNER_RADIUS 5
|
||||||
|
|
||||||
#define GLW_CHECK_COLOR 0x000000
|
#define GLW_CHECK_COLOR GLW_BORDER_COLOR_2
|
||||||
|
|
||||||
#define GLW_TAB_FILL_GRADIENT_COLOR_1 GLW_FILL_GRADIENT_COLOR_1
|
#define GLW_TAB_FILL_GRADIENT_COLOR_1 GLW_FILL_GRADIENT_COLOR_1
|
||||||
#define GLW_TAB_FILL_GRADIENT_COLOR_2 GLW_FILL_GRADIENT_COLOR_2
|
#define GLW_TAB_FILL_GRADIENT_COLOR_2 GLW_FILL_GRADIENT_COLOR_2
|
||||||
|
@ -37,4 +38,6 @@
|
||||||
|
|
||||||
#define GLW_MIN_TAB_WIDTH 120
|
#define GLW_MIN_TAB_WIDTH 120
|
||||||
|
|
||||||
|
#define GLW_MENU_BACKGROUND_COLOR 0x181818
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue