mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 10:23:27 +00:00
c89-ification
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@387 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -69,8 +69,9 @@ typedef struct {
|
||||
} color_wheel;
|
||||
|
||||
void color_wheel_wheel_image_update(color_wheel* wheel) {
|
||||
for(int y = 0; y < PICKER_SIZE; y++) {
|
||||
for(int x = 0; x < PICKER_SIZE; x++) {
|
||||
int y, x;
|
||||
for(y = 0; y < PICKER_SIZE; y++) {
|
||||
for(x = 0; x < PICKER_SIZE; x++) {
|
||||
int i = ((y * PICKER_SIZE) + x) * 4;
|
||||
int _x = x - (PICKER_SIZE / 2);
|
||||
int _y = y - (PICKER_SIZE / 2);
|
||||
@@ -89,14 +90,16 @@ void color_wheel_wheel_image_update(color_wheel* wheel) {
|
||||
float angle = atan2(yd, xd) - M_PI;
|
||||
float hue = (angle * 180.) / M_PI;
|
||||
|
||||
hsv hsv_v;
|
||||
rgb color;
|
||||
|
||||
if(hue < 0.0) {
|
||||
hue += 360;
|
||||
}
|
||||
rgb color = hsv2rgb((hsv){
|
||||
.h = hue / 360.,
|
||||
.s = (dist / 179.61),
|
||||
.v = wheel->value,
|
||||
});
|
||||
hsv_v.h = hue / 360.;
|
||||
hsv_v.s = (dist / 179.61);
|
||||
hsv_v.v = wheel->value;
|
||||
color = hsv2rgb(hsv_v);
|
||||
|
||||
wheel->color_wheel_image_data[i] = color.r * 255;
|
||||
wheel->color_wheel_image_data[i + 1] = color.g * 255;
|
||||
@@ -116,17 +119,25 @@ void color_wheel_wheel_image_update(color_wheel* wheel) {
|
||||
static void color_wheel_click(MwWidget handle, void* user, void* call) {
|
||||
color_wheel* wheel = (color_wheel*)user;
|
||||
MwLLMouse* mouse = (MwLLMouse*)call;
|
||||
char* hexColor;
|
||||
int i, r, g, b, a;
|
||||
|
||||
(void)handle;
|
||||
(void)user;
|
||||
(void)call;
|
||||
|
||||
color_wheel_wheel_image_update(wheel);
|
||||
|
||||
int i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4;
|
||||
i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4;
|
||||
|
||||
int r = wheel->color_wheel_image_data[i];
|
||||
int g = wheel->color_wheel_image_data[i + 1];
|
||||
int b = wheel->color_wheel_image_data[i + 2];
|
||||
int a = wheel->color_wheel_image_data[i + 3];
|
||||
r = wheel->color_wheel_image_data[i];
|
||||
g = wheel->color_wheel_image_data[i + 1];
|
||||
b = wheel->color_wheel_image_data[i + 2];
|
||||
a = wheel->color_wheel_image_data[i + 3];
|
||||
|
||||
char* hexColor = malloc(8);
|
||||
(void)a;
|
||||
|
||||
hexColor = malloc(8);
|
||||
snprintf(hexColor, 8, "#%02X%02X%02X", r, g, b);
|
||||
MwSetText(wheel->color_display, MwNbackground, hexColor);
|
||||
MwSetText(wheel->color_display_text, MwNbackground, hexColor);
|
||||
@@ -139,6 +150,9 @@ static void color_wheel_on_change_value(MwWidget handle, void* user, void* call)
|
||||
int value = MwGetInteger(handle, MwNvalue);
|
||||
int diff = MwGetInteger(handle, MwNchangedBy);
|
||||
|
||||
(void)diff;
|
||||
(void)call;
|
||||
|
||||
wheel->value = 1.0 - ((double)value / 1024.);
|
||||
|
||||
color_wheel_wheel_image_update(wheel);
|
||||
|
||||
@@ -39,6 +39,12 @@ MWDECL MwDirectoryEntry* MwDirectoryRead(void* handle);
|
||||
*/
|
||||
MWDECL void MwDirectoryFreeEntry(MwDirectoryEntry* entry);
|
||||
|
||||
/*!
|
||||
* %brief Gets a current directory
|
||||
* %param Directory
|
||||
*/
|
||||
MWDECL char* MwDirectoryCurrent(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#ifndef _WIN32
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -103,3 +103,16 @@ void MwDirectoryFreeEntry(MwDirectoryEntry* entry) {
|
||||
free(entry->name);
|
||||
free(entry);
|
||||
}
|
||||
|
||||
char* MwDirectoryCurrent(void) {
|
||||
#ifdef _WIN32
|
||||
int len = GetCurrentDirectory(0, NULL);
|
||||
char* out = malloc(len);
|
||||
|
||||
GetCurrentDirectory(len, out);
|
||||
|
||||
return out;
|
||||
#else
|
||||
return getcwd(NULL, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -237,6 +237,10 @@ static void resize(MwWidget handle, void* user, void* call) {
|
||||
static void scan(MwWidget handle, const char* path) {
|
||||
filechooser_t* fc = handle->opaque;
|
||||
|
||||
MwVaApply(fc->addr,
|
||||
MwNtext, path,
|
||||
NULL);
|
||||
|
||||
MwListBoxReset(fc->files);
|
||||
MwListBoxInsert(fc->files, -1, NULL, "Name", "Date modified", "Size", NULL);
|
||||
MwListBoxSetWidth(fc->files, 0, -128 - 64);
|
||||
@@ -251,6 +255,7 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
int w, h;
|
||||
filechooser_t* fc = malloc(sizeof(*fc));
|
||||
char* path;
|
||||
|
||||
memset(fc, 0, sizeof(*fc));
|
||||
|
||||
@@ -275,7 +280,9 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
||||
layout(window);
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
|
||||
scan(window, ".");
|
||||
path = MwDirectoryCurrent();
|
||||
scan(window, path);
|
||||
free(path);
|
||||
|
||||
MwLLDetach(window->lowlevel, &p);
|
||||
MwLLMakePopup(window->lowlevel, handle->lowlevel);
|
||||
|
||||
@@ -117,13 +117,17 @@ static void key(MwWidget handle, int code) {
|
||||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
static void prop_change(MwWidget handle, const char* prop) {
|
||||
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
|
||||
}
|
||||
|
||||
MwClassRec MwEntryClassRec = {
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
NULL, /* prop_change */
|
||||
prop_change, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
MwForceRender2, /* mouse_up */
|
||||
MwForceRender2, /* mouse_down */
|
||||
|
||||
@@ -126,13 +126,17 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
||||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
static void prop_change(MwWidget handle, const char* prop) {
|
||||
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
|
||||
}
|
||||
|
||||
MwClassRec MwNumberEntryClassRec = {
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
NULL, /* prop_change */
|
||||
prop_change, /* prop_change */
|
||||
mouse_move, /* mouse_move */
|
||||
mouse_up, /* mouse_up */
|
||||
mouse_down, /* mouse_down */
|
||||
|
||||
Reference in New Issue
Block a user