mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 03:43:29 +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;
|
} color_wheel;
|
||||||
|
|
||||||
void color_wheel_wheel_image_update(color_wheel* wheel) {
|
void color_wheel_wheel_image_update(color_wheel* wheel) {
|
||||||
for(int y = 0; y < PICKER_SIZE; y++) {
|
int y, x;
|
||||||
for(int x = 0; x < PICKER_SIZE; x++) {
|
for(y = 0; y < PICKER_SIZE; y++) {
|
||||||
|
for(x = 0; x < PICKER_SIZE; x++) {
|
||||||
int i = ((y * PICKER_SIZE) + x) * 4;
|
int i = ((y * PICKER_SIZE) + x) * 4;
|
||||||
int _x = x - (PICKER_SIZE / 2);
|
int _x = x - (PICKER_SIZE / 2);
|
||||||
int _y = y - (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 angle = atan2(yd, xd) - M_PI;
|
||||||
float hue = (angle * 180.) / M_PI;
|
float hue = (angle * 180.) / M_PI;
|
||||||
|
|
||||||
|
hsv hsv_v;
|
||||||
|
rgb color;
|
||||||
|
|
||||||
if(hue < 0.0) {
|
if(hue < 0.0) {
|
||||||
hue += 360;
|
hue += 360;
|
||||||
}
|
}
|
||||||
rgb color = hsv2rgb((hsv){
|
hsv_v.h = hue / 360.;
|
||||||
.h = hue / 360.,
|
hsv_v.s = (dist / 179.61);
|
||||||
.s = (dist / 179.61),
|
hsv_v.v = wheel->value;
|
||||||
.v = wheel->value,
|
color = hsv2rgb(hsv_v);
|
||||||
});
|
|
||||||
|
|
||||||
wheel->color_wheel_image_data[i] = color.r * 255;
|
wheel->color_wheel_image_data[i] = color.r * 255;
|
||||||
wheel->color_wheel_image_data[i + 1] = color.g * 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) {
|
static void color_wheel_click(MwWidget handle, void* user, void* call) {
|
||||||
color_wheel* wheel = (color_wheel*)user;
|
color_wheel* wheel = (color_wheel*)user;
|
||||||
MwLLMouse* mouse = (MwLLMouse*)call;
|
MwLLMouse* mouse = (MwLLMouse*)call;
|
||||||
|
char* hexColor;
|
||||||
|
int i, r, g, b, a;
|
||||||
|
|
||||||
|
(void)handle;
|
||||||
|
(void)user;
|
||||||
|
(void)call;
|
||||||
|
|
||||||
color_wheel_wheel_image_update(wheel);
|
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];
|
r = wheel->color_wheel_image_data[i];
|
||||||
int g = wheel->color_wheel_image_data[i + 1];
|
g = wheel->color_wheel_image_data[i + 1];
|
||||||
int b = wheel->color_wheel_image_data[i + 2];
|
b = wheel->color_wheel_image_data[i + 2];
|
||||||
int a = wheel->color_wheel_image_data[i + 3];
|
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);
|
snprintf(hexColor, 8, "#%02X%02X%02X", r, g, b);
|
||||||
MwSetText(wheel->color_display, MwNbackground, hexColor);
|
MwSetText(wheel->color_display, MwNbackground, hexColor);
|
||||||
MwSetText(wheel->color_display_text, 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 value = MwGetInteger(handle, MwNvalue);
|
||||||
int diff = MwGetInteger(handle, MwNchangedBy);
|
int diff = MwGetInteger(handle, MwNchangedBy);
|
||||||
|
|
||||||
|
(void)diff;
|
||||||
|
(void)call;
|
||||||
|
|
||||||
wheel->value = 1.0 - ((double)value / 1024.);
|
wheel->value = 1.0 - ((double)value / 1024.);
|
||||||
|
|
||||||
color_wheel_wheel_image_update(wheel);
|
color_wheel_wheel_image_update(wheel);
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ MWDECL MwDirectoryEntry* MwDirectoryRead(void* handle);
|
|||||||
*/
|
*/
|
||||||
MWDECL void MwDirectoryFreeEntry(MwDirectoryEntry* entry);
|
MWDECL void MwDirectoryFreeEntry(MwDirectoryEntry* entry);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* %brief Gets a current directory
|
||||||
|
* %param Directory
|
||||||
|
*/
|
||||||
|
MWDECL char* MwDirectoryCurrent(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifndef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|||||||
@@ -103,3 +103,16 @@ void MwDirectoryFreeEntry(MwDirectoryEntry* entry) {
|
|||||||
free(entry->name);
|
free(entry->name);
|
||||||
free(entry);
|
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) {
|
static void scan(MwWidget handle, const char* path) {
|
||||||
filechooser_t* fc = handle->opaque;
|
filechooser_t* fc = handle->opaque;
|
||||||
|
|
||||||
|
MwVaApply(fc->addr,
|
||||||
|
MwNtext, path,
|
||||||
|
NULL);
|
||||||
|
|
||||||
MwListBoxReset(fc->files);
|
MwListBoxReset(fc->files);
|
||||||
MwListBoxInsert(fc->files, -1, NULL, "Name", "Date modified", "Size", NULL);
|
MwListBoxInsert(fc->files, -1, NULL, "Name", "Date modified", "Size", NULL);
|
||||||
MwListBoxSetWidth(fc->files, 0, -128 - 64);
|
MwListBoxSetWidth(fc->files, 0, -128 - 64);
|
||||||
@@ -251,6 +255,7 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
|||||||
int wh = MwGetInteger(handle, MwNheight);
|
int wh = MwGetInteger(handle, MwNheight);
|
||||||
int w, h;
|
int w, h;
|
||||||
filechooser_t* fc = malloc(sizeof(*fc));
|
filechooser_t* fc = malloc(sizeof(*fc));
|
||||||
|
char* path;
|
||||||
|
|
||||||
memset(fc, 0, sizeof(*fc));
|
memset(fc, 0, sizeof(*fc));
|
||||||
|
|
||||||
@@ -275,7 +280,9 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
|||||||
layout(window);
|
layout(window);
|
||||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||||
|
|
||||||
scan(window, ".");
|
path = MwDirectoryCurrent();
|
||||||
|
scan(window, path);
|
||||||
|
free(path);
|
||||||
|
|
||||||
MwLLDetach(window->lowlevel, &p);
|
MwLLDetach(window->lowlevel, &p);
|
||||||
MwLLMakePopup(window->lowlevel, handle->lowlevel);
|
MwLLMakePopup(window->lowlevel, handle->lowlevel);
|
||||||
|
|||||||
@@ -117,13 +117,17 @@ static void key(MwWidget handle, int code) {
|
|||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prop_change(MwWidget handle, const char* prop) {
|
||||||
|
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwEntryClassRec = {
|
MwClassRec MwEntryClassRec = {
|
||||||
create, /* create */
|
create, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
NULL, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
MwForceRender2, /* mouse_up */
|
MwForceRender2, /* mouse_up */
|
||||||
MwForceRender2, /* mouse_down */
|
MwForceRender2, /* mouse_down */
|
||||||
|
|||||||
@@ -126,17 +126,21 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
|||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prop_change(MwWidget handle, const char* prop) {
|
||||||
|
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwNumberEntryClassRec = {
|
MwClassRec MwNumberEntryClassRec = {
|
||||||
create, /* create */
|
create, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
NULL, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
mouse_move, /* mouse_move */
|
mouse_move, /* mouse_move */
|
||||||
mouse_up, /* mouse_up */
|
mouse_up, /* mouse_up */
|
||||||
mouse_down, /* mouse_down */
|
mouse_down, /* mouse_down */
|
||||||
key, /* key */
|
key, /* key */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ static void draw(MwWidget handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_move(MwWidget handle) {
|
static void mouse_move(MwWidget handle) {
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
|
|
||||||
if(!handle->pressed) return;
|
if(!handle->pressed) return;
|
||||||
@@ -160,9 +160,9 @@ static void mouse_move(MwWidget handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_down(MwWidget handle, void* ptr) {
|
static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
int ww = MwGetInteger(handle, MwNwidth);
|
int ww = MwGetInteger(handle, MwNwidth);
|
||||||
int wh = MwGetInteger(handle, MwNheight);
|
int wh = MwGetInteger(handle, MwNheight);
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
MwLLMouse* m = ptr;
|
MwLLMouse* m = ptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user