Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
magicseteditor
Commits
17463560
Commit
17463560
authored
Mar 29, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mask for image fields, added mask support to slice window
parent
b7bd4f83
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
21 deletions
+60
-21
src/data/field/choice.cpp
src/data/field/choice.cpp
+3
-2
src/data/field/choice.hpp
src/data/field/choice.hpp
+12
-12
src/data/field/image.cpp
src/data/field/image.cpp
+4
-0
src/data/field/image.hpp
src/data/field/image.hpp
+2
-0
src/gui/image_slice_window.cpp
src/gui/image_slice_window.cpp
+21
-4
src/gui/image_slice_window.hpp
src/gui/image_slice_window.hpp
+4
-2
src/gui/value/image.cpp
src/gui/value/image.cpp
+14
-1
No files found.
src/data/field/choice.cpp
View file @
17463560
...
...
@@ -177,7 +177,8 @@ ChoiceStyle::~ChoiceStyle() {
bool
ChoiceStyle
::
update
(
Context
&
ctx
)
{
// Don't update the choice images, leave that to invalidate()
return
Style
::
update
(
ctx
);
return
Style
::
update
(
ctx
)
|
mask_filename
.
update
(
ctx
);
}
void
ChoiceStyle
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Style
::
initDependencies
(
ctx
,
dep
);
...
...
@@ -199,7 +200,7 @@ void ChoiceStyle::invalidate() {
}
void
ChoiceStyle
::
loadMask
(
Package
&
pkg
)
{
if
(
mask
.
Ok
()
||
mask_filename
.
empty
())
return
;
if
(
mask
.
Ok
()
||
mask_filename
()
.
empty
())
return
;
// load file
InputStreamP
image_file
=
pkg
.
openIn
(
mask_filename
);
mask
.
LoadFile
(
*
image_file
);
...
...
src/data/field/choice.hpp
View file @
17463560
...
...
@@ -121,18 +121,18 @@ class ChoiceStyle : public Style {
DECLARE_STYLE_TYPE
(
Choice
);
~
ChoiceStyle
();
ChoicePopupStyle
popup_style
;
///< Style of popups/menus
ChoiceRenderStyle
render_style
;
///< Style of rendering
Font
font
;
///< Font for drawing text (when RENDER_TEXT)
map
<
String
,
ScriptableImage
>
choice_images
;
///< Images for the various choices (when RENDER_IMAGE)
map
<
String
,
Color
>
choice_colors
;
///< Colors for the various choices (when color_cardlist)
bool
colors_card_list
;
///< Does this field determine colors of the rows in the card list?
S
tring
mask_filename
;
///< Filename of an additional mask over the images
ImageCombine
combine
;
///< Combining mode for drawing the images
Alignment
alignment
;
///< Alignment of images
Image
mask
;
///< The actual mask image
wxImageList
*
thumbnails
;
///< Thumbnails for the choices
Age
thumbnail_age
;
///< Age the thumbnails were generated
ChoicePopupStyle
popup_style
;
///< Style of popups/menus
ChoiceRenderStyle
render_style
;
///< Style of rendering
Font
font
;
///< Font for drawing text (when RENDER_TEXT)
map
<
String
,
ScriptableImage
>
choice_images
;
///< Images for the various choices (when RENDER_IMAGE)
map
<
String
,
Color
>
choice_colors
;
///< Colors for the various choices (when color_cardlist)
bool
colors_card_list
;
///< Does this field determine colors of the rows in the card list?
S
criptable
<
String
>
mask_filename
;
///< Filename of an additional mask over the images
ImageCombine
combine
;
///< Combining mode for drawing the images
Alignment
alignment
;
///< Alignment of images
Image
mask
;
///< The actual mask image
wxImageList
*
thumbnails
;
///< Thumbnails for the choices
Age
thumbnail_age
;
///< Age the thumbnails were generated
bool
invalidated_images
;
///< Have the images been invalidated?
/// Load the mask image, if it's not already done
...
...
src/data/field/image.cpp
View file @
17463560
...
...
@@ -28,6 +28,10 @@ IMPLEMENT_REFLECTION(ImageStyle) {
REFLECT_N
(
"mask"
,
mask_filename
);
}
bool
ImageStyle
::
update
(
Context
&
ctx
)
{
return
Style
::
update
(
ctx
)
|
mask_filename
.
update
(
ctx
);
}
// ----------------------------------------------------------------------------- : ImageValue
...
...
src/data/field/image.hpp
View file @
17463560
...
...
@@ -39,6 +39,8 @@ class ImageStyle : public Style {
Scriptable
<
String
>
mask_filename
;
///< Filename for a mask image
virtual
bool
update
(
Context
&
);
private:
DECLARE_REFLECTION
();
};
...
...
src/gui/image_slice_window.cpp
View file @
17463560
...
...
@@ -7,7 +7,9 @@
// ----------------------------------------------------------------------------- : Includes
#include <gui/image_slice_window.hpp>
#include <gui/util.hpp>
#include <util/window_id.hpp>
#include <util/rotation.hpp>
#include <gfx/gfx.hpp>
#include <wx/spinctrl.h>
#include <wx/dcbuffer.h>
...
...
@@ -72,7 +74,7 @@ DEFINE_EVENT_TYPE(EVENT_SLICE_CHANGED);
// ----------------------------------------------------------------------------- : ImageSliceWindow
ImageSliceWindow
::
ImageSliceWindow
(
Window
*
parent
,
const
Image
&
source
,
const
wxSize
&
target_size
)
ImageSliceWindow
::
ImageSliceWindow
(
Window
*
parent
,
const
Image
&
source
,
const
wxSize
&
target_size
,
const
AlphaMaskP
&
mask
)
:
wxDialog
(
parent
,
wxID_ANY
,
_TITLE_
(
"slice image"
),
wxDefaultPosition
,
wxDefaultSize
,
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
|
wxFULL_REPAINT_ON_RESIZE
)
,
slice
(
source
,
target_size
)
{
...
...
@@ -80,7 +82,7 @@ ImageSliceWindow::ImageSliceWindow(Window* parent, const Image& source, const wx
const
wxPoint
defPos
=
wxDefaultPosition
;
const
wxSize
spinSize
(
80
,
-
1
);
selector
=
new
ImageSliceSelector
(
this
,
ID_SELECTOR
,
slice
);
preview
=
new
ImageSlicePreview
(
this
,
ID_PREVIEW
,
slice
);
preview
=
new
ImageSlicePreview
(
this
,
ID_PREVIEW
,
slice
,
mask
);
String
sizes
[]
=
{
_
(
"&Original Size"
)
,
_
(
"Size to &Fit"
)
...
...
@@ -331,9 +333,10 @@ END_EVENT_TABLE ()
// ----------------------------------------------------------------------------- : ImageSlicePreview
ImageSlicePreview
::
ImageSlicePreview
(
Window
*
parent
,
int
id
,
ImageSlice
&
slice
)
ImageSlicePreview
::
ImageSlicePreview
(
Window
*
parent
,
int
id
,
ImageSlice
&
slice
,
const
AlphaMaskP
&
mask
)
:
wxControl
(
parent
,
id
)
,
slice
(
slice
)
,
mask
(
mask
)
,
mouse_down
(
false
)
{}
...
...
@@ -356,7 +359,21 @@ void ImageSlicePreview::onPaint(wxPaintEvent&) {
}
void
ImageSlicePreview
::
draw
(
DC
&
dc
)
{
if
(
!
bitmap
.
Ok
())
{
bitmap
=
Bitmap
(
slice
.
getSlice
());
Image
image
=
slice
.
getSlice
();
if
(
mask
&&
mask
->
size
==
slice
.
target_size
)
{
mask
->
setAlpha
(
image
);
// create bitmap
bitmap
=
Bitmap
(
image
.
GetWidth
(),
image
.
GetHeight
());
wxMemoryDC
mdc
;
mdc
.
SelectObject
(
bitmap
);
// draw checker pattern behind image
RealRect
rect
=
GetClientSize
();
RotatedDC
rdc
(
mdc
,
0
,
rect
,
1
,
false
);
draw_checker
(
rdc
,
rect
);
rdc
.
DrawImage
(
image
,
RealPoint
(
0
,
0
));
mdc
.
SelectObject
(
wxNullBitmap
);
}
else
{
bitmap
=
Bitmap
(
image
);
}
}
if
(
bitmap
.
Ok
())
{
dc
.
DrawBitmap
(
bitmap
,
0
,
0
);
...
...
src/gui/image_slice_window.hpp
View file @
17463560
...
...
@@ -14,6 +14,7 @@
class
ImageSlicePreview
;
class
ImageSliceSelector
;
class
wxSpinEvent
;
DECLARE_POINTER_TYPE
(
AlphaMask
);
// ----------------------------------------------------------------------------- : ImageSlice
...
...
@@ -50,7 +51,7 @@ class ImageSlice {
/// Dialog for selecting a slice of an image
class
ImageSliceWindow
:
public
wxDialog
{
public:
ImageSliceWindow
(
Window
*
parent
,
const
Image
&
source
,
const
wxSize
&
target_size
);
ImageSliceWindow
(
Window
*
parent
,
const
Image
&
source
,
const
wxSize
&
target_size
,
const
AlphaMaskP
&
target_mask
);
/// Return the sliced image
Image
getImage
()
const
;
...
...
@@ -106,7 +107,7 @@ class ImageSliceWindow : public wxDialog {
/// A preview of the sliced image
class
ImageSlicePreview
:
public
wxControl
{
public:
ImageSlicePreview
(
Window
*
parent
,
int
id
,
ImageSlice
&
slice
);
ImageSlicePreview
(
Window
*
parent
,
int
id
,
ImageSlice
&
slice
,
const
AlphaMaskP
&
mask
);
/// Notify that the slice was updated
void
update
();
...
...
@@ -115,6 +116,7 @@ class ImageSlicePreview : public wxControl {
private:
Bitmap
bitmap
;
ImageSlice
&
slice
;
AlphaMaskP
mask
;
bool
mouse_down
;
int
mouseX
,
mouseY
;
///< starting mouse position
...
...
src/gui/value/image.cpp
View file @
17463560
...
...
@@ -10,6 +10,7 @@
#include <gui/image_slice_window.hpp>
#include <data/format/clipboard.hpp>
#include <data/action/value.hpp>
#include <data/stylesheet.hpp>
#include <wx/clipbrd.h>
// ----------------------------------------------------------------------------- : ImageValueEditor
...
...
@@ -28,8 +29,20 @@ bool ImageValueEditor::onLeftDClick(const RealPoint&, wxMouseEvent&) {
void
ImageValueEditor
::
sliceImage
(
const
Image
&
image
)
{
if
(
!
image
.
Ok
())
return
;
// mask?
AlphaMaskP
mask
;
if
(
!
style
().
mask_filename
().
empty
())
{
Image
mask_image
;
InputStreamP
image_file
=
viewer
.
stylesheet
->
openIn
(
style
().
mask_filename
);
if
(
mask_image
.
LoadFile
(
*
image_file
))
{
Image
resampled
(
style
().
width
,
style
().
height
);
resample
(
mask_image
,
resampled
);
mask
=
new_shared1
<
AlphaMask
>
(
resampled
);
}
}
// slice
ImageSliceWindow
s
(
wxGetTopLevelParent
(
&
editor
()),
image
,
style
().
getSize
());
ImageSliceWindow
s
(
wxGetTopLevelParent
(
&
editor
()),
image
,
style
().
getSize
(),
mask
);
// clicked ok?
if
(
s
.
ShowModal
()
==
wxID_OK
)
{
// store the image into the set
FileName
new_image_file
=
getSet
().
newFileName
(
field
().
name
,
_
(
""
));
// a new unique name in the package
...
...
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