| 1 |
/************************************************************************* |
| 2 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* https://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: Details at https://graphviz.org |
| 9 |
*************************************************************************/ |
| 10 |
|
| 11 |
#include "config.h" |
| 12 |
|
| 13 |
#include <glcomp/glcomppanel.h> |
| 14 |
#include <glcomp/glcompfont.h> |
| 15 |
#include <glcomp/glcompset.h> |
| 16 |
#include <glcomp/glcomptexture.h> |
| 17 |
#include <glcomp/glutils.h> |
| 18 |
#include <stdbool.h> |
| 19 |
#include <util/alloc.h> |
| 20 |
|
| 21 |
static void glCompPanelDraw(void *o) { |
| 22 |
glCompPanel *p = o; |
| 23 |
glCompRect r; |
| 24 |
glCompCommon ref = p->base.common; |
| 25 |
glCompCalcWidget(p->base.common.parent, &p->base.common, &ref); |
| 26 |
|
| 27 |
if (!p->base.common.visible) |
| 28 |
return; |
| 29 |
/*draw shadow */ |
| 30 |
const float SHADOW_COLOR_R = 0.0f; |
| 31 |
const float SHADOW_COLOR_G = 0.0f; |
| 32 |
const float SHADOW_COLOR_B = 0.0f; |
| 33 |
const float SHADOW_COLOR_A = 0.3f; |
| 34 |
glColor4f(SHADOW_COLOR_R, SHADOW_COLOR_G, SHADOW_COLOR_B, SHADOW_COLOR_A); |
| 35 |
r.h = p->shadowwidth; |
| 36 |
r.w = ref.width; |
| 37 |
r.pos.x = ref.pos.x + p->shadowwidth; |
| 38 |
r.pos.y = ref.pos.y - p->shadowwidth; |
| 39 |
r.pos.z = -0.001f; |
| 40 |
glCompDrawRectangle(&r); |
| 41 |
r.h = ref.height; |
| 42 |
r.w = p->shadowwidth; |
| 43 |
r.pos.x = ref.pos.x + ref.width; |
| 44 |
r.pos.y = ref.pos.y - p->shadowwidth; |
| 45 |
r.pos.z = -0.001f; |
| 46 |
glCompDrawRectangle(&r); |
| 47 |
/*draw panel */ |
| 48 |
glCompDrawRectPrism(ref.pos, ref.width, ref.height, |
| 49 |
p->base.common.borderWidth, ref.color, true); |
| 50 |
} |
| 51 |
|
| 52 |
glCompPanel *glCompPanelNew(void *parentObj, float x, float y, float w, |
| 53 |
float h) { |
| 54 |
glCompPanel *p = gv_alloc(sizeof(glCompPanel)); |
| 55 |
glCompInitCommon(&p->base, parentObj, x, y); |
| 56 |
|
| 57 |
p->shadowwidth = GLCOMPSET_PANEL_SHADOW_WIDTH; |
| 58 |
p->base.common.borderWidth = GLCOMPSET_PANEL_BORDERWIDTH; |
| 59 |
|
| 60 |
p->base.common.width = w; |
| 61 |
p->base.common.height = h; |
| 62 |
|
| 63 |
glDeleteFont(&p->base.common.font); |
| 64 |
p->base.common.font = glNewFontFromParent(&p->base, NULL); |
| 65 |
p->text = NULL; |
| 66 |
p->base.common.functions.draw = glCompPanelDraw; |
| 67 |
return p; |
| 68 |
} |