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
872d1463
Commit
872d1463
authored
Aug 23, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some tweaks to word drop down list
parent
ced4ee14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
21 deletions
+61
-21
src/gui/drop_down_list.cpp
src/gui/drop_down_list.cpp
+2
-2
src/gui/drop_down_list.hpp
src/gui/drop_down_list.hpp
+4
-2
src/gui/value/text.cpp
src/gui/value/text.cpp
+49
-14
src/gui/value/text.hpp
src/gui/value/text.hpp
+4
-2
src/script/functions/editor.cpp
src/script/functions/editor.cpp
+2
-1
No files found.
src/gui/drop_down_list.cpp
View file @
872d1463
...
@@ -84,7 +84,7 @@ DropDownList::~DropDownList() {
...
@@ -84,7 +84,7 @@ DropDownList::~DropDownList() {
delete
hider2
;
delete
hider2
;
}
}
void
DropDownList
::
show
(
bool
in_place
,
wxPoint
pos
)
{
void
DropDownList
::
show
(
bool
in_place
,
wxPoint
pos
,
RealRect
*
rect
)
{
if
(
IsShown
())
return
;
if
(
IsShown
())
return
;
onShow
();
onShow
();
// find selection
// find selection
...
@@ -111,7 +111,7 @@ void DropDownList::show(bool in_place, wxPoint pos) {
...
@@ -111,7 +111,7 @@ void DropDownList::show(bool in_place, wxPoint pos) {
int
parent_height
=
0
;
int
parent_height
=
0
;
if
(
!
in_place
&&
viewer
)
{
if
(
!
in_place
&&
viewer
)
{
// Position the drop down list below the editor control (based on the style)
// Position the drop down list below the editor control (based on the style)
RealRect
r
=
viewer
->
viewer
.
getRotation
().
trNoNeg
(
viewer
->
getStyle
()
->
getRect
());
RealRect
r
=
viewer
->
viewer
.
getRotation
().
trNoNeg
(
rect
?
*
rect
:
viewer
->
getStyle
()
->
getRect
());
if
(
viewer
->
viewer
.
nativeLook
())
{
if
(
viewer
->
viewer
.
nativeLook
())
{
pos
=
RealPoint
(
r
.
x
-
3
,
r
.
y
-
3
);
pos
=
RealPoint
(
r
.
x
-
3
,
r
.
y
-
3
);
size
.
width
=
max
(
size
.
width
,
r
.
width
+
6
);
size
.
width
=
max
(
size
.
width
,
r
.
width
+
6
);
...
...
src/gui/drop_down_list.hpp
View file @
872d1463
...
@@ -28,8 +28,10 @@ class DropDownList : public wxPopupWindow {
...
@@ -28,8 +28,10 @@ class DropDownList : public wxPopupWindow {
DropDownList
(
Window
*
parent
,
bool
is_submenu
=
false
,
ValueViewer
*
viewer
=
nullptr
);
DropDownList
(
Window
*
parent
,
bool
is_submenu
=
false
,
ValueViewer
*
viewer
=
nullptr
);
/// Show the editor
/// Show the editor
/** if in_place, then shows the list at the position pos */
/** if in_place, then shows the list at the position pos.
void
show
(
bool
in_place
,
wxPoint
pos
);
* Otherwise around the rect or the viewer rectangle
*/
void
show
(
bool
in_place
,
wxPoint
pos
,
RealRect
*
rect
=
nullptr
);
/// Close the list, optionally send an onSelect event
/// Close the list, optionally send an onSelect event
void
hide
(
bool
event
,
bool
allow_veto
=
true
);
void
hide
(
bool
event
,
bool
allow_veto
=
true
);
...
...
src/gui/value/text.cpp
View file @
872d1463
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
DECLARE_SHARED_POINTER_TYPE
(
DropDownList
);
DECLARE_SHARED_POINTER_TYPE
(
DropDownList
);
DECLARE_TYPEOF_COLLECTION
(
WordListP
);
DECLARE_TYPEOF_COLLECTION
(
WordListP
);
DECLARE_TYPEOF_COLLECTION
(
WordListWordP
);
DECLARE_TYPEOF_COLLECTION
(
WordListPosP
);
DECLARE_TYPEOF_COLLECTION
(
WordListPosP
);
// ----------------------------------------------------------------------------- : TextValueEditorScrollBar
// ----------------------------------------------------------------------------- : TextValueEditorScrollBar
...
@@ -134,7 +135,14 @@ DropDownList* DropDownWordList::submenu(size_t item) const {
...
@@ -134,7 +135,14 @@ DropDownList* DropDownWordList::submenu(size_t item) const {
size_t
DropDownWordList
::
selection
()
const
{
size_t
DropDownWordList
::
selection
()
const
{
// TODO: find selection
// current selection
String
current
=
untag
(
tve
.
value
().
value
().
substr
(
pos
->
start
,
pos
->
end
-
pos
->
start
));
// find selection
size_t
i
=
0
;
FOR_EACH
(
w
,
words
->
words
)
{
if
(
current
==
w
->
name
)
return
i
;
++
i
;
}
return
NO_SELECTION
;
return
NO_SELECTION
;
}
}
...
@@ -143,7 +151,8 @@ void DropDownWordList::select(size_t item) {
...
@@ -143,7 +151,8 @@ void DropDownWordList::select(size_t item) {
tve
.
selection_start_i
=
pos
->
start
;
tve
.
selection_start_i
=
pos
->
start
;
tve
.
selection_end_i
=
pos
->
end
;
tve
.
selection_end_i
=
pos
->
end
;
tve
.
fixSelection
(
TYPE_INDEX
);
tve
.
fixSelection
(
TYPE_INDEX
);
tve
.
replaceSelection
(
words
->
words
[
item
]
->
name
,
_ACTION_
(
"?????"
));
tve
.
replaceSelection
(
escape
(
words
->
words
[
item
]
->
name
),
format_string
(
_ACTION_
(
"change"
),
tve
.
field
().
name
));
}
}
// ----------------------------------------------------------------------------- : TextValueEditor
// ----------------------------------------------------------------------------- : TextValueEditor
...
@@ -171,13 +180,7 @@ bool TextValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
...
@@ -171,13 +180,7 @@ bool TextValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
// on word list dropdown button?
// on word list dropdown button?
WordListPosP
wl_pos
=
findWordList
(
pos2
);
WordListPosP
wl_pos
=
findWordList
(
pos2
);
if
(
wl_pos
)
{
if
(
wl_pos
)
{
// show dropdown
wordListDropDown
(
wl_pos
);
if
(
drop_down
)
{
drop_down
->
setWords
(
wl_pos
);
}
else
{
drop_down
.
reset
(
new
DropDownWordList
(
&
editor
(),
false
,
*
this
,
wl_pos
,
wl_pos
->
word_list
));
}
drop_down
->
show
(
false
,
wxPoint
(
0
,
0
));
// TODO: position?
}
else
{
}
else
{
// no, select text
// no, select text
selecting
=
true
;
selecting
=
true
;
...
@@ -215,6 +218,7 @@ bool TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
...
@@ -215,6 +218,7 @@ bool TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
}
}
bool
TextValueEditor
::
onLeftDClick
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
bool
TextValueEditor
::
onLeftDClick
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
if
(
dropDownShown
())
return
false
;
select_words
=
true
;
select_words
=
true
;
size_t
index
=
v
.
indexAt
(
style
().
getRotation
().
trInv
(
pos
));
size_t
index
=
v
.
indexAt
(
style
().
getRotation
().
trInv
(
pos
));
moveSelection
(
TYPE_INDEX
,
prevWordBoundry
(
index
),
true
,
MOVE_MID
);
moveSelection
(
TYPE_INDEX
,
prevWordBoundry
(
index
),
true
,
MOVE_MID
);
...
@@ -223,6 +227,7 @@ bool TextValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent& ev) {
...
@@ -223,6 +227,7 @@ bool TextValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent& ev) {
}
}
bool
TextValueEditor
::
onRightDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
bool
TextValueEditor
::
onRightDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
if
(
dropDownShown
())
return
false
;
size_t
index
=
v
.
indexAt
(
style
().
getRotation
().
trInv
(
pos
));
size_t
index
=
v
.
indexAt
(
style
().
getRotation
().
trInv
(
pos
));
if
(
index
<
min
(
selection_start_i
,
selection_end_i
)
||
if
(
index
<
min
(
selection_start_i
,
selection_end_i
)
||
index
>
max
(
selection_start_i
,
selection_end_i
))
{
index
>
max
(
selection_start_i
,
selection_end_i
))
{
...
@@ -259,10 +264,18 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
...
@@ -259,10 +264,18 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
}
}
break
;
break
;
case
WXK_UP
:
case
WXK_UP
:
moveSelection
(
TYPE_INDEX
,
v
.
moveLine
(
selection_end_i
,
-
1
),
!
ev
.
ShiftDown
(),
MOVE_LEFT_OPT
);
if
(
field
().
multi_line
)
{
moveSelection
(
TYPE_INDEX
,
v
.
moveLine
(
selection_end_i
,
-
1
),
!
ev
.
ShiftDown
(),
MOVE_LEFT_OPT
);
}
else
{
wordListDropDown
(
findWordList
(
selection_end_i
));
}
break
;
break
;
case
WXK_DOWN
:
case
WXK_DOWN
:
moveSelection
(
TYPE_INDEX
,
v
.
moveLine
(
selection_end_i
,
+
1
),
!
ev
.
ShiftDown
(),
MOVE_RIGHT_OPT
);
if
(
field
().
multi_line
)
{
moveSelection
(
TYPE_INDEX
,
v
.
moveLine
(
selection_end_i
,
+
1
),
!
ev
.
ShiftDown
(),
MOVE_RIGHT_OPT
);
}
else
{
wordListDropDown
(
findWordList
(
selection_end_i
));
}
break
;
break
;
case
WXK_HOME
:
case
WXK_HOME
:
// move to begining of line / all (if control)
// move to begining of line / all (if control)
...
@@ -1016,6 +1029,7 @@ void TextValueEditor::findWordLists() {
...
@@ -1016,6 +1029,7 @@ void TextValueEditor::findWordLists() {
}
}
void
TextValueEditor
::
drawWordListIndicators
(
RotatedDC
&
dc
)
{
void
TextValueEditor
::
drawWordListIndicators
(
RotatedDC
&
dc
)
{
Rotater
rot
(
dc
,
style
().
getRotation
());
bool
current
=
isCurrent
();
bool
current
=
isCurrent
();
FOR_EACH
(
wl
,
word_lists
)
{
FOR_EACH
(
wl
,
word_lists
)
{
RealRect
&
r
=
wl
->
rect
;
RealRect
&
r
=
wl
->
rect
;
...
@@ -1039,16 +1053,16 @@ void TextValueEditor::drawWordListIndicators(RotatedDC& dc) {
...
@@ -1039,16 +1053,16 @@ void TextValueEditor::drawWordListIndicators(RotatedDC& dc) {
dc
.
SetPen
(
Color
(
128
,
128
,
128
));
dc
.
SetPen
(
Color
(
128
,
128
,
128
));
dc
.
SetBrush
(
Color
(
192
,
192
,
192
));
dc
.
SetBrush
(
Color
(
192
,
192
,
192
));
}
}
dc
.
DrawRectangle
(
RealRect
(
style
().
left
+
r
.
right
(),
style
().
top
+
r
.
top
(),
9
,
r
.
height
));
dc
.
DrawRectangle
(
RealRect
(
r
.
right
(),
r
.
top
(),
9
,
r
.
height
));
// draw foreground
// draw foreground
/*
/*
dc.SetPen (*wxTRANSPARENT_PEN);
dc.SetPen (*wxTRANSPARENT_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
dc.SetBrush(*wxBLACK_BRUSH);
wxPoint poly[] = {dc.tr(RealPoint(0,0)), dc.tr(RealPoint(5,0)), dc.tr(RealPoint(3,2))};
wxPoint poly[] = {dc.tr(RealPoint(0,0)), dc.tr(RealPoint(5,0)), dc.tr(RealPoint(3,2))};
dc.getDC().DrawPolygon(3, poly,
style().left + r.right() + 2, style().top +
r.bottom() - 5);
dc.getDC().DrawPolygon(3, poly,
r.right() + 2,
r.bottom() - 5);
*/
*/
dc
.
SetPen
(
*
wxBLACK_PEN
);
dc
.
SetPen
(
*
wxBLACK_PEN
);
double
x
=
style
().
left
+
r
.
right
(),
y
=
style
().
top
+
r
.
bottom
();
double
x
=
r
.
right
(),
y
=
r
.
bottom
();
dc
.
DrawLine
(
RealPoint
(
x
+
4
,
y
-
3
),
RealPoint
(
x
+
5
,
y
-
3
));
dc
.
DrawLine
(
RealPoint
(
x
+
4
,
y
-
3
),
RealPoint
(
x
+
5
,
y
-
3
));
dc
.
DrawLine
(
RealPoint
(
x
+
3
,
y
-
4
),
RealPoint
(
x
+
6
,
y
-
4
));
dc
.
DrawLine
(
RealPoint
(
x
+
3
,
y
-
4
),
RealPoint
(
x
+
6
,
y
-
4
));
dc
.
DrawLine
(
RealPoint
(
x
+
2
,
y
-
5
),
RealPoint
(
x
+
7
,
y
-
5
));
dc
.
DrawLine
(
RealPoint
(
x
+
2
,
y
-
5
),
RealPoint
(
x
+
7
,
y
-
5
));
...
@@ -1065,3 +1079,24 @@ WordListPosP TextValueEditor::findWordList(const RealPoint& pos) const {
...
@@ -1065,3 +1079,24 @@ WordListPosP TextValueEditor::findWordList(const RealPoint& pos) const {
}
}
return
WordListPosP
();
return
WordListPosP
();
}
}
WordListPosP
TextValueEditor
::
findWordList
(
size_t
index
)
const
{
FOR_EACH_CONST
(
wl
,
word_lists
)
{
if
(
index
>=
wl
->
start
&&
index
<=
wl
->
end
)
{
return
wl
;
}
}
return
WordListPosP
();
}
bool
TextValueEditor
::
wordListDropDown
(
const
WordListPosP
&
wl
)
{
if
(
!
wl
)
return
false
;
// show dropdown
if
(
drop_down
)
{
drop_down
->
setWords
(
wl
);
}
else
{
drop_down
.
reset
(
new
DropDownWordList
(
&
editor
(),
false
,
*
this
,
wl
,
wl
->
word_list
));
}
RealRect
rect
=
wl
->
rect
.
move
(
style
().
left
,
style
().
top
,
0
,
0
);
drop_down
->
show
(
false
,
wxPoint
(
0
,
0
),
&
rect
);
return
true
;
}
src/gui/value/text.hpp
View file @
872d1463
...
@@ -164,8 +164,10 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
...
@@ -164,8 +164,10 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
void
drawWordListIndicators
(
RotatedDC
&
dc
);
void
drawWordListIndicators
(
RotatedDC
&
dc
);
/// Find a WordListPos under the mouse cursor (if any), pos is in internal coordinates
/// Find a WordListPos under the mouse cursor (if any), pos is in internal coordinates
WordListPosP
findWordList
(
const
RealPoint
&
pos
)
const
;
WordListPosP
findWordList
(
const
RealPoint
&
pos
)
const
;
/// Show a word list drop down menu
/// Find a WordListPos for a index position
void
wordListDropDown
(
const
WordListPosP
&
pos
);
WordListPosP
findWordList
(
size_t
index
)
const
;
/// Show a word list drop down menu, if wl
bool
wordListDropDown
(
const
WordListPosP
&
wl
);
};
};
...
...
src/script/functions/editor.cpp
View file @
872d1463
...
@@ -67,7 +67,8 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) {
...
@@ -67,7 +67,8 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) {
// update the values if our input value is newer?
// update the values if our input value is newer?
Age
new_value_update
=
last_update_age
();
Age
new_value_update
=
last_update_age
();
FOR_EACH_2
(
v
,
values
,
nv
,
value_parts
)
{
FOR_EACH_2
(
v
,
values
,
nv
,
value_parts
)
{
if
(
v
->
value
()
!=
nv
.
first
&&
v
->
last_update
<
new_value_update
)
{
//if (v->value() != nv.first && v->last_update < new_value_update) {
if
(
v
->
last_update
<
new_value_update
)
{
v
->
value
.
assign
(
nv
.
first
);
v
->
value
.
assign
(
nv
.
first
);
v
->
update
(
ctx
);
v
->
update
(
ctx
);
}
}
...
...
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