forked from mia/Aegisub
Fix recent colours box in colour picker on Mac
Originally committed to SVN as r2260.
This commit is contained in:
parent
e8dffb60ec
commit
9c51d15a99
2 changed files with 42 additions and 17 deletions
|
@ -52,6 +52,8 @@
|
||||||
#include "help_button.h"
|
#include "help_button.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define STATIC_BORDER_FLAG wxSTATIC_BORDER
|
#define STATIC_BORDER_FLAG wxSTATIC_BORDER
|
||||||
|
@ -168,6 +170,8 @@ ColorPickerRecent::ColorPickerRecent(wxWindow *parent, wxWindowID id, int _cols,
|
||||||
, cols(_cols)
|
, cols(_cols)
|
||||||
, cellsize(_cellsize)
|
, cellsize(_cellsize)
|
||||||
, internal_control_offset(0,0)
|
, internal_control_offset(0,0)
|
||||||
|
, background_valid(false)
|
||||||
|
, background()
|
||||||
{
|
{
|
||||||
LoadFromString(wxEmptyString);
|
LoadFromString(wxEmptyString);
|
||||||
SetClientSize(cols*cellsize, rows*cellsize);
|
SetClientSize(cols*cellsize, rows*cellsize);
|
||||||
|
@ -183,12 +187,14 @@ void ColorPickerRecent::LoadFromString(const wxString &recent_string)
|
||||||
while (toker.HasMoreTokens()) {
|
while (toker.HasMoreTokens()) {
|
||||||
AssColor color;
|
AssColor color;
|
||||||
color.Parse(toker.NextToken());
|
color.Parse(toker.NextToken());
|
||||||
color.a = 0;
|
color.a = wxALPHA_OPAQUE;
|
||||||
colors.push_back(color.GetWXColor());
|
colors.push_back(color.GetWXColor());
|
||||||
}
|
}
|
||||||
while ((int)colors.size() < rows*cols) {
|
while ((int)colors.size() < rows*cols) {
|
||||||
colors.push_back(*wxBLACK);
|
colors.push_back(*wxBLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString ColorPickerRecent::StoreToString()
|
wxString ColorPickerRecent::StoreToString()
|
||||||
|
@ -210,7 +216,11 @@ void ColorPickerRecent::AddColor(wxColour color)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
colors.insert(colors.begin(), color);
|
colors.insert(colors.begin(), color);
|
||||||
|
|
||||||
|
background_valid = false;
|
||||||
|
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,9 +250,14 @@ void ColorPickerRecent::OnClick(wxMouseEvent &evt)
|
||||||
|
|
||||||
void ColorPickerRecent::OnPaint(wxPaintEvent &evt)
|
void ColorPickerRecent::OnPaint(wxPaintEvent &evt)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC pdc(this);
|
||||||
wxBrush brush;
|
PrepareDC(pdc);
|
||||||
wxSize cs = GetClientSize();
|
|
||||||
|
if (!background_valid) {
|
||||||
|
wxSize sz = pdc.GetSize();
|
||||||
|
|
||||||
|
background = wxBitmap(sz.x, sz.y);
|
||||||
|
wxMemoryDC dc(background);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
@ -259,11 +274,17 @@ void ColorPickerRecent::OnPaint(wxPaintEvent &evt)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pdc.DrawBitmap(background, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickerRecent::OnSize(wxSizeEvent &evt)
|
void ColorPickerRecent::OnSize(wxSizeEvent &evt)
|
||||||
{
|
{
|
||||||
wxSize size = GetClientSize();
|
wxSize size = GetClientSize();
|
||||||
|
background_valid = false;
|
||||||
//internal_control_offset.x = (size.GetWidth() - cellsize * cols) / 2;
|
//internal_control_offset.x = (size.GetWidth() - cellsize * cols) / 2;
|
||||||
//internal_control_offset.y = (size.GetHeight() - cellsize * rows) / 2;
|
//internal_control_offset.y = (size.GetHeight() - cellsize * rows) / 2;
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
|
@ -81,8 +81,12 @@ private:
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
int cellsize;
|
int cellsize;
|
||||||
wxPoint internal_control_offset;
|
wxPoint internal_control_offset;
|
||||||
|
|
||||||
std::vector<wxColour> colors;
|
std::vector<wxColour> colors;
|
||||||
|
|
||||||
|
bool background_valid;
|
||||||
|
wxBitmap background;
|
||||||
|
|
||||||
void OnClick(wxMouseEvent &evt);
|
void OnClick(wxMouseEvent &evt);
|
||||||
void OnPaint(wxPaintEvent &evt);
|
void OnPaint(wxPaintEvent &evt);
|
||||||
void OnSize(wxSizeEvent &evt);
|
void OnSize(wxSizeEvent &evt);
|
||||||
|
|
Loading…
Reference in a new issue