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
be4009b6
Commit
be4009b6
authored
Nov 26, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added SymbolValueEditor + minor fixes
parent
263c2ca9
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
104 additions
and
37 deletions
+104
-37
src/data/action/symbol_part.hpp
src/data/action/symbol_part.hpp
+1
-1
src/gui/control/graph.cpp
src/gui/control/graph.cpp
+1
-1
src/gui/symbol/control.cpp
src/gui/symbol/control.cpp
+1
-1
src/gui/symbol/window.cpp
src/gui/symbol/window.cpp
+46
-7
src/gui/symbol/window.hpp
src/gui/symbol/window.hpp
+8
-7
src/gui/value/choice.cpp
src/gui/value/choice.cpp
+1
-1
src/gui/value/color.cpp
src/gui/value/color.cpp
+1
-1
src/gui/value/symbol.cpp
src/gui/value/symbol.cpp
+12
-1
src/gui/value/symbol.hpp
src/gui/value/symbol.hpp
+3
-0
src/gui/value/text.hpp
src/gui/value/text.hpp
+1
-0
src/render/card/viewer.cpp
src/render/card/viewer.cpp
+2
-3
src/render/symbol/filter.cpp
src/render/symbol/filter.cpp
+1
-1
src/render/symbol/viewer.cpp
src/render/symbol/viewer.cpp
+3
-2
src/render/value/viewer.hpp
src/render/value/viewer.hpp
+9
-6
src/script/script_manager.cpp
src/script/script_manager.cpp
+5
-2
src/util/action_stack.cpp
src/util/action_stack.cpp
+2
-0
src/util/io/package.cpp
src/util/io/package.cpp
+1
-1
src/util/io/package.hpp
src/util/io/package.hpp
+1
-1
src/util/prec.hpp
src/util/prec.hpp
+5
-1
No files found.
src/data/action/symbol_part.hpp
View file @
be4009b6
...
...
@@ -150,7 +150,7 @@ class ControlPointAddAction : public Action {
// ----------------------------------------------------------------------------- : Remove control point
/// Action that removes any number of points from a symbol part
/// TODO: If less then 3 points are left removes the entire part
!
/// TODO: If less then 3 points are left removes the entire part
?
Action
*
controlPointRemoveAction
(
const
SymbolPartP
&
part
,
const
set
<
ControlPointP
>&
toDelete
);
...
...
src/gui/control/graph.cpp
View file @
be4009b6
...
...
@@ -203,7 +203,7 @@ void GraphControl::setData(const GraphDataPre& data) {
void
GraphControl
::
setData
(
const
GraphDataP
&
data
)
{
if
(
graph
)
{
graph
->
setData
(
data
);
current_item
.
clear
();
// TODO : preserve
r
selection
current_item
.
clear
();
// TODO : preserve selection
Refresh
(
false
);
}
}
...
...
src/gui/symbol/control.cpp
View file @
be4009b6
...
...
@@ -201,7 +201,7 @@ void SymbolControl::onSize(wxSizeEvent& ev) {
Refresh
(
false
);
}
void
SymbolControl
::
onUpdateUI
(
wxUpdateUIEvent
&
ev
)
{
if
(
!
editor
)
return
;
if
(
!
editor
)
return
;
switch
(
ev
.
GetId
())
{
case
ID_MODE_SELECT
:
case
ID_MODE_ROTATE
:
case
ID_MODE_POINTS
:
case
ID_MODE_SHAPES
:
//case ID_MODE_PAINT:
ev
.
Check
(
editor
->
modeToolId
()
==
ev
.
GetId
());
...
...
src/gui/symbol/window.cpp
View file @
be4009b6
...
...
@@ -10,8 +10,12 @@
#include <gui/symbol/control.hpp>
#include <gui/symbol/part_list.hpp>
#include <gui/icon_menu.hpp>
#include <data/set.hpp>
#include <data/field/symbol.hpp>
#include <data/action/value.hpp>
#include <util/window_id.hpp>
#include <util/io/reader.hpp>
#include <util/error.hpp>
#include <wx/filename.h>
#include <wx/wfstream.h>
...
...
@@ -29,7 +33,7 @@ SymbolPartP defaultSymbolPart(double d) {
}
// A default symbol, a square
SymbolP
default
S
ymbol
()
{
SymbolP
default
_s
ymbol
()
{
SymbolP
symbol
=
new_shared
<
Symbol
>
();
symbol
->
parts
.
push_back
(
defaultSymbolPart
(
0
));
return
symbol
;
...
...
@@ -38,12 +42,29 @@ SymbolP defaultSymbol() {
// ----------------------------------------------------------------------------- : Constructor
SymbolWindow
::
SymbolWindow
(
Window
*
parent
)
{
init
(
parent
,
default
S
ymbol
());
init
(
parent
,
default
_s
ymbol
());
}
SymbolWindow
::
SymbolWindow
(
Window
*
parent
,
String
filename
)
{
// TODO
init
(
parent
,
defaultSymbol
());
SymbolWindow
::
SymbolWindow
(
Window
*
parent
,
const
String
&
filename
)
{
// TODO : open file
init
(
parent
,
default_symbol
());
}
SymbolWindow
::
SymbolWindow
(
Window
*
parent
,
const
SymbolValueP
&
value
,
const
SetP
&
set
)
:
value
(
value
),
set
(
set
)
{
// attempt to load symbol
SymbolP
symbol
;
if
(
!
value
->
filename
.
empty
())
{
try
{
// load symbol
symbol
=
set
->
readFile
<
SymbolP
>
(
value
->
filename
);
}
catch
(
const
Error
&
e
)
{
handle_error
(
e
);
}
}
if
(
!
symbol
)
symbol
=
default_symbol
();
init
(
parent
,
symbol
);
}
void
SymbolWindow
::
init
(
Window
*
parent
,
SymbolP
symbol
)
{
...
...
@@ -122,12 +143,17 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
s
->
Add
(
v
,
0
,
wxEXPAND
);
s
->
Add
(
control
,
1
,
wxEXPAND
);
SetSizer
(
s
);
// we want update ui events
wxUpdateUIEvent
::
SetMode
(
wxUPDATE_UI_PROCESS_SPECIFIED
);
SetExtraStyle
(
wxWS_EX_PROCESS_UI_UPDATES
);
em
->
SetExtraStyle
(
wxWS_EX_PROCESS_UI_UPDATES
);
}
// ----------------------------------------------------------------------------- : Event handling
void
SymbolWindow
::
onFileNew
(
wxCommandEvent
&
ev
)
{
SymbolP
symbol
=
default
S
ymbol
();
SymbolP
symbol
=
default
_s
ymbol
();
parts
->
setSymbol
(
symbol
);
control
->
setSymbol
(
symbol
);
}
...
...
@@ -151,12 +177,25 @@ void SymbolWindow::onFileOpen(wxCommandEvent& ev) {
}
void
SymbolWindow
::
onFileSave
(
wxCommandEvent
&
ev
)
{
// TODO
onFileSaveAs
(
ev
);
}
void
SymbolWindow
::
onFileSaveAs
(
wxCommandEvent
&
ev
)
{
String
name
=
wxFileSelector
(
_
(
"Save symbol"
),
_
(
""
),
_
(
""
),
_
(
""
),
_
(
"Symbol files (*.mse-symbol)|*.mse-symbol"
),
wxSAVE
,
this
);
if
(
!
name
.
empty
())
{
Writer
writer
(
new_shared1
<
wxFileOutputStream
>
(
name
));
writer
.
handle
(
control
->
getSymbol
());
}
}
void
SymbolWindow
::
onFileStore
(
wxCommandEvent
&
ev
)
{
if
(
value
)
{
FileName
new_filename
=
set
->
newFileName
(
value
->
field
().
name
,
_
(
".mse-symbol"
));
// a new unique name in the package
Writer
writer
(
set
->
openOut
(
new_filename
));
writer
.
handle
(
control
->
getSymbol
());
set
->
actions
.
add
(
value_action
(
value
,
new_filename
));
}
}
void
SymbolWindow
::
onFileExit
(
wxCommandEvent
&
ev
)
{
...
...
@@ -191,7 +230,7 @@ void SymbolWindow::onUpdateUI(wxUpdateUIEvent& ev) {
switch
(
ev
.
GetId
())
{
// file menu
case
ID_FILE_STORE
:
{
//
ev.Enable(value);
ev
.
Enable
(
value
);
break
;
// undo/redo
}
case
ID_EDIT_UNDO
:
{
...
...
src/gui/symbol/window.hpp
View file @
be4009b6
...
...
@@ -9,13 +9,14 @@
// ----------------------------------------------------------------------------- : Includes
#include
"../../util/prec.hpp"
#include
<util/prec.hpp>
#include <data/symbol.hpp>
#include <wx/listctrl.h>
//#include "control.hpp"
class
SymbolControl
;
class
SymbolPartList
;
DECLARE_POINTER_TYPE
(
SymbolValue
);
DECLARE_POINTER_TYPE
(
Set
);
// ----------------------------------------------------------------------------- : SymbolWindow
...
...
@@ -25,9 +26,9 @@ class SymbolWindow : public Frame {
/// Construct a SymbolWindow
SymbolWindow
(
Window
*
parent
);
/// Construct a SymbolWindow showing a symbol from a file
SymbolWindow
(
Window
*
parent
,
String
filename
);
// /// Construct a SymbolWindow showing a symbol
from
a set
// SymbolWindow(Window* paren
t);
SymbolWindow
(
Window
*
parent
,
const
String
&
filename
);
// /// Construct a SymbolWindow showing a symbol
value in
a set
SymbolWindow
(
Window
*
parent
,
const
SymbolValueP
&
value
,
const
SetP
&
se
t
);
private:
// --------------------------------------------------- : Children
...
...
@@ -39,8 +40,8 @@ class SymbolWindow : public Frame {
SymbolPartList
*
parts
;
///< A list of parts in the symbol
// when editing a symbol field
// SymbolValueP value
// SetP set
SymbolValueP
value
;
SetP
set
;
// --------------------------------------------------- : Event handling
DECLARE_EVENT_TABLE
();
...
...
src/gui/value/choice.cpp
View file @
be4009b6
...
...
@@ -112,5 +112,5 @@ void ChoiceValueEditor::determineSize() {
}
void
ChoiceValueEditor
::
change
(
const
Defaultable
<
String
>&
c
)
{
getSet
().
actions
.
add
(
value_action
(
static_pointer_cast
<
ChoiceValue
>
(
valueP
),
c
));
getSet
().
actions
.
add
(
value_action
(
valueP
(
),
c
));
}
src/gui/value/color.cpp
View file @
be4009b6
...
...
@@ -148,7 +148,7 @@ void ColorValueEditor::determineSize() {
}
void
ColorValueEditor
::
change
(
const
Defaultable
<
Color
>&
c
)
{
getSet
().
actions
.
add
(
value_action
(
static_pointer_cast
<
ColorValue
>
(
valueP
),
c
));
getSet
().
actions
.
add
(
value_action
(
valueP
(
),
c
));
}
void
ColorValueEditor
::
changeCustom
()
{
Color
c
=
wxGetColourFromUser
(
0
,
value
().
value
());
...
...
src/gui/value/symbol.cpp
View file @
be4009b6
...
...
@@ -7,7 +7,18 @@
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/symbol.hpp>
#include <gui/symbol/window.hpp>
// ----------------------------------------------------------------------------- :
// ----------------------------------------------------------------------------- :
SymbolValueEditor
IMPLEMENT_VALUE_EDITOR
(
Symbol
)
{}
void
SymbolValueEditor
::
onLeftDClick
(
const
RealPoint
&
pos
,
wxMouseEvent
&
)
{
// TODO : use SetWindow as parent? Maybe not, the symbol editor will stay open when mainwindow closes
SymbolWindow
*
wnd
=
new
SymbolWindow
(
nullptr
,
valueP
(),
viewer
.
getSet
());
wnd
->
Show
();
}
void
SymbolValueEditor
::
determineSize
()
{
style
().
height
=
50
;
}
src/gui/value/symbol.hpp
View file @
be4009b6
...
...
@@ -19,6 +19,9 @@
class
SymbolValueEditor
:
public
SymbolValueViewer
,
public
ValueEditor
{
public:
DECLARE_VALUE_EDITOR
(
Symbol
);
virtual
void
onLeftDClick
(
const
RealPoint
&
pos
,
wxMouseEvent
&
);
virtual
void
determineSize
();
};
// ----------------------------------------------------------------------------- : EOF
...
...
src/gui/value/text.hpp
View file @
be4009b6
...
...
@@ -20,6 +20,7 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR
(
Text
);
// virtual void determineSize();
};
// ----------------------------------------------------------------------------- : EOF
...
...
src/render/card/viewer.cpp
View file @
be4009b6
...
...
@@ -95,9 +95,8 @@ void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
(
s
->
width
||
s
->
width
.
isScripted
())
&&
(
s
->
height
||
s
->
height
.
isScripted
())))
{
// no need to make a viewer for things that are always invisible
viewers
.
push_back
(
makeViewer
(
s
));
// REMOVEME //TODO //%%%
if
(
!
viewers
.
back
())
viewers
.
pop_back
();
ValueViewerP
viewer
=
makeViewer
(
s
);
if
(
viewer
)
viewers
.
push_back
(
viewer
);
}
}
// sort viewers by z-index of style
...
...
src/render/symbol/filter.cpp
View file @
be4009b6
...
...
@@ -28,7 +28,7 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
AColor
result
=
filter
.
color
((
double
)
x
/
width
,
(
double
)
y
/
height
,
point
);
// Store color
data
[
0
]
=
result
.
Red
();
data
[
2
]
=
result
.
Green
();
data
[
1
]
=
result
.
Green
();
data
[
2
]
=
result
.
Blue
();
alpha
[
0
]
=
result
.
alpha
;
// next
...
...
src/render/symbol/viewer.cpp
View file @
be4009b6
...
...
@@ -18,7 +18,8 @@ Image render_symbol(const SymbolP& symbol, double border_radius, int size) {
Bitmap
bmp
(
size
,
size
);
wxMemoryDC
dc
;
dc
.
SelectObject
(
bmp
);
clearDC_black
(
dc
);
clearDC
(
dc
,
Color
(
0
,
128
,
0
));
viewer
.
rotation
.
setZoom
(
size
);
viewer
.
draw
(
dc
);
dc
.
SelectObject
(
wxNullBitmap
);
return
bmp
.
ConvertToImage
();
...
...
@@ -28,7 +29,7 @@ Image render_symbol(const SymbolP& symbol, double border_radius, int size) {
SymbolViewer
::
SymbolViewer
(
const
SymbolP
&
symbol
,
double
border_radius
)
:
border_radius
(
border_radius
)
,
rotation
(
0
,
RealRect
(
0
,
0
,
500
,
500
))
,
rotation
(
0
,
RealRect
(
0
,
0
,
500
,
500
)
,
500
)
{
setSymbol
(
symbol
);
}
...
...
src/render/value/viewer.hpp
View file @
be4009b6
...
...
@@ -79,12 +79,15 @@ class ValueViewer {
// ----------------------------------------------------------------------------- : Utility
#define DECLARE_VALUE_VIEWER(Type) \
protected
:
\
inline
Type
##
Style
&
style
()
const
{
return
static_cast
<
Type
##
Style
&>
(
*
styleP
);
}
\
inline
const
Type
##
Value
&
value
()
const
{
return
static_cast
<
const
Type
##
Value
&>
(
*
valueP
);
}
\
inline
const
Type
##
Field
&
field
()
const
{
return
style
().
field
();
}
\
public
:
\
#define DECLARE_VALUE_VIEWER(Type) \
protected
:
\
inline
Type
##
Style
&
style
()
const
{
return
static_cast
<
Type
##
Style
&>
(
*
ValueViewer
::
styleP
);
}
\
inline
const
Type
##
Value
&
value
()
const
{
return
static_cast
<
const
Type
##
Value
&>
(
*
ValueViewer
::
valueP
);
}
\
inline
const
Type
##
Field
&
field
()
const
{
return
style
().
field
();
}
\
inline
Type
##
StyleP
styleP
()
const
{
return
static_pointer_cast
<
Type
##
Style
>
(
ValueViewer
::
styleP
);
}
\
inline
Type
##
ValueP
valueP
()
const
{
return
static_pointer_cast
<
Type
##
Value
>
(
ValueViewer
::
valueP
);
}
\
inline
Type
##
FieldP
fieldP
()
const
{
return
static_pointer_cast
<
Type
##
Field
>
(
style
().
fieldP
);
}
\
public
:
\
Type
##
ValueViewer
(
DataViewer
&
parent
,
const
Type
##
StyleP
&
style
)
...
...
src/script/script_manager.cpp
View file @
be4009b6
...
...
@@ -217,18 +217,21 @@ void ScriptManager::alsoUpdate(deque<ToUpdate>& to_update, const vector<Dependen
}
break
;
}
case
DEP_CARDS_FIELD
:
{
// TODO
break
;
}
case
DEP_STYLE
:
{
// TODO
break
;
}
case
DEP_CARD_COPY_DEP
:
{
// TODO
break
;
}
case
DEP_SET_COPY_DEP
:
{
// TODO
break
;
}
default
:
assert
(
false
);
}
/*
if (d.type == DependendScript.setField) {
/* if (d.type == DependendScript.setField) {
// from set data
ValueP value = set->data.at(ds.index);
toUpdate.push_back(ToUpdate(&*value));
...
...
src/util/action_stack.cpp
View file @
be4009b6
...
...
@@ -43,6 +43,7 @@ void ActionStack::add(Action* action, bool allow_merge) {
void
ActionStack
::
undo
()
{
assert
(
canUndo
());
if
(
!
canUndo
())
return
;
Action
*
action
=
undo_actions
.
back
();
action
->
perform
(
true
);
tellListeners
(
*
action
,
true
);
...
...
@@ -52,6 +53,7 @@ void ActionStack::undo() {
}
void
ActionStack
::
redo
()
{
assert
(
canRedo
());
if
(
!
canRedo
())
return
;
Action
*
action
=
redo_actions
.
back
();
action
->
perform
(
false
);
tellListeners
(
*
action
,
false
);
...
...
src/util/io/package.cpp
View file @
be4009b6
...
...
@@ -203,7 +203,7 @@ String Package::nameOut(const String& file) {
}
}
String
Package
::
newFileName
(
const
String
&
prefix
,
const
String
&
suffix
)
{
FileName
Package
::
newFileName
(
const
String
&
prefix
,
const
String
&
suffix
)
{
assert
(
wxThread
::
IsMain
());
// Writing should only be done from the main thread
String
name
;
UInt
infix
=
0
;
...
...
src/util/io/package.hpp
View file @
be4009b6
...
...
@@ -98,7 +98,7 @@ class Package {
/// Creates a new, unique, filename with the specified prefix and suffix
/// for example newFileName("image/",".jpg") -> "image/1.jpg"
/// Returns the name of a temporary file that can be written to.
String
newFileName
(
const
String
&
prefix
,
const
String
&
suffix
);
FileName
newFileName
(
const
String
&
prefix
,
const
String
&
suffix
);
/// Signal that a file is still used by this package.
/// Must be called for files not opened using openOut/nameOut
...
...
src/util/prec.hpp
View file @
be4009b6
...
...
@@ -66,7 +66,11 @@ typedef unsigned int UInt;
#define nullptr 0
/// A string standing for a filename, has different behaviour when reading/writing
class
FileName
:
public
String
{};
class
FileName
:
public
String
{
public:
FileName
()
{}
FileName
(
const
String
&
s
)
:
String
(
s
)
{}
};
// ----------------------------------------------------------------------------- : EOF
#endif
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