mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
implemented ColorValueViewer
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@56 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+180
@@ -1144,6 +1144,96 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="value"
|
Name="value"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\boolean.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\boolean.hpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\choice.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\choice.hpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\color.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\color.hpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\render\value\image.cpp">
|
RelativePath=".\render\value\image.cpp">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
@@ -1174,6 +1264,96 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\render\value\image.hpp">
|
RelativePath=".\render\value\image.hpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\multiple_choice.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\multiple_choice.hpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\symbol.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\symbol.hpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\text.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\render\value\text.hpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\render\value\viewer.cpp">
|
RelativePath=".\render\value\viewer.cpp">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
|
|||||||
@@ -8,4 +8,60 @@
|
|||||||
|
|
||||||
#include <render/value/color.hpp>
|
#include <render/value/color.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- :
|
DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP);
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : ColorValueViewer
|
||||||
|
|
||||||
|
void ColorValueViewer::draw(RotatedDC& dc) {
|
||||||
|
// draw in the value color
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
dc.SetBrush(value().value.get());
|
||||||
|
if (nativeLook()) {
|
||||||
|
// native look
|
||||||
|
// find name of color
|
||||||
|
String color_name = _("Custom");
|
||||||
|
if (field().default_script && value().value.isDefault()) {
|
||||||
|
color_name = field().default_name;
|
||||||
|
} else {
|
||||||
|
FOR_EACH_CONST(c, field().choices) {
|
||||||
|
if (value().value.get() == c->color) {
|
||||||
|
color_name = capitalize(c->name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// draw name and color
|
||||||
|
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||||
|
dc.DrawRectangle(RealRect(style().left, style().top, 40, style().height));
|
||||||
|
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
dc.DrawRectangle(style().getRect() + RealRect(40, 0, -40, 0));
|
||||||
|
dc.DrawText(color_name, style().getPos() + RealSize(43, 3));
|
||||||
|
} else {
|
||||||
|
// do we need clipping?
|
||||||
|
bool clip = style().left_width < style().width && style().right_width < style().width &&
|
||||||
|
style().top_width < style().height && style().bottom_width < style().height;
|
||||||
|
if (clip) {
|
||||||
|
// clip away the inside of the rectangle
|
||||||
|
wxRegion r = dc.tr(style().getRect());
|
||||||
|
r.Subtract(dc.tr(RealRect(
|
||||||
|
style().left + style().left_width,
|
||||||
|
style().top + style().top_width,
|
||||||
|
style().width - style().left_width - style().right_width,
|
||||||
|
style().height - style().top_width - style().bottom_width
|
||||||
|
)));
|
||||||
|
dc.getDC().SetClippingRegion(r);
|
||||||
|
}
|
||||||
|
dc.DrawRoundedRectangle(style().getRect(), style().radius);
|
||||||
|
if (clip) dc.getDC().DestroyClippingRegion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ColorValueViewer::containsPoint(const RealPoint& p) const {
|
||||||
|
// distance to each side
|
||||||
|
double left = p.x - style().left, right = style().left + style().width - p.x - 1;
|
||||||
|
double top = p.y - style().top, bottom = style().top + style().height - p.y - 1;
|
||||||
|
return left >= 0 && right >= 0 && top >= 0 && bottom >= 0 && // inside bounding box
|
||||||
|
(left < style().left_width || right < style().right_width || // inside horizontal border
|
||||||
|
top < style().top_width || bottom < style().bottom_width); // inside vertical border
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,8 +10,19 @@
|
|||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
|
#include <render/value/viewer.hpp>
|
||||||
|
#include <data/field/color.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- :
|
// ----------------------------------------------------------------------------- : ColorValueViewer
|
||||||
|
|
||||||
|
/// Viewer that displays an color value
|
||||||
|
class ColorValueViewer : public ValueViewer {
|
||||||
|
public:
|
||||||
|
DECLARE_VALUE_VIEWER(Color) : ValueViewer(parent,style) {}
|
||||||
|
|
||||||
|
virtual void draw(RotatedDC& dc);
|
||||||
|
virtual bool containsPoint(const RealPoint& p) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ class ImageValueViewer : public ValueViewer {
|
|||||||
public:
|
public:
|
||||||
DECLARE_VALUE_VIEWER(Image) : ValueViewer(parent,style) {}
|
DECLARE_VALUE_VIEWER(Image) : ValueViewer(parent,style) {}
|
||||||
|
|
||||||
void draw(RotatedDC& dc);
|
virtual void draw(RotatedDC& dc);
|
||||||
|
|
||||||
bool containsPoint(const RealPoint& p) const;
|
virtual bool containsPoint(const RealPoint& p) const;
|
||||||
|
|
||||||
void onValueChange();
|
virtual void onValueChange();
|
||||||
void onStyleChange();
|
virtual void onStyleChange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Bitmap bitmap;
|
Bitmap bitmap;
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ void ValueViewer::drawFieldBorder(RotatedDC& dc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ValueViewer::nativeLook() const {
|
||||||
|
return viewer.nativeLook();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Development/debug
|
// ----------------------------------------------------------------------------- : Development/debug
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -72,8 +76,9 @@ void ValueViewer::drawFieldBorder(RotatedDC& dc) {
|
|||||||
ValueViewerP ChoiceStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
ValueViewerP ChoiceStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
ValueViewerP BooleanStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
ValueViewerP BooleanStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
ValueViewerP MultipleChoiceStyle::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
ValueViewerP MultipleChoiceStyle::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
ValueViewerP ColorStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
//ValueViewerP ColorStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
//ValueViewerP ImageStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
//ValueViewerP ImageStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
|
IMPLEMENT_MAKE_VIEWER(Color);
|
||||||
IMPLEMENT_MAKE_VIEWER(Image);
|
IMPLEMENT_MAKE_VIEWER(Image);
|
||||||
ValueViewerP SymbolStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
ValueViewerP SymbolStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
ValueViewerP TextStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
ValueViewerP TextStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Defaultable {
|
|||||||
|
|
||||||
/// Get access to the value
|
/// Get access to the value
|
||||||
inline const T& operator () () const { return value; }
|
inline const T& operator () () const { return value; }
|
||||||
|
inline const T& get () const { return value; }
|
||||||
|
|
||||||
/// Is this value in the default state?
|
/// Is this value in the default state?
|
||||||
inline bool isDefault() const { return is_default; }
|
inline bool isDefault() const { return is_default; }
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ class RealRect {
|
|||||||
/// Size of the rectangle
|
/// Size of the rectangle
|
||||||
RealSize size;
|
RealSize size;
|
||||||
|
|
||||||
|
inline RealRect(const wxRect& rect)
|
||||||
|
: position(rect.x, rect.y), size(rect.width, rect.height)
|
||||||
|
{}
|
||||||
inline RealRect(const RealPoint& position, const RealSize& size)
|
inline RealRect(const RealPoint& position, const RealSize& size)
|
||||||
: position(position), size(size)
|
: position(position), size(size)
|
||||||
{}
|
{}
|
||||||
@@ -107,6 +110,10 @@ class RealRect {
|
|||||||
inline RealRect grow(double amount) {
|
inline RealRect grow(double amount) {
|
||||||
return RealRect(position.x - amount, position.y - amount, size.width + 2 * amount, size.height + 2 * amount);
|
return RealRect(position.x - amount, position.y - amount, size.width + 2 * amount, size.height + 2 * amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline RealRect operator + (const RealRect& r) const {
|
||||||
|
return RealRect(position + r.position, size + r.size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Operators
|
// ----------------------------------------------------------------------------- : Operators
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ class RotatedDC : public Rotation {
|
|||||||
|
|
||||||
RealSize GetTextExtent(const String& text);
|
RealSize GetTextExtent(const String& text);
|
||||||
|
|
||||||
|
inline wxDC& getDC() { return dc; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDC& dc; ///< The actual dc
|
wxDC& dc; ///< The actual dc
|
||||||
bool high_quality; ///< Drawing using our own anti aliassing?
|
bool high_quality; ///< Drawing using our own anti aliassing?
|
||||||
|
|||||||
Reference in New Issue
Block a user