parent
3295be55e6
commit
3b354f16ca
@ -135,6 +135,7 @@ void Emgui_drawTextFlipped(const char* text, int x, int y, uint32_t color);
|
||||
|
||||
void Emgui_staticImage(const char* filename);
|
||||
void Emgui_fill(uint32_t color, int x, int y, int w, int h);
|
||||
void Emgui_fillStipple(uint32_t color, int x, int y, int w, int h);
|
||||
void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h);
|
||||
void Emgui_drawBorder(uint32_t color0, uint32_t color1, int x, int y, int w, int h);
|
||||
void Emgui_drawDots(uint32_t color, int* coords, int count);
|
||||
|
||||
@ -236,6 +236,58 @@ void createDefaultFont()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void createStipplePattern()
|
||||
{
|
||||
static unsigned char pattern[32*34];
|
||||
static unsigned char tempData[32 * 34] = { 0 };
|
||||
int x, y, i, startX = 8, width = 16, t = 0;
|
||||
|
||||
for (y = 0; y < 32; ++y)
|
||||
{
|
||||
unsigned char* line = &tempData[y * 32];
|
||||
|
||||
for (i = 0; i < width; ++i)
|
||||
line[startX + i] = 0x1;
|
||||
|
||||
/*
|
||||
for (int i = 0; i < width; ++i)
|
||||
{
|
||||
int p = startX + i;
|
||||
|
||||
if (p <= -1)
|
||||
p = 32 + p;
|
||||
|
||||
line[p] = 0x1;
|
||||
}
|
||||
startX--;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// pack data to bits
|
||||
|
||||
for (x = 0; x < (32 * 32) / 8; ++x)
|
||||
{
|
||||
unsigned char p = 0;
|
||||
|
||||
p = tempData[t + 0] << 0;
|
||||
p |= tempData[t + 1] << 1;
|
||||
p |= tempData[t + 2] << 2;
|
||||
p |= tempData[t + 3] << 3;
|
||||
p |= tempData[t + 4] << 4;
|
||||
p |= tempData[t + 5] << 5;
|
||||
p |= tempData[t + 6] << 6;
|
||||
p |= tempData[t + 7] << 7;
|
||||
|
||||
pattern[x] = p;
|
||||
t += 8;
|
||||
}
|
||||
|
||||
EMGFXBackend_setStippleMask(pattern);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Emgui_loadFontBitmap(const char* buffer, int size, enum EmguiMemoryLocation location,
|
||||
int rangeStart, int rangeEnd, EmguiFontLayout* layout)
|
||||
|
||||
@ -318,6 +370,7 @@ bool Emgui_create()
|
||||
const uint32_t size = 1024 * 1024;
|
||||
LinearAllocator_create(&s_allocator, malloc(size), size);
|
||||
createDefaultFont();
|
||||
createStipplePattern();
|
||||
g_emguiGuiState.kbdItem = -1;
|
||||
return true;
|
||||
}
|
||||
@ -397,14 +450,7 @@ static bool Emgui_regionHitSlider(const EmguiControlInfo* control)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Emgui_fill(uint32_t color, int x, int y, int w, int h)
|
||||
{
|
||||
Emgui_fillGrad(color, color, x, y, w, h);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h)
|
||||
static void fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h, int stipple)
|
||||
{
|
||||
const int active_layer = s_activeLayer;
|
||||
struct DrawFillCommand* command = LinearAllocator_allocZero(&s_allocator, struct DrawFillCommand);
|
||||
@ -415,6 +461,7 @@ void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h
|
||||
command->height = h;
|
||||
command->color0 = color0;
|
||||
command->color1 = color1;
|
||||
command->stipple = stipple;
|
||||
|
||||
if (!s_renderData.layers[active_layer].fillCommands)
|
||||
{
|
||||
@ -426,6 +473,28 @@ void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h
|
||||
s_renderData.layers[active_layer].fillCommandsTail->next = command;
|
||||
s_renderData.layers[active_layer].fillCommandsTail = command;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Emgui_fill(uint32_t color, int x, int y, int w, int h)
|
||||
{
|
||||
Emgui_fillGrad(color, color, x, y, w, h);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Emgui_fillStipple(uint32_t color, int x, int y, int w, int h)
|
||||
{
|
||||
fillGrad(color, color, x, y, w, h, 1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h)
|
||||
{
|
||||
fillGrad(color0, color1, x, y, w, h, 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -104,6 +104,7 @@ void Emgui_beginHorizontalPanel();
|
||||
|
||||
void Emgui_setLayer(int layer);
|
||||
void Emgui_setScissor(int x, int y, int w, int h);
|
||||
void Emgui_setStipple(int enabled);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Font functions
|
||||
@ -133,6 +134,7 @@ void Emgui_drawTextFlipped(const char* text, int x, int y, uint32_t color);
|
||||
|
||||
void Emgui_staticImage(const char* filename);
|
||||
void Emgui_fill(uint32_t color, int x, int y, int w, int h);
|
||||
void Emgui_fillStipple(uint32_t color, int x, int y, int w, int h);
|
||||
void Emgui_fillGrad(uint32_t color0, uint32_t color1, int x, int y, int w, int h);
|
||||
void Emgui_drawBorder(uint32_t color0, uint32_t color1, int x, int y, int w, int h);
|
||||
void Emgui_drawDots(uint32_t color, int* coords, int count);
|
||||
|
||||
@ -74,6 +74,7 @@ struct DrawFillCommand
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
int stipple;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -10,6 +10,7 @@ void EMGFXBackend_render();
|
||||
|
||||
uint64_t EMGFXBackend_createFontTexture(void* imageBuffer, int w, int h);
|
||||
uint64_t EMGFXBackend_createTexture(void* imageBuffer, int w, int h, int comp);
|
||||
void EMGFXBackend_setStippleMask(unsigned char* mask);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -271,7 +271,6 @@ static void drawText(struct DrawTextCommand* commands, int fontId)
|
||||
static void drawFill(struct DrawFillCommand* command)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
while (command)
|
||||
@ -281,6 +280,12 @@ static void drawFill(struct DrawFillCommand* command)
|
||||
const float w = (float)command->width;
|
||||
const float h = (float)command->height;
|
||||
|
||||
if (command->stipple)
|
||||
{
|
||||
command = command->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
setColor(command->color0);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x + w, y);
|
||||
@ -293,6 +298,44 @@ static void drawFill(struct DrawFillCommand* command)
|
||||
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void drawFillStipple(struct DrawFillCommand* command)
|
||||
{
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
while (command)
|
||||
{
|
||||
const float x = (float)command->x;
|
||||
const float y = (float)command->y;
|
||||
const float w = (float)command->width;
|
||||
const float h = (float)command->height;
|
||||
|
||||
if (!command->stipple)
|
||||
{
|
||||
command = command->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
setColor(command->color0);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x + w, y);
|
||||
setColor(command->color1);
|
||||
glVertex2f(x + w, y + h);
|
||||
glVertex2f(x, y + h);
|
||||
|
||||
command = command->next;
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@ -369,6 +412,7 @@ void EMGFXBackend_render()
|
||||
}
|
||||
|
||||
drawFill(layer->fillCommands);
|
||||
drawFillStipple(layer->fillCommands);
|
||||
|
||||
for (i = 0; i < EMGUI_MAX_FONTS; ++i)
|
||||
{
|
||||
@ -388,4 +432,12 @@ void EMGFXBackend_render()
|
||||
swapBuffers();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EMGFXBackend_setStippleMask(unsigned char* mask)
|
||||
{
|
||||
glPolygonStipple(mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -447,11 +447,21 @@ static int renderChannel(struct TrackInfo* info, int startX, Track* trackData, b
|
||||
|
||||
if (y != 0)
|
||||
{
|
||||
bool overlapping = false;
|
||||
|
||||
if (TrackData_hasBookmark(info->trackData, y))
|
||||
{
|
||||
overlapping = true;
|
||||
Emgui_fill(bookmark_color, startX, y_offset - font_size_half, size, 8);
|
||||
}
|
||||
|
||||
if (TrackData_hasLoopmark(info->trackData, y))
|
||||
Emgui_fill(loopmark_color , startX, y_offset - font_size_half, size, 8);
|
||||
{
|
||||
if (!overlapping)
|
||||
Emgui_fill(loopmark_color , startX, y_offset - font_size_half, size, 8);
|
||||
else
|
||||
Emgui_fillStipple(loopmark_color , startX, y_offset - font_size_half, size, 8);
|
||||
}
|
||||
}
|
||||
|
||||
y_offset += font_size;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user