Comments (2)
I modified the progress bar code. Now it almost works, but I am not sure if the solution is the right one, because I have not studied AGAR's widget structure thoroughly. Also I still have some doubt that there may be ± 1 px problems.
I attach the diff so that you can take a look at it.
--- progress_bar.c.orig
+++ progress_bar.c
@@ -230,58 +230,56 @@
static void
Draw(void *_Nonnull obj)
{
AG_ProgressBar *pb = obj;
AG_Rect rd = WIDGET(pb)->r;
const int paddingLeft = WIDGET(pb)->paddingLeft;
const int paddingRight = WIDGET(pb)->paddingRight;
const int paddingTop = WIDGET(pb)->paddingTop;
const int paddingBottom = WIDGET(pb)->paddingBottom;
int min, max, val;
min = AG_GetInt(pb, "min");
max = AG_GetInt(pb, "max");
val = AG_GetInt(pb, "value");
if (val < min) { val = min; }
if (val > max) { val = max; }
AG_DrawBoxSunk(pb, &rd, &WCOLOR(pb,BG_COLOR));
if ((max - min) <= 0)
return;
- rd.x = paddingLeft;
- rd.y = paddingTop;
+ rd.x = 0;
+ rd.y = 0;
switch (pb->type) {
case AG_PROGRESS_BAR_VERT:
- rd.h -= (paddingTop + paddingBottom);
- rd.y += rd.h - (val-min)*(rd.h)/(max-min) - 1;
- rd.h = HEIGHT(pb) - paddingTop - rd.y + 1;
- rd.w -= (paddingLeft + paddingRight);
+ rd.y += rd.h - (val-min)*(rd.h)/(max-min) - 1;
+ rd.h = HEIGHT(pb) - rd.y;
+ rd.w -= 1;
break;
case AG_PROGRESS_BAR_HORIZ:
default:
- rd.w = (val-min)*(rd.w - paddingLeft - paddingRight)/(max-min);
- rd.h -= (paddingTop + paddingBottom);
+ rd.w = (val-min)*(rd.w - 1)/(max-min);
break;
}
AG_DrawRect(pb, &rd, &WCOLOR(pb,SELECTION_COLOR));
if (pb->flags & AG_PROGRESS_BAR_SHOW_PCT)
DrawPercentText(pb);
}
AG_WidgetClass agProgressBarClass = {
{
"Agar(Widget:ProgressBar)",
sizeof(AG_ProgressBar),
{ 1,0, AGC_PROGRESSBAR, 0xE032 },
Init,
NULL, /* reset */
Destroy,
NULL, /* load */
NULL, /* save */
NULL /* edit */
},
Draw,
SizeRequest,
If you think I should submit a push request I will try to clone the repository and do it.
from libagar.
Looks good to me! Committed to: 1140aa6. Thank you very much!
from libagar.
Related Issues (20)
- drv_glx unicode input HOT 1
- agartest failing to execute properly on Linux X86_64 Devuan ASCII 2.1 / NVidia 190.138 HOT 1
- Can agar work only on FB without sdl? HOT 1
- agarhello doesn't render text using sdlfb HOT 2
- Add clipboard support to SDL2 drivers
- GLX driver does not enforce window minimum size
- Segmentation fault on keyevents test. HOT 5
- Cannot run agartest or the hello.c example on Fedora Linux HOT 2
- How about provide libagar with meson WrapDB database HOT 3
- Build error under macOS HOT 1
- Build Agar on MSYS2
- Zig build fails due to undeclared identifiers HOT 1
- Installing failing on linux HOT 5
- AG_ProgressBarSetWidth does nothing HOT 1
- Pane test. Pane is not restored after having been hidden
- Submenus are decorated when using twm HOT 3
- AG_WindowShow() fails on macOS Sonoma
- [ Release: File Not Found ] Download link on release page does not work HOT 1
- AG_Icon(3) drag and drop (e.g., sockets test) doesn't work in multi-window mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libagar.