mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Allow ValueViewers to have a bounding box different from the Style's. This closes #64.
This commit is contained in:
@@ -150,7 +150,7 @@ struct CompareTabOrder {
|
||||
};
|
||||
|
||||
bool is_enabled(ValueViewerP const& v) {
|
||||
return v->getField()->editable && v->getStyle()->isVisible();
|
||||
return v->getField()->editable && v->isVisible();
|
||||
}
|
||||
|
||||
bool DataEditor::selectWithTab(vector<ValueViewerP>::iterator const& it) {
|
||||
@@ -210,7 +210,7 @@ bool DataEditor::search(Iterator it, Iterator end, FindInfo& find, bool from_sta
|
||||
for (;it != end; ++it) {
|
||||
ValueViewer* viewer = *it;
|
||||
if (viewer == current_viewer) include = true;
|
||||
if (include && viewer->getField()->editable && viewer->getStyle()->isVisible()) {
|
||||
if (include && viewer->getField()->editable && viewer->isVisible()) {
|
||||
ValueEditor* editor = viewer->getEditor();
|
||||
if (editor) {
|
||||
if (editor && editor->search(find, from_start || viewer != current_viewer)) {
|
||||
|
||||
@@ -44,7 +44,7 @@ void CardViewer::redraw(const ValueViewer& v) {
|
||||
// causing the two viewers to continously refresh.
|
||||
if (drawing_card()) return;
|
||||
up_to_date = false;
|
||||
RefreshRect(getRotation().trRectToBB(v.boundingBox()), false);
|
||||
RefreshRect(getRotation().trRectToBB(v.boundingBoxBorder()), false);
|
||||
}
|
||||
|
||||
void CardViewer::onChange() {
|
||||
@@ -112,7 +112,7 @@ bool CardViewer::shouldDraw(const ValueViewer& v) const {
|
||||
// int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
|
||||
// wxRegion clip = GetUpdateRegion();
|
||||
// clip.Offset(dx, dy);
|
||||
return GetUpdateRegion().Contains(getRotation().trRectToBB(v.boundingBox().toRect()).toRect()) != wxOutRegion;
|
||||
return GetUpdateRegion().Contains(getRotation().trRectToBB(v.boundingBoxBorder().toRect()).toRect()) != wxOutRegion;
|
||||
}
|
||||
|
||||
// helper class for overdrawDC()
|
||||
|
||||
@@ -35,14 +35,13 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
ValueEditor* e = v.getEditor();
|
||||
if (!e || e->drawLabel()) {
|
||||
// draw control border and box
|
||||
Style& s = *v.getStyle();
|
||||
draw_control_box(this, dc.getDC(), dc.trRectToBB(s.getInternalRect().grow(1)), current_editor == e, e != nullptr);
|
||||
draw_control_box(this, dc.getDC(), dc.getExternalRect().grow(1), current_editor == e, e != nullptr);
|
||||
// draw label
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
// TODO : tr using stylesheet or using game?
|
||||
dc.DrawText(tr(getStylePackage(), s.fieldP->caption, identity),
|
||||
RealPoint(margin_left - s.left, 1));
|
||||
dc.DrawText(tr(getStylePackage(), v.getField()->caption, identity),
|
||||
RealPoint(margin_left - v.bounding_box.x, 1));
|
||||
}
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
@@ -76,15 +75,15 @@ void NativeLookEditor::resizeViewers() {
|
||||
StyleP s = v->getStyle();
|
||||
ValueEditor* e = v->getEditor();
|
||||
if (!e || e->drawLabel()) {
|
||||
s->left = margin + label_width;
|
||||
v->bounding_box.x = margin + label_width;
|
||||
} else {
|
||||
s->left = margin;
|
||||
v->bounding_box.x = margin;
|
||||
}
|
||||
s->top = y;
|
||||
s->width = w - s->left - margin;
|
||||
s->height = default_height;
|
||||
v->bounding_box.y = y;
|
||||
v->bounding_box.width = w - v->bounding_box.x - margin;
|
||||
v->bounding_box.height = s->height() == 0 ? default_height : s->height;
|
||||
if (e) e->determineSize();
|
||||
y += s->height + vspace;
|
||||
y += v->bounding_box.height + vspace;
|
||||
}
|
||||
y = y - vspace + margin;
|
||||
SetVirtualSize(w, (int)y);
|
||||
@@ -93,17 +92,6 @@ void NativeLookEditor::resizeViewers() {
|
||||
}
|
||||
if (y >= h) {
|
||||
// Doesn't fit vertically, add scrollbar and resize
|
||||
/*
|
||||
y = margin;
|
||||
FOR_EACH(v, viewers) {
|
||||
StyleP s = v->getStyle();
|
||||
ValueEditor* e = v->getEditor();
|
||||
s->top = y;
|
||||
s->width = s->width - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
|
||||
if (e) e->determineSize();
|
||||
y += s->height + vspace;
|
||||
}
|
||||
*/
|
||||
// create scrollbar
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ TextFieldP TextCtrl::getFieldP() {
|
||||
}
|
||||
void TextCtrl::updateSize() {
|
||||
wxSize cs = GetClientSize();
|
||||
Style& style = getStyle();
|
||||
style.width = cs.GetWidth() - 2;
|
||||
style.height = cs.GetHeight() - 2;
|
||||
ValueViewer& viewer = *viewers.front();
|
||||
viewer.bounding_box.width = cs.GetWidth() - 2;
|
||||
viewer.bounding_box.height = cs.GetHeight() - 2;
|
||||
viewers.front()->getEditor()->determineSize(true);
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ void TextCtrl::onChangeSet() {
|
||||
// initialize
|
||||
if (viewers.empty()) {
|
||||
// create a field, style and value
|
||||
TextFieldP field(new TextField);
|
||||
TextStyleP style(new TextStyle(field));
|
||||
TextValueP value(new FakeTextValue(field, nullptr, false, false));
|
||||
TextFieldP field = make_intrusive<TextField>();
|
||||
TextStyleP style = make_intrusive<TextStyle>(field);
|
||||
TextValueP value = make_intrusive<FakeTextValue>(field, nullptr, false, false);
|
||||
// set stuff
|
||||
field->index = 0;
|
||||
field->multi_line = multi_line;
|
||||
|
||||
Reference in New Issue
Block a user