mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
working on scrollbar, wip
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@163 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -34,7 +34,7 @@ E_LIBS = $(LIBS) -lMw
|
||||
|
||||
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o
|
||||
L_OBJS += src/external/ds.o src/external/image.o
|
||||
L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o
|
||||
L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o src/widget/scrollbar.o
|
||||
|
||||
ifeq ($(TARGET),NetBSD)
|
||||
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
|
||||
@@ -66,7 +66,7 @@ endif
|
||||
ifeq ($(UNIX),1)
|
||||
L_CFLAGS += -DUSE_X11
|
||||
L_OBJS += src/backend/x11.o
|
||||
L_LIBS += -lX11 -lXrender -lXext
|
||||
L_LIBS += -lm -lX11 -lXrender -lXext
|
||||
|
||||
GL = -lGL -lGLU
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/OpenGL.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/OpenGL.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
||||
@@ -22,6 +22,17 @@ extern "C" {
|
||||
*/
|
||||
MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||
|
||||
/*!
|
||||
* %brief Lighten a color
|
||||
* %param handle Widget
|
||||
* %param color Color
|
||||
* %param r Red
|
||||
* %param g Green
|
||||
* %param b Blue
|
||||
* %return Color
|
||||
*/
|
||||
MWDECL MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b);
|
||||
|
||||
/*!
|
||||
* %brief Draws a filled rectangle
|
||||
* %param handle Widget
|
||||
@@ -40,6 +51,16 @@ MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
||||
*/
|
||||
MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||
|
||||
/*!
|
||||
* %brief Draws a triangle
|
||||
* %param handle Widget
|
||||
* %param rect Rectangle area
|
||||
* %param color Color
|
||||
* %param invert Invert the 3D border color or not
|
||||
* %warning `rect` gets changed to the area of rectangle inside
|
||||
*/
|
||||
MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction);
|
||||
|
||||
/*!
|
||||
* %brief Draws a frame with specified border width
|
||||
* %param handle Widget
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
#include <Mw/Draw.h>
|
||||
#include <Mw/Font.h>
|
||||
#include <Mw/Error.h>
|
||||
#include <Mw/Constants.h>
|
||||
|
||||
#include <Mw/Window.h>
|
||||
#include <Mw/Menu.h>
|
||||
#include <Mw/SubMenu.h>
|
||||
#include <Mw/Button.h>
|
||||
#include <Mw/Frame.h>
|
||||
#include <Mw/Image.h>
|
||||
#include <Mw/Widget/Window.h>
|
||||
#include <Mw/Widget/Menu.h>
|
||||
#include <Mw/Widget/SubMenu.h>
|
||||
#include <Mw/Widget/Button.h>
|
||||
#include <Mw/Widget/Frame.h>
|
||||
#include <Mw/Widget/Image.h>
|
||||
#include <Mw/Widget/ScrollBar.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Button.h
|
||||
* %file Mw/Widget/Button.h
|
||||
* %brief Button widget
|
||||
*/
|
||||
#ifndef __MW_BUTTON_H__
|
||||
#define __MW_BUTTON_H__
|
||||
#ifndef __MW_WIDGET_BUTTON_H__
|
||||
#define __MW_WIDGET_BUTTON_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Frame.h
|
||||
* %file Mw/Widget/Frame.h
|
||||
* %brief Frame widget
|
||||
*/
|
||||
#ifndef __MW_FRAME_H__
|
||||
#define __MW_FRAME_H__
|
||||
#ifndef __MW_WIDGET_FRAME_H__
|
||||
#define __MW_WIDGET_FRAME_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Image.h
|
||||
* %file Mw/Widget/Image.h
|
||||
* %brief Image widget
|
||||
*/
|
||||
#ifndef __MW_IMAGE_H__
|
||||
#define __MW_IMAGE_H__
|
||||
#ifndef __MW_WIDGET_IMAGE_H__
|
||||
#define __MW_WIDGET_IMAGE_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Menu.h
|
||||
* %file Mw/Widget/Menu.h
|
||||
* %brief Menu widget
|
||||
*/
|
||||
#ifndef __MW_MENU_H__
|
||||
#define __MW_MENU_H__
|
||||
#ifndef __MW_WIDGET_MENU_H__
|
||||
#define __MW_WIDGET_MENU_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/OpenGL.h
|
||||
* %file Mw/Widget/OpenGL.h
|
||||
* %brief OpenGL widget
|
||||
*/
|
||||
#ifndef __MW_OPENGL_H__
|
||||
#define __MW_OPENGL_H__
|
||||
#ifndef __MW_WIDGET_OPENGL_H__
|
||||
#define __MW_WIDGET_OPENGL_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
25
include/Mw/Widget/ScrollBar.h
Normal file
25
include/Mw/Widget/ScrollBar.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Widget/ScrollBar.h
|
||||
* %brief ScrollBar widget
|
||||
*/
|
||||
#ifndef __MW_WIDGET_SCROLLBAR_H__
|
||||
#define __MW_WIDGET_SCROLLBAR_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* %brief ScrollBar widget class
|
||||
*/
|
||||
MWDECL MwClass MwScrollBarClass;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/SubMenu.h
|
||||
* %file Mw/Widget/SubMenu.h
|
||||
* %brief SubMenu widget
|
||||
*/
|
||||
#ifndef __MW_SUBMENU_H__
|
||||
#define __MW_SUBMENU_H__
|
||||
#ifndef __MW_WIDGET_SUBMENU_H__
|
||||
#define __MW_WIDGET_SUBMENU_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Vulkan.h
|
||||
* %file Mw/Widget/Vulkan.h
|
||||
* %brief Vulkan widget
|
||||
* %warning This header is not documented yet
|
||||
*/
|
||||
@@ -9,8 +9,8 @@
|
||||
* ioixd maintains this file. nishi doesn't know vulkan at all
|
||||
*/
|
||||
|
||||
#ifndef __MW_VULKAN_H__
|
||||
#define __MW_VULKAN_H__
|
||||
#ifndef __MW_WIDGET_VULKAN_H__
|
||||
#define __MW_WIDGET_VULKAN_H__
|
||||
|
||||
#if !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__)
|
||||
#error Vulkan is unsupported on the requested platform.
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Window.h
|
||||
* %file Mw/Widget/Window.h
|
||||
* %brief Window widget
|
||||
*/
|
||||
#ifndef __MW_WINDOW_H__
|
||||
#define __MW_WINDOW_H__
|
||||
#ifndef __MW_WIDGET_WINDOW_H__
|
||||
#define __MW_WIDGET_WINDOW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
18
src/draw.c
18
src/draw.c
@@ -48,6 +48,21 @@ MwLLColor MwParseColor(MwWidget handle, const char* text) {
|
||||
return MwLLAllocColor(handle->lowlevel, r, g, b);
|
||||
}
|
||||
|
||||
MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b) {
|
||||
int cr = color->red + r;
|
||||
int cg = color->green + g;
|
||||
int cb = color->blue + b;
|
||||
|
||||
if(cr < 0) cr = 0;
|
||||
if(cg < 0) cg = 0;
|
||||
if(cb < 0) cb = 0;
|
||||
if(cr > 255) cr = 255;
|
||||
if(cg > 255) cg = 255;
|
||||
if(cb > 255) cb = 255;
|
||||
|
||||
return MwLLAllocColor(handle->lowlevel, cr, cg, cb);
|
||||
}
|
||||
|
||||
void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||
MwPoint p[4];
|
||||
|
||||
@@ -177,3 +192,6 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
|
||||
|
||||
return px;
|
||||
}
|
||||
|
||||
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/OpenGL.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* nothing */
|
||||
|
||||
38
src/widget/scrollbar.c
Normal file
38
src/widget/scrollbar.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* $Id $*/
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void draw(MwWidget handle) {
|
||||
MwRect r, rt;
|
||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
||||
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.width = MwGetInteger(handle, MwNwidth);
|
||||
r.height = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwDrawFrame(handle, &r, dark, 1);
|
||||
MwDrawRect(handle, &r, dark);
|
||||
|
||||
rt = r;
|
||||
rt.height = rt.width;
|
||||
MwDrawTriangle(handle, &r, base, 0, MwNORTH);
|
||||
|
||||
MwLLFreeColor(dark);
|
||||
MwLLFreeColor(base);
|
||||
}
|
||||
|
||||
MwClassRec MwScrollBarClassRec = {
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL /* parent_resize */
|
||||
};
|
||||
MwClass MwScrollBarClass = &MwScrollBarClassRec;
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/Vulkan.h>
|
||||
#include <Mw/Widget/Vulkan.h>
|
||||
|
||||
#include "../error_internal.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user