Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
5e5c1376
Commit
5e5c1376
authored
Oct 22, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QT: fix Glow custom colors.
parent
61d30c53
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
48 deletions
+60
-48
xtt/lib/glow/qt/glow_draw_qt.cqt
xtt/lib/glow/qt/glow_draw_qt.cqt
+37
-44
xtt/lib/glow/qt/glow_draw_qt.h
xtt/lib/glow/qt/glow_draw_qt.h
+21
-4
xtt/lib/glow/src/glow_customcolors.h
xtt/lib/glow/src/glow_customcolors.h
+2
-0
No files found.
xtt/lib/glow/qt/glow_draw_qt.cqt
View file @
5e5c1376
...
...
@@ -232,7 +232,11 @@ static QColor glow_allocate_custom_color(GlowDrawQt* draw_ctx,
return QColor();
}
return QColor(rgb_red, rgb_green, rgb_blue);
QColor color(rgb_red, rgb_green, rgb_blue);
draw_ctx->get_customcolors()->color_vect[drawtype - glow_eDrawType_CustomColor1] = color;
return color;
}
GlowDrawQt::~GlowDrawQt()
...
...
@@ -274,13 +278,15 @@ int GlowDrawQt::init_nav(QWidget* nav_widget)
GlowDrawQt::GlowDrawQt(QWidget* toplevel, void** glow_ctx,
int (*init_proc)(QWidget* w, GlowCtx* ctx, void* client_data),
void* client_data, glow_eCtxType type)
: click_sensitivity(0), closing_down(0)
: click_sensitivity(0), closing_down(0)
, customcolors_cnt(0)
{
timer_id = new QTimer(this);
m_wind = new DrawWindQt();
nav_wind = new DrawWindQt();
nav_wind->is_nav = 1;
memset(customcolors, 0, sizeof(customcolors));
if (type == glow_eCtxType_Brow) {
ctx = (GlowCtx*)new BrowCtx("Claes context", 20);
} else if (type == glow_eCtxType_Grow) {
...
...
@@ -1211,8 +1217,7 @@ int GlowDrawQt::polyline_helper(GlowWind* wind, int painter_type, int size,
if (!fill) {
painter->setBrush(Qt::NoBrush);
}
// debug_print("polyline painter_type=%d, fill=%d, point_cnt=%d\n",
// painter_type, fill, point_cnt);
// debug_print("polyline painter_type=%d, fill=%d, point_cnt=%d\n", painter_type, fill, point_cnt);
painter->drawPolygon(qpoints, point_cnt);
delete[] qpoints;
...
...
@@ -1285,6 +1290,7 @@ int GlowDrawQt::text(GlowWind* wind, int x, int y, char* text, int len,
QRect rect
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
// debug_print("text %s on %d,%d\n", text, x, y);
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
QString::fromLocal8Bit(text, len));
...
...
@@ -1318,6 +1324,7 @@ int GlowDrawQt::text_cursor(GlowWind* wind, int x, int y, char* text, int len,
set_clip(w, get_painter(this, painter_type, idx));
}
// debug_print("cursor %d,%d to %d,%d\n", x + width, y + descent, x + width, y - height + descent);
painter->drawLine(x + width, y + descent, x + width, y - height + descent);
delete painter;
...
...
@@ -1361,6 +1368,7 @@ int GlowDrawQt::text_erase(GlowWind* wind, int x, int y, char* text, int len,
QRect rect
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
// debug_print("textErase %s on %d,%d\n", text, x, y);
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
QString::fromLocal8Bit(text, len));
...
...
@@ -1977,40 +1985,12 @@ int GlowDrawQt::create_buffer(GlowWind* wind)
window_height = ctx->navw.window_height;
}
/*
if (!w->double_buffer_on || !window_width) {
return 0;
}
if (window_width == w->buffer->width() &&
window_height == w->buffer->height()) {
return 0;
}
if (w->buffer) {
delete w->buffer;
}
w->buffer = new QImage(window_width, window_height, QImage::Format_RGB32);
w->buffer_width = window_width;
w->buffer_height = window_height;
*/
buffer_background(w, 0);
return 1;
}
void GlowDrawQt::delete_buffer(GlowWind* wind)
{
/*
DrawWindQt *w = (DrawWindQt *) wind->window;
if (w->buffer) {
delete w->buffer;
}
w->buffer_width = 0;
w->buffer_height = 0;
*/
}
void GlowDrawQt::buffer_background(DrawWind* wind, GlowCtx* cctx)
...
...
@@ -2904,6 +2884,7 @@ int GlowDrawQt::gradient_fill_rect(GlowWind* wind, int x, int y, int w, int h,
if (!gradient_create_pattern(x, y, w, h, d0, d1, d2, gradient, &pat)) {
return 0;
}
// debug_print("gradient fillRect [%d,%d,%d,%d]\n", x, y, w, h);
painter->fillRect(QRect(x, y, w, h), *pat);
delete pat;
...
...
@@ -2932,6 +2913,7 @@ int GlowDrawQt::gradient_fill_rectrounded(GlowWind* wind, int x, int y, int w,
return 0;
}
// debug_print("gradient fillRect rounded [%d,%d,%d,%d]\n", x, y, w, h);
if (roundamount >= 0) {
QPainterPath path;
path.addRoundedRect(QRect(x, y, w, h), roundamount, roundamount);
...
...
@@ -3107,6 +3089,7 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
px = x;
py = (int)(y - (1.0 - FONT_DESCENT) * height);
}
// debug_print("textQt %s on %d,%d with color %s, painter_type=%d, color=%d\n", text, px, py, qPrintable(painter->pen().color().name()), painter_type, color);
painter->drawText(px, py, rect.width(), rect.height(), Qt::TextDontClip, str);
delete painter;
...
...
@@ -3179,6 +3162,7 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
set_clip(w, painter);
}
// debug_print("textEraseQt %s on %d,%d\n", text, px, py);
painter->fillRect(px, py, pw, ph, painter->brush());
delete painter;
...
...
@@ -3318,38 +3302,47 @@ void GlowDrawQt::update_color(glow_eDrawType color)
void GlowDrawQt::push_customcolors(GlowCustomColors* cc)
{
customcolors.push(*cc);
if (customcolors_cnt > 10) {
printf("** Max number custom colors exceede\n");
return;
}
for (int i = customcolors_cnt; i > 0; i--)
customcolors[i] = customcolors[i - 1];
customcolors[0] = (GlowCustomColorsQt*)cc;
customcolors_cnt++;
}
void GlowDrawQt::set_customcolors(GlowCustomColors* cc)
{
while (!customcolors.empty()) {
customcolors.pop();
}
customcolors.push(*cc);
customcolors[0] = (GlowCustomColorsQt*)cc;
customcolors_cnt = 1;
}
void GlowDrawQt::pop_customcolors()
{
if (customcolors
.empty()
) {
if (customcolors
_cnt <= 0
) {
printf("** Customcolor stack disorder\n");
}
customcolors.pop();
for (int i = 0; i < customcolors_cnt - 1; i++)
customcolors[i] = customcolors[i + 1];
customcolors_cnt--;
}
GlowCustomColors* GlowDrawQt::get_customcolors()
GlowCustomColors
Qt
* GlowDrawQt::get_customcolors()
{
if (customcolors
.empty()) {
if (customcolors
_cnt == 0)
return 0;
}
return &customcolors.top();
return customcolors[0];
}
GlowCustomColors* GlowDrawQt::create_customcolors()
{
return new GlowCustomColors();
return new GlowCustomColors
Qt
();
}
void GlowDrawQt::reset_customcolors(GlowCustomColors* cc)
{
memset(((GlowCustomColorsQt*)cc)->color_vect, 0,
sizeof(((GlowCustomColorsQt*)cc)->color_vect));
}
\ No newline at end of file
xtt/lib/glow/qt/glow_draw_qt.h
View file @
5e5c1376
...
...
@@ -39,6 +39,7 @@
#include <stack>
#include "glow_customcolors.h"
#include "glow_draw.h"
#include <QColor>
...
...
@@ -72,8 +73,6 @@ public:
QPixmap
*
background_pixmap
;
int
background_pixmap_width
;
int
background_pixmap_height
;
/*int buffer_width;
int buffer_height;*/
};
typedef
struct
{
...
...
@@ -82,6 +81,8 @@ typedef struct {
QTimer
*
timer_id
;
}
glow_draw_sTimerCb
;
class
GlowCustomColorsQt
;
class
GlowDrawQt
:
private
QObject
,
public
GlowDraw
{
Q_OBJECT
...
...
@@ -99,7 +100,8 @@ public:
QTimer
*
timer_id
;
int
click_sensitivity
;
int
closing_down
;
std
::
stack
<
GlowCustomColors
>
customcolors
;
GlowCustomColorsQt
*
customcolors
[
10
];
int
customcolors_cnt
;
int
event_handler
(
QEvent
*
event
,
QWidget
*
target
);
virtual
void
enable_event
(
glow_eEvent
event
,
glow_eEventType
event_type
,
...
...
@@ -250,7 +252,7 @@ public:
void
set_customcolors
(
GlowCustomColors
*
cc
);
void
pop_customcolors
();
GlowCustomColors
*
create_customcolors
();
GlowCustomColors
*
get_customcolors
();
GlowCustomColors
Qt
*
get_customcolors
();
void
reset_customcolors
(
GlowCustomColors
*
cc
);
private:
...
...
@@ -293,4 +295,19 @@ public:
double
y
;
};
class
GlowCustomColorsQt
:
public
GlowCustomColors
{
public:
GlowCustomColorsQt
()
:
color_vect_cnt
(
0
)
{
memset
(
color_vect
,
0
,
sizeof
(
color_vect
));
}
~
GlowCustomColorsQt
()
{
}
QColor
color_vect
[
glow_eDrawType_CustomColor__
-
glow_eDrawType_CustomColor1
];
int
color_vect_cnt
;
};
#endif
\ No newline at end of file
xtt/lib/glow/src/glow_customcolors.h
View file @
5e5c1376
...
...
@@ -37,6 +37,8 @@
#ifndef glow_customcolors_h
#define glow_customcolors_h
#include <fstream>
#include "glow.h"
/*! \file glow_customcolors.h
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment