From: <av...@us...> - 2009-12-17 03:10:26
|
Revision: 3436 http://sc2.svn.sourceforge.net/sc2/?rev=3436&view=rev Author: avolkov Date: 2009-12-17 03:10:18 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Oscilloscope and slider cleanup: determine the dimensions dynamically instead of relying on constants Modified Paths: -------------- trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/oscill.c trunk/sc2/src/uqm/oscill.h Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-12-17 02:47:40 UTC (rev 3435) +++ trunk/sc2/src/uqm/comm.c 2009-12-17 03:10:18 UTC (rev 3436) @@ -491,20 +491,11 @@ static void InitSpeechGraphics (void) { - RECT r; - RECT sr; - FRAME f; + InitOscilloscope (SetAbsFrameIndex (ActivityFrame, 9)); - InitOscilloscope (0, 0, RADAR_WIDTH, RADAR_HEIGHT, - SetAbsFrameIndex (ActivityFrame, 9)); - - 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); + InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, + SetAbsFrameIndex (ActivityFrame, 5), + SetAbsFrameIndex (ActivityFrame, 2)); } static void Modified: trunk/sc2/src/uqm/oscill.c =================================================================== --- trunk/sc2/src/uqm/oscill.c 2009-12-17 02:47:40 UTC (rev 3435) +++ trunk/sc2/src/uqm/oscill.c 2009-12-17 03:10:18 UTC (rev 3436) @@ -18,9 +18,6 @@ #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" // for OffScreenContext #include "libs/graphics/gfx_common.h" @@ -33,12 +30,13 @@ static int scope_init = 0; static FRAME scopeWork; static Color scopeColor; +static EXTENT scopeSize; BOOLEAN oscillDisabled = FALSE; void -InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) +InitOscilloscope (FRAME scopeBg) { - scope_frame = f; + scope_frame = scopeBg; if (!scope_init) { EXTENT size = GetFrameBounds (scope_frame); @@ -51,11 +49,12 @@ WANT_PIXMAP | MAPPED_TO_DISPLAY, size.width, size.height, 1)); + // assume and subtract the borders + scopeSize.width = size.width - 2; + scopeSize.height = size.height - 2; + scope_init = 1; } - /* remove compiler warnings */ - (void) x; - (void) y; } void @@ -72,12 +71,15 @@ DrawOscilloscope (void) { STAMP s; - BYTE scope_data[RADAR_WIDTH - 2]; + BYTE scope_data[128]; if (oscillDisabled) 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; CONTEXT oldContext; @@ -94,7 +96,7 @@ // draw the scope lines SetContextForeGroundColor (scopeColor); - for (i = 0; i < RADAR_WIDTH - 3; ++i) + for (i = 0; i < scopeSize.width - 1; ++i) { LINE line; @@ -139,15 +141,20 @@ */ void -InitSlider (int x, int y, int width, int height, - int bwidth, int bheight, FRAME f) +InitSlider (int x, int y, int width, FRAME sliderFrame, FRAME buttonFrame) { + EXTENT sliderSize = GetFrameBounds (sliderFrame); + EXTENT buttonSize = GetFrameBounds (buttonFrame); + sliderStamp.origin.x = x; sliderStamp.origin.y = y; - sliderStamp.frame = f; + sliderStamp.frame = sliderFrame; + buttonStamp.origin.x = x; - buttonStamp.origin.y = y - ((bheight - height) >> 1); - sliderSpace = width - bwidth; + buttonStamp.origin.y = y - ((buttonSize.height - sliderSize.height) / 2); + buttonStamp.frame = buttonFrame; + + sliderSpace = width - buttonSize.width; } void Modified: trunk/sc2/src/uqm/oscill.h =================================================================== --- trunk/sc2/src/uqm/oscill.h 2009-12-17 02:47:40 UTC (rev 3435) +++ trunk/sc2/src/uqm/oscill.h 2009-12-17 03:10:18 UTC (rev 3436) @@ -23,13 +23,12 @@ extern BOOLEAN sliderDisabled; extern BOOLEAN oscillDisabled; -extern void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, - FRAME f); +extern void InitOscilloscope (FRAME scopeBg); extern void DrawOscilloscope (void); extern void UninitOscilloscope (void); -extern void InitSlider (int x, int y, int width, int height, - int bwidth, int bheight, FRAME f); +extern void InitSlider (int x, int y, int width, FRAME sliderFrame, + FRAME buttonFrame); extern void SetSliderImage (FRAME f); void DrawSlider (void); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |