Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
28 KB
Referenced Files
None
Subscribers
None
diff --git a/util/gui/box.cpp b/util/gui/box.cpp
index 9b0cd19b..b6c29d26 100644
--- a/util/gui/box.cpp
+++ b/util/gui/box.cpp
@@ -1,73 +1,75 @@
#include "util/bitmap.h"
#include "util/trans-bitmap.h"
#include "box.h"
#include "menu/menu.h"
#include "util/font.h"
using namespace Gui;
Box::Box(){
// Nothing yet
}
Box::Box( const Box & b ){
this->location = b.location;
+ this->transforms = b.transforms;
this->workArea = b.workArea;
}
Box::~Box(){
// Nothing yet
}
Box &Box::operator=( const Box &copy){
location = copy.location;
+ transforms = copy.transforms;
workArea = copy.workArea;
return *this;
}
// Logic
void Box::act(const Font & font){
// Nothing yet
}
// Render
void Box::render(const Graphics::Bitmap & work){
checkWorkArea();
// Check if we are using a rounded box
if (transforms.getRadius() > 0){
roundRectFill(*workArea, (int)transforms.getRadius(), 0, 0, location.getWidth()-1, location.getHeight()-1, colors.body);
roundRect(*workArea, (int)transforms.getRadius(), 0, 0, location.getWidth()-1, location.getHeight()-1, colors.border);
} else {
workArea->rectangleFill(0, 0, location.getWidth()-1, location.getHeight()-1, colors.body );
workArea->rectangle(0, 0, location.getWidth()-1, location.getHeight()-1, colors.border );
}
Graphics::Bitmap::transBlender( 0, 0, 0, colors.bodyAlpha );
// workArea->drawingMode( Bitmap::MODE_TRANS );
workArea->translucent().draw(location.getX(), location.getY(), work);
// work.drawingMode( Bitmap::MODE_SOLID );
}
void Box::messageDialog(int centerWidth, int centerHeight, const std::string & message, int radius){
/* FIXME Get rid of this */
#if 0
const Font &vFont = Font::getFont(OldMenu::Menu::getFont(),OldMenu::Menu::getFontWidth(),OldMenu::Menu::getFontHeight());
const int width = vFont.textLength(message.c_str()) + 10;
const int height = vFont.getHeight() + 10;
const int x = (centerWidth/2) - (width/2);
const int y = (centerHeight/2) - (height/2);
Box dialog;
dialog.location.setDimensions(width, height);
dialog.location.setRadius(radius);
dialog.colors.body = Bitmap::makeColor(0,0,0);
dialog.colors.bodyAlpha = 200;
dialog.colors.border = Bitmap::makeColor(255,255,255);
dialog.colors.borderAlpha = 255;
Bitmap temp = Bitmap::temporaryBitmap(width,height);
dialog.render(temp);
vFont.printf( 5, 5, Bitmap::makeColor(255,255,255), temp, message, -1);
temp.BlitToScreen(x,y);
#endif
}
diff --git a/util/gui/context-box.cpp b/util/gui/context-box.cpp
index 8dbad74f..9cca633e 100644
--- a/util/gui/context-box.cpp
+++ b/util/gui/context-box.cpp
@@ -1,428 +1,429 @@
#include "util/bitmap.h"
#include "util/trans-bitmap.h"
#include "context-box.h"
#include "util/font.h"
#include <math.h>
static const double FONT_SPACER = 1.3;
static const int GradientMax = 50;
static int selectedGradientStart(){
static int color = Graphics::makeColor(19, 167, 168);
return color;
}
static int selectedGradientEnd(){
static int color = Graphics::makeColor(27, 237, 239);
return color;
}
using namespace std;
namespace Gui{
ContextItem::ContextItem(){
}
ContextItem::~ContextItem(){
}
bool ContextItem::isAdjustable(){
return false;
}
int ContextItem::getLeftColor(){
return 0;
}
int ContextItem::getRightColor(){
return 0;
}
void ContextItem::draw(int x, int y, int color, const Graphics::Bitmap & where, const Font & font) const {
font.printf(x, y, color, where, getName(), 0);
}
int ContextItem::size(const Font & font) const {
return font.textLength(getName().c_str());
}
ContextBox::ContextBox():
fadeState(NotActive),
/*
fontWidth(0),
fontHeight(0),
*/
fadeSpeed(12),
fadeAlpha(0),
cursorCenter(0),
cursorLocation(0),
scrollWait(4),
selectedGradient(GradientMax, selectedGradientStart(), selectedGradientEnd()),
useGradient(true),
renderOnlyText(false){
}
ContextBox::ContextBox( const ContextBox & copy ):
fadeState(NotActive),
selectedGradient(GradientMax, selectedGradientStart(), selectedGradientEnd()),
renderOnlyText(false){
this->list = copy.list;
// this->context = copy.context;
/*
this->font = copy.font;
this->fontWidth = copy.fontWidth;
this->fontHeight = copy.fontHeight;
*/
this->fadeSpeed = copy.fadeSpeed;
this->fadeAlpha = copy.fadeAlpha;
this->cursorCenter = copy.cursorCenter;
this->cursorLocation = copy.cursorLocation;
this->scrollWait = copy.scrollWait;
this->useGradient = copy.useGradient;
this->renderOnlyText = copy.renderOnlyText;
}
ContextBox::~ContextBox(){
}
ContextBox & ContextBox::operator=( const ContextBox & copy){
this->fadeState = NotActive;
this->list = copy.list;
// this->context = copy.context;
/*
this->font = copy.font;
this->fontWidth = copy.fontWidth;
this->fontHeight = copy.fontHeight;
*/
this->fadeSpeed = copy.fadeSpeed;
this->fadeAlpha = copy.fadeAlpha;
this->cursorCenter = copy.cursorCenter;
this->cursorLocation = copy.cursorLocation;
this->scrollWait = copy.scrollWait;
this->useGradient = copy.useGradient;
this->renderOnlyText = copy.renderOnlyText;
return *this;
}
void ContextBox::act(const Font & font){
// update board
board.act(font);
// Calculate text info
// calculateText(font);
list.act();
// do fade
doFade();
// Update gradient
selectedGradient.update();
}
void ContextBox::render(const Graphics::Bitmap & work){
}
void ContextBox::render(const Graphics::Bitmap & work, const Font & font){
if (!renderOnlyText){
board.render(work);
}
drawText(work, font);
}
bool ContextBox::next(const Font & font){
if (fadeState == FadeOut){
return false;
}
list.next();
/*
cursorLocation += (int)(font.getHeight()/FONT_SPACER);
if (current < context.size()-1){
current++;
} else {
current = 0;
}
*/
return true;
}
bool ContextBox::previous(const Font & font){
if (fadeState == FadeOut){
return false;
}
list.previous();
/*
cursorLocation -= (int)(font.getHeight()/FONT_SPACER);
if (current > 0){
current--;
} else {
current = context.size()-1;
}
*/
return true;
}
void ContextBox::adjustLeft(){
}
void ContextBox::adjustRight(){
}
void ContextBox::open(){
// Set the fade stuff
fadeState = FadeIn;
//board.position = position;
board.location = location;
+ board.transforms = transforms;
board.colors = colors;
board.open();
fadeAlpha = 0;
cursorLocation = 0;
}
void ContextBox::close(){
fadeState = FadeOut;
board.close();
fadeAlpha = 255;
cursorLocation = 480;
}
void ContextBox::doFade(){
switch ( fadeState ){
case FadeIn: {
if (fadeAlpha < 255){
fadeAlpha += (fadeSpeed+2);
}
if (fadeAlpha >= 255){
fadeAlpha = 255;
if (board.isActive()){
fadeState = Active;
}
}
break;
}
case FadeOut: {
if (fadeAlpha > 0){
fadeAlpha -= (fadeSpeed+2);
}
if (fadeAlpha <= 0){
fadeAlpha = 0;
if (!board.isActive()){
fadeState = NotActive;
}
}
break;
}
case Active:
case NotActive:
default:
break;
}
}
void ContextBox::calculateText(const Font & vFont){
/*
if (context.empty()){
return;
}
// const Font & vFont = Font::getFont(font, fontWidth, fontHeight);
cursorCenter = (location.getY() + (int)location.getHeight()/2) - vFont.getHeight()/2;//(position.y + (int)position.height/2) - vFont.getHeight()/2;
if (cursorLocation == cursorCenter){
scrollWait = 4;
} else {
if (scrollWait <= 0){
cursorLocation = (cursorLocation + cursorCenter)/2;
scrollWait = 4;
} else {
scrollWait--;
}
}
*/
}
/* draws the text, fading the items according to the distance from the
* current selection.
*/
void ContextBox::doDraw(int x, int y, int middle_x, int min_y, int max_y, const Font & font, int current, int selected, const Graphics::Bitmap & area, int direction){
#if 0
while (y < max_y && y > min_y){
int pick = current;
while (pick < 0){
pick += context.size();
}
pick = pick % context.size();
ContextItem * option = context[pick];
const int startx = middle_x - font.textLength(option->getName().c_str())/2;
/* draw current selection, make it glow */
if (current == selected){
Graphics::Bitmap::transBlender(0, 0, 0, fadeAlpha);
Graphics::TranslucentBitmap translucent(area);
const int color = useGradient ? selectedGradient.current() : selectedGradientStart();
font.printf(x + startx, y, color, translucent, option->getName(), 0 );
if (option->isAdjustable()){
const int triangleSize = 14;
int cx = startx - 15;
int cy = (int)(y + (font.getHeight()/FONT_SPACER) / 2 + 2);
/* do the triangles need to be translucent? */
translucent.equilateralTriangle(cx, cy, 180, triangleSize, option->getLeftColor());
cx = (x + startx + font.textLength(option->getName().c_str()))+15;
translucent.equilateralTriangle(cx, cy, 0, triangleSize, option->getRightColor());
}
} else {
/* draw some other item, and fade it */
int count = (int) fabs((double) current - (double) selected);
/* TODO: maybe scale by the number of total items instead of using 35 */
int textAlpha = fadeAlpha - (count * 35);
if (textAlpha < 0){
textAlpha = 0;
}
Graphics::Bitmap::transBlender(0, 0, 0, textAlpha);
const int color = Graphics::makeColor(255,255,255);
font.printf(x + startx, y, color, area.translucent(), option->getName(), 0);
}
if (context.size() == 1){
return;
}
current += direction;
y += direction * font.getHeight() / FONT_SPACER;
}
#endif
}
void ContextBox::setList(const std::vector<Util::ReferenceCount<ContextItem> > & list){
for (vector<Util::ReferenceCount<ContextItem> >::const_iterator it = list.begin(); it != list.end(); it++){
const Util::ReferenceCount<ContextItem> & item = *it;
this->list.addItem(item.convert<ScrollItem>());
}
}
void ContextBox::drawText(const Graphics::Bitmap & bmp, const Font & font){
/*
if (context.empty()){
return;
}
*/
// const Font & vFont = Font::getFont(font, fontWidth, fontHeight);
const int x1 = board.getArea().getX()+(int)(board.getTransforms().getRadius()/2);
const int y1 = board.getArea().getY()+2;//(board.getArea().radius/2);
const int x2 = board.getArea().getX2()-(int)(board.getTransforms().getRadius()/2);
const int y2 = board.getArea().getY2()-2;//(board.getArea().radius/2);
Graphics::Bitmap area(bmp, x1, y1, x2 - x1, y2 - y1);
int min_y = location.getX() - font.getHeight() - y1;
int max_y = location.getX2() + font.getHeight() - y1;
list.render(area, font);
#if 0
/* draw from the current selection down */
doDraw(0, cursorLocation - y1, area.getWidth() / 2, min_y, max_y, font, current, current, area, 1);
/* draw above the current selection */
doDraw(0, cursorLocation - y1 - font.getHeight() / FONT_SPACER, area.getWidth() / 2, min_y, max_y, font, current - 1, current, area, -1);
#endif
#if 0
int currentOption = current;
int count = 0;
/* draw the current selection and everything below it */
while (locationY < location.getX2() + vFont.getHeight()){
const int startx = (location.getWidth()/2)-(vFont.textLength(context[currentOption]->getName().c_str())/2);
if (count == 0){
Graphics::Bitmap::transBlender(0, 0, 0, fadeAlpha);
Graphics::TranslucentBitmap translucent(area);
// Bitmap::drawingMode( Bitmap::MODE_TRANS );
const int color = useGradient ? selectedGradient.current() : selectedGradientStart();
vFont.printf(location.getX() + startx - x1, locationY - y1, color, translucent, context[currentOption]->getName(), 0 );
if (context[currentOption]->isAdjustable()){
const int triangleSize = 14;
int cx = (location.getX() + startx) - 15;
int cy = (int)(locationY + (vFont.getHeight()/FONT_SPACER) / 2 + 2);
/*
int cx1 = cx + triangleSize / 2;
int cy1 = cy - triangleSize / 2;
int cx2 = cx - triangleSize;
int cy2 = cy;
int cx3 = cx + triangleSize / 2;
int cy3 = cy + triangleSize / 2;
*/
/* do the triangles need to be translucent? */
// translucent.triangle(cx1, cy1, cx2, cy2, cx3, cy3, context[currentOption]->getLeftColor());
translucent.equilateralTriangle(cx, cy, 180, triangleSize, context[currentOption]->getLeftColor());
cx = (location.getX()+startx + vFont.textLength(context[currentOption]->getName().c_str()))+15;
translucent.equilateralTriangle(cx, cy, 0, triangleSize, context[currentOption]->getLeftColor());
// translucent.triangle( cx - triangleSize / 2, cy - triangleSize / 2, cx + triangleSize, cy, cx - triangleSize / 2, cy + triangleSize / 2, context[currentOption]->getRightColor() );
}
// Bitmap::drawingMode(Bitmap::MODE_SOLID);
} else {
int textAlpha = fadeAlpha - (count * 35);
if (textAlpha < 0){
textAlpha = 0;
}
Graphics::Bitmap::transBlender(0, 0, 0, textAlpha);
// Bitmap::drawingMode( Bitmap::MODE_TRANS );
const int color = Graphics::makeColor(255,255,255);
vFont.printf(location.getX() + startx - x1, locationY - y1, color, area.translucent(), context[currentOption]->getName(), 0 );
// Bitmap::drawingMode( Bitmap::MODE_SOLID );
}
if (context.size() == 1){
// area.setClipRect(0, 0, bmp.getWidth(), bmp.getHeight());
return;
}
currentOption++;
if (currentOption == (int)context.size()){
currentOption = 0;
}
locationY += (int)(vFont.getHeight()/FONT_SPACER);
count++;
/*if (context.size() < 2 && count == 2){
break;
}*/
}
locationY = cursorLocation - (int)(vFont.getHeight()/FONT_SPACER);
currentOption = current;
currentOption--;
count = 0;
/* this draws the stuff above the current selection */
while (locationY > location.getX() - vFont.getHeight()){
if (currentOption < 0){
currentOption = context.size()-1;
}
const int startx = (location.getWidth()/2)-(vFont.textLength(context[currentOption]->getName().c_str())/2);
int textAlpha = fadeAlpha - (count * 35);
if (textAlpha < 0){
textAlpha = 0;
}
Graphics::Bitmap::transBlender(0, 0, 0, textAlpha);
const int color = Graphics::makeColor(255,255,255);
vFont.printf(location.getX() + startx - x1, locationY - y1, color, area.translucent(), context[currentOption]->getName(), 0 );
currentOption--;
locationY -= (int)(vFont.getHeight()/FONT_SPACER);
count++;
/*if (context.size() < 2 && count == 1){
break;
}*/
}
// bmp.setClipRect(0, 0, bmp.getWidth(), bmp.getHeight());
#endif
}
}
diff --git a/util/gui/popup-box.cpp b/util/gui/popup-box.cpp
index e344f160..080d2325 100644
--- a/util/gui/popup-box.cpp
+++ b/util/gui/popup-box.cpp
@@ -1,98 +1,99 @@
#include "util/bitmap.h"
#include "popup-box.h"
using namespace std;
using namespace Gui;
PopupBox::PopupBox():
fadeState(Closed),
fadeSpeed(12){
}
PopupBox::PopupBox( const PopupBox & copy ):
fadeState(Closed){
this->fadeSpeed = copy.fadeSpeed;
}
PopupBox::~PopupBox(){
}
PopupBox & PopupBox::operator=( const PopupBox & copy){
this->fadeState = Closed;
this->fadeSpeed = copy.fadeSpeed;
return *this;
}
void PopupBox::act(const Font & font){
// do fade
doFade();
}
void PopupBox::render(const Graphics::Bitmap & work){
board.render(work);
}
void PopupBox::open(){
// Set the fade stuff
fadeState = FadeIn;
board.location = location;
+ board.transforms = transforms;
board.colors = colors;
board.location.center(location);
board.colors.borderAlpha = board.colors.bodyAlpha = 0;
}
void PopupBox::close(){
fadeState = FadeOut;
}
void PopupBox::doFade(){
switch (fadeState){
case FadeIn: {
board.location.growTo(location, 0.0025 * fadeSpeed);
if (board.colors.borderAlpha < colors.borderAlpha){
board.colors.borderAlpha += (int)(fadeSpeed/2);
if (board.colors.borderAlpha >= colors.borderAlpha){
board.colors.borderAlpha = colors.borderAlpha;
}
}
if (board.colors.bodyAlpha < colors.bodyAlpha){
board.colors.bodyAlpha += (int)(fadeSpeed/2);
if (board.colors.bodyAlpha >= colors.bodyAlpha){
board.colors.bodyAlpha = colors.bodyAlpha;
}
}
if (board.location == location && board.colors.bodyAlpha == colors.bodyAlpha && board.colors.borderAlpha == colors.borderAlpha){
fadeState = Open;
}
break;
}
case FadeOut: {
Coordinate coord;
coord.center(location);
board.location.growTo(coord, 0.0025 * fadeSpeed);
if (board.colors.borderAlpha > 0){
board.colors.borderAlpha -= (int)(fadeSpeed/2);
if (board.colors.borderAlpha <= 0){
board.colors.borderAlpha = 0;
}
}
if (board.colors.bodyAlpha > 0){
board.colors.bodyAlpha -= (int)(fadeSpeed/2);
if (board.colors.bodyAlpha <= 0){
board.colors.bodyAlpha = 0;
}
}
if (board.location.empty() && board.colors.borderAlpha == 0 && board.colors.bodyAlpha == 0){
fadeState = Closed;
}
break;
}
case Open:
case Closed:
default:
break;
}
}
diff --git a/util/gui/widget.cpp b/util/gui/widget.cpp
index 8adc5980..53550912 100644
--- a/util/gui/widget.cpp
+++ b/util/gui/widget.cpp
@@ -1,265 +1,267 @@
#include "util/bitmap.h"
#include "widget.h"
#include <math.h>
#include "globals.h"
#include "util/token.h"
#include "coordinate.h"
#include "util/load_exception.h"
#include <sstream>
using namespace Gui;
static const double S_PI = 3.14159265358979323846;
static const double DEG_TO_RAD = 180.0/S_PI;
static const double RAD_TO_DEG = S_PI/180.0;
static void round_double (double dbl_to_round , int &rounded_num) {
rounded_num = static_cast<int>(dbl_to_round);
if ((dbl_to_round - static_cast<double>(rounded_num)) >= 0.5) {rounded_num++;}
}
//! min (borrowed from allegro)
static inline int Min(int x, int y){ return (((x) < (y)) ? (x) : (y)); }
//! max (borrowed from allegro)
static inline int Max(int x, int y){ return (((x) > (y)) ? (x) : (y)); }
//! mid (borrowed from allegro)
static inline int Mid(int x,int y,int z){ return (Max((x), Min((y), (z)))); }
Transformations::Transformations():
radius(0){
}
Transformations::Transformations(const Transformations & transforms):
radius(transforms.radius){
}
Transformations::~Transformations(){
}
Transformations & Transformations::operator=(const Transformations & transforms){
this->radius = transforms.radius;
return *this;
}
Widget::Widget() : workArea(0)
{
// Nothing yet
}
Widget::Widget( const Widget & w ){
this->location = w.location;
+ this->transforms = w.transforms;
this->workArea = w.workArea;
}
Widget::~Widget(){
if ( workArea ){
delete workArea;
}
}
// copy
Widget &Widget::operator=( const Widget &copy){
- location = copy.location;
- workArea = copy.workArea;
+ this->location = copy.location;
+ this->transforms = copy.transforms;
+ this->workArea = copy.workArea;
return *this;
}
void Widget::setCoordinates(const Token * token){
if ( *token == "position" ){
int x, y, width, height;
token->view() >> x >> y >> width >> height;
AbsolutePoint pos(x, y);
AbsolutePoint dimensions(x + width, y + height);
location.setPosition(pos);
location.setPosition2(dimensions);
} else if ( *token == "relative-position" ){
double x1, y1, x2, y2;
token->view() >> x1 >> y1 >> x2 >> y2;
RelativePoint pos(x1,y1);
RelativePoint dimensions(x2,y2);
location = Coordinate(pos, dimensions);
} else if ( *token == "coordinate" ){
TokenView view = token->view();
while (view.hasMore()){
const Token * coordToken;
view >> coordToken;
if (*coordToken == "absolute"){
int x, y, width, height;
coordToken->view() >> x >> y >> width >> height;
AbsolutePoint pos(x, y);
AbsolutePoint dimensions(x + width, y + height);
location = Coordinate(pos, dimensions);
} else if (*coordToken == "relative"){
double x1, y1, x2, y2;
coordToken->view() >> x1 >> y1 >> x2 >> y2;
RelativePoint pos(x1,y1);
RelativePoint dimensions(x2,y2);
location = Coordinate(pos, dimensions);
} else if (*coordToken == "radius"){
double radius = 0;
coordToken->view() >> radius;
transforms.setRadius(radius);
} else if (*coordToken == "z"){
double z;
coordToken->view() >> z;
location.setZ(z);
}
}
}
if (location.getWidth() < 0 || location.getHeight() < 0){
std::ostringstream out;
out << "Invalid location dimension (cannot have a negative size). Width " << location.getWidth() << " Height " << location.getHeight() << ". From token: ";
token->toString(out, "");
throw LoadException(__FILE__, __LINE__, out.str());
}
}
void Widget::setColors(const Token * token){
if ( *token == "position-body" ) {
// This handles the body color of the widget
int r,g,b;
token->view() >> r >> g >> b >> colors.bodyAlpha;
colors.body = Graphics::makeColor(r,g,b);
} else if ( *token == "position-border" ) {
// This handles the border color of the widget
int r,g,b;
token->view() >> r >> g >> b >> colors.borderAlpha;
colors.border = Graphics::makeColor(r,g,b);
}
}
void Widget::render(const Graphics::Bitmap & bitmap, const Font & font){
render(bitmap);
}
void Widget::arc( const Graphics::Bitmap & work, int x, int y, double startAngle, int radius, int color ){
int q = 0;// for counters
double d_q = 0.0;// for percentage of loop completed
double d_q_plus_one = 0.0;
const double d_angular_length_deg = 0.030;
const double d_start_angle_rad = startAngle*DEG_TO_RAD;
const double d_angular_length_rad = d_angular_length_deg*DEG_TO_RAD;
const double d_arc_distance_between_points = 0.25*pow(2.0 , static_cast<double>(10) / 10.0);
double d_angular_length_rad_per_segment = 0.0;
double arc_length = radius*d_angular_length_rad;
if (arc_length < 0.0) {arc_length *= -1.0;}
const double d_num_segments = arc_length / d_arc_distance_between_points;
int num_segments = 0;
round_double(d_num_segments , num_segments);
if (num_segments == 0) {num_segments += 1;} // need at least one segment (two points)
const int num_points = num_segments + 1;
const double d_num_points_minus_one = static_cast<double>(num_points - 1);
int arc_point_x;//[num_points];
int arc_point_y;//[num_points];
int arc_point2_x;//[num_points];
int arc_point2_y;//[num_points];
double d_arc_point_x = 0.0;
double d_arc_point_y = 0.0;
double d_arc_point2_x = 0.0;
double d_arc_point2_y = 0.0;
double current_angle_rad = 0.0;
double current_angle2_rad = 0.0;
if (d_arc_distance_between_points <= 1.0) {
for (q = 0 ; q < num_points ; q++) {
d_q = static_cast<double>(q);
current_angle_rad = d_start_angle_rad + (d_q / d_num_points_minus_one)*d_angular_length_rad;
d_arc_point_x = x + radius*cos(current_angle_rad);
d_arc_point_y = y + radius*sin(current_angle_rad);
round_double(d_arc_point_x , arc_point_x);
round_double(d_arc_point_y , arc_point_y);
work.putPixel(arc_point_x,arc_point_y,color);
}
}
if (d_arc_distance_between_points > 1.0) {
d_angular_length_rad_per_segment = d_angular_length_rad / d_num_points_minus_one;
for (q = 0 ; q < num_segments ; q++) {
d_q = static_cast<double>(q);
d_q_plus_one = static_cast<double>(q + 1);
current_angle_rad = d_start_angle_rad + d_q*d_angular_length_rad_per_segment;
current_angle2_rad = d_start_angle_rad + d_q_plus_one*d_angular_length_rad_per_segment;
d_arc_point_x = x + radius*cos(current_angle_rad);
d_arc_point_y = y + radius*sin(current_angle_rad);
round_double(d_arc_point_x , arc_point_x);
round_double(d_arc_point_y , arc_point_y);
d_arc_point2_x = x + radius*cos(current_angle2_rad);
d_arc_point2_y = y + radius*sin(current_angle2_rad);
round_double(d_arc_point2_x , arc_point2_x);
round_double(d_arc_point2_y , arc_point2_y);
work.line(arc_point_x,arc_point_y, arc_point2_x, arc_point2_y,color);
}
}
}
void Widget::roundRect( const Graphics::Bitmap & work, int radius, int x1, int y1, int x2, int y2, int color ){
const int width = x2 - x1;
const int height = y2 - y1;
radius = Mid(0, radius, Min((x1+width - x1)/2, (y1+height - y1)/2));
work.line(x1+radius, y1, x1+width-radius, y1, color);
work.line(x1+radius, y1+height, x1+width-radius,y1+height, color);
work.line(x1, y1+radius,x1, y1+height-radius, color);
work.line(x1+width, y1+radius,x1+width, y1+height-radius, color);
arc(work, x1+radius, y1+radius, S_PI-1.115, radius, color);
arc(work, x1+radius + (width - radius *2), y1+radius, -S_PI/2 +0.116, radius, color);
arc(work, x1+width-radius, y1+height-radius, -0.110, radius ,color);
arc(work, x1+radius, y1+height-radius, S_PI/2-0.119, radius, color);
}
void Widget::roundRectFill( const Graphics::Bitmap & work, int radius, int x1, int y1, int x2, int y2, int color ){
const int width = x2 - x1;
const int height = y2 - y1;
radius = Mid(0, radius, Min((x1+width - x1)/2, (y1+height - y1)/2));
work.circleFill(x1+radius, y1+radius, radius, color);
work.circleFill((x1+width)-radius, y1+radius, radius, color);
work.circleFill(x1+radius, (y1+height)-radius, radius, color);
work.circleFill((x1+width)-radius, (y1+height)-radius, radius, color);
work.rectangleFill( x1+radius, y1, x2-radius, y1+radius, color);
work.rectangleFill( x1, y1+radius, x2, y2-radius, color);
work.rectangleFill( x1+radius, y2-radius, x2-radius, y2, color);
}
static void foobar(int a, int b){
a = a + b;
}
void Widget::checkWorkArea(){
/*
if (location.getWidth() < 0 || location.getHeight() < 0){
foobar(location.getWidth(), location.getHeight());
}
*/
if ( ! workArea ){
workArea = new Graphics::Bitmap(location.getWidth(), location.getHeight());
} else if (location.getWidth() < workArea->getWidth() || location.getHeight() < workArea->getHeight()){
delete workArea;
workArea = new Graphics::Bitmap(location.getWidth(), location.getHeight());
} else if (location.getWidth() > workArea->getWidth() || location.getHeight() > workArea->getHeight()){
delete workArea;
workArea = new Graphics::Bitmap(location.getWidth(), location.getHeight());
}
if (workArea){
workArea->fill(Graphics::makeColor(255,0,255));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:07 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68636
Default Alt Text
(28 KB)

Event Timeline