Oscilloscope and slider cleanup: determine the dimensions dynamically instead of relying on constants

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3436 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-17 03:10:18 +00:00
parent 877e9ced23
commit f46c5c7ada
3 changed files with 30 additions and 33 deletions
+4 -13
View File
@@ -491,20 +491,11 @@ FeedbackPlayerPhrase (UNICODE *pStr)
static void static void
InitSpeechGraphics (void) InitSpeechGraphics (void)
{ {
RECT r; InitOscilloscope (SetAbsFrameIndex (ActivityFrame, 9));
RECT sr;
FRAME f;
InitOscilloscope (0, 0, RADAR_WIDTH, RADAR_HEIGHT, InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH,
SetAbsFrameIndex (ActivityFrame, 9)); SetAbsFrameIndex (ActivityFrame, 5),
SetAbsFrameIndex (ActivityFrame, 2));
f = SetAbsFrameIndex (ActivityFrame, 2);
GetFrameRect (f, &r);
SetSliderImage (f);
f = SetAbsFrameIndex (ActivityFrame, 5);
GetFrameRect (f, &sr);
InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, sr.extent.height,
r.extent.width, r.extent.height, f);
} }
static void static void
+23 -16
View File
@@ -18,9 +18,6 @@
#include "oscill.h" #include "oscill.h"
// XXX: we should not refer to units.h here because we should not be
// using RADAR_WIDTH constants!
#include "units.h"
#include "setup.h" #include "setup.h"
// for OffScreenContext // for OffScreenContext
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
@@ -33,12 +30,13 @@ static FRAME scope_frame;
static int scope_init = 0; static int scope_init = 0;
static FRAME scopeWork; static FRAME scopeWork;
static Color scopeColor; static Color scopeColor;
static EXTENT scopeSize;
BOOLEAN oscillDisabled = FALSE; BOOLEAN oscillDisabled = FALSE;
void void
InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) InitOscilloscope (FRAME scopeBg)
{ {
scope_frame = f; scope_frame = scopeBg;
if (!scope_init) if (!scope_init)
{ {
EXTENT size = GetFrameBounds (scope_frame); EXTENT size = GetFrameBounds (scope_frame);
@@ -51,11 +49,12 @@ InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f)
WANT_PIXMAP | MAPPED_TO_DISPLAY, WANT_PIXMAP | MAPPED_TO_DISPLAY,
size.width, size.height, 1)); size.width, size.height, 1));
// assume and subtract the borders
scopeSize.width = size.width - 2;
scopeSize.height = size.height - 2;
scope_init = 1; scope_init = 1;
} }
/* remove compiler warnings */
(void) x;
(void) y;
} }
void void
@@ -72,12 +71,15 @@ void
DrawOscilloscope (void) DrawOscilloscope (void)
{ {
STAMP s; STAMP s;
BYTE scope_data[RADAR_WIDTH - 2]; BYTE scope_data[128];
if (oscillDisabled) if (oscillDisabled)
return; return;
if (GraphForegroundStream (scope_data, RADAR_WIDTH - 2, RADAR_HEIGHT - 2)) assert (scopeSize.width <= sizeof scope_data);
assert (scopeSize.height < 256);
if (GraphForegroundStream (scope_data, scopeSize.width, scopeSize.height))
{ {
int i; int i;
CONTEXT oldContext; CONTEXT oldContext;
@@ -94,7 +96,7 @@ DrawOscilloscope (void)
// draw the scope lines // draw the scope lines
SetContextForeGroundColor (scopeColor); SetContextForeGroundColor (scopeColor);
for (i = 0; i < RADAR_WIDTH - 3; ++i) for (i = 0; i < scopeSize.width - 1; ++i)
{ {
LINE line; LINE line;
@@ -139,15 +141,20 @@ BOOLEAN sliderDisabled = FALSE;
*/ */
void void
InitSlider (int x, int y, int width, int height, InitSlider (int x, int y, int width, FRAME sliderFrame, FRAME buttonFrame)
int bwidth, int bheight, FRAME f)
{ {
EXTENT sliderSize = GetFrameBounds (sliderFrame);
EXTENT buttonSize = GetFrameBounds (buttonFrame);
sliderStamp.origin.x = x; sliderStamp.origin.x = x;
sliderStamp.origin.y = y; sliderStamp.origin.y = y;
sliderStamp.frame = f; sliderStamp.frame = sliderFrame;
buttonStamp.origin.x = x; buttonStamp.origin.x = x;
buttonStamp.origin.y = y - ((bheight - height) >> 1); buttonStamp.origin.y = y - ((buttonSize.height - sliderSize.height) / 2);
sliderSpace = width - bwidth; buttonStamp.frame = buttonFrame;
sliderSpace = width - buttonSize.width;
} }
void void
+3 -4
View File
@@ -23,13 +23,12 @@
extern BOOLEAN sliderDisabled; extern BOOLEAN sliderDisabled;
extern BOOLEAN oscillDisabled; extern BOOLEAN oscillDisabled;
extern void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, extern void InitOscilloscope (FRAME scopeBg);
FRAME f);
extern void DrawOscilloscope (void); extern void DrawOscilloscope (void);
extern void UninitOscilloscope (void); extern void UninitOscilloscope (void);
extern void InitSlider (int x, int y, int width, int height, extern void InitSlider (int x, int y, int width, FRAME sliderFrame,
int bwidth, int bheight, FRAME f); FRAME buttonFrame);
extern void SetSliderImage (FRAME f); extern void SetSliderImage (FRAME f);
void DrawSlider (void); void DrawSlider (void);