Track editing fix

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
This commit is contained in:
kavi khalique 2024-08-20 18:07:31 +05:30 committed by Viktor Havaka
parent f6a59f4e66
commit c1d7287a18
17 changed files with 183 additions and 55 deletions

View file

@ -588,6 +588,11 @@ void Framework::ReplaceTrack(kml::TrackId trackId, kml::TrackData & trackData)
m_work.GetBookmarkManager().GetEditSession().UpdateTrack(trackId, trackData);
}
void Framework::ChangeTrackColor(kml::TrackId trackId, uint32_t color)
{
m_work.GetBookmarkManager().GetEditSession().ChangeTrackColor(trackId, color);
}
void Framework::MoveBookmark(kml::MarkId markId, kml::MarkGroupId curCat, kml::MarkGroupId newCat)
{
m_work.GetBookmarkManager().GetEditSession().MoveBookmark(markId, curCat, newCat);

View file

@ -158,6 +158,7 @@ namespace android
void Scale(::Framework::EScaleMode mode);
void Scale(m2::PointD const & centerPt, int targetZoom, bool animate);
void ChangeTrackColor(kml::TrackId trackId, uint32_t color);
void ReplaceBookmark(kml::MarkId markId, kml::BookmarkData & bm);
void ReplaceTrack(kml::TrackId trackId, kml::TrackData & trackData);
void MoveBookmark(kml::MarkId markId, kml::MarkGroupId curCat, kml::MarkGroupId newCat);

View file

@ -790,21 +790,23 @@ Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeSetBookmarkParams(
g_framework->ReplaceBookmark(static_cast<kml::MarkId>(bmk), bmData);
}
constexpr static uint8_t ExtractByte(uint32_t number, uint8_t byteIdx) { return (number >> (8 * byteIdx)) & 0xFF; }
JNIEXPORT void JNICALL
Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeSetTrackParams(
JNIEnv * env, jclass, jlong trackId,
jstring name, jint color, jstring descr)
{
auto const * nTrack = frm()->GetBookmarkManager().GetTrack(static_cast<kml::TrackId>(trackId));
ASSERT(nTrack, ("Track must not be null with id:", trackId));
CHECK(nTrack, ("Track must not be null with id:", trackId));
kml::TrackData trackData(nTrack->GetData());
auto const trkName = jni::ToNativeString(env, name);
if (nTrack->GetName() != trkName)
kml::SetDefaultStr(trackData.m_name, trkName);
if (descr)
kml::SetDefaultStr(trackData.m_description, jni::ToNativeString(env, descr));
trackData.m_layers[0].m_color.m_rgba = static_cast<uint32_t>((color << 8) + 255);
kml::SetDefaultStr(trackData.m_name, trkName);
kml::SetDefaultStr(trackData.m_description, jni::ToNativeString(env, descr));
uint8_t alpha = ExtractByte(color, 3);
trackData.m_layers[0].m_color.m_rgba = static_cast<uint32_t>(shift(color,8) + alpha);
g_framework->ReplaceTrack(static_cast<kml::TrackId>(trackId), trackData);
}
@ -832,6 +834,14 @@ Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeChangeTrackCategory(
static_cast<kml::MarkGroupId>(newCat));
}
JNIEXPORT void JNICALL
Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeChangeTrackColor(
JNIEnv *, jclass, jlong trackId, jint color)
{
uint8_t alpha = ExtractByte(color, 3);
g_framework->ChangeTrackColor(static_cast<kml::TrackId>(trackId), static_cast<uint32_t>(shift(color,8) + alpha));
}
JNIEXPORT jobject JNICALL
Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeGetBookmarkXY(
JNIEnv * env, jclass, jlong bmk)

View file

@ -14,6 +14,7 @@ import app.organicmaps.R;
import app.organicmaps.bookmarks.data.BookmarkCategory;
import app.organicmaps.bookmarks.data.BookmarkInfo;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.bookmarks.data.IconClickListener;
import app.organicmaps.bookmarks.data.SortedBlock;
import app.organicmaps.content.DataSource;
import app.organicmaps.widget.recycler.RecyclerClickListener;
@ -47,6 +48,8 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
private RecyclerClickListener mClickListener;
@Nullable
private RecyclerLongClickListener mLongClickListener;
private RecyclerClickListener mMoreClickListener;
private IconClickListener mIconClickListener;
public static abstract class SectionsDataSource
{
@ -391,8 +394,14 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
mLongClickListener = listener;
}
void setMoreListener(@Nullable RecyclerClickListener listener)
public void setMoreListener(@Nullable RecyclerClickListener listener)
{
mMoreClickListener = listener;
}
public void setIconClickListener(IconClickListener listener)
{
mIconClickListener = listener;
}
@Override
@ -409,6 +418,8 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
false));
trackHolder.setOnClickListener(mClickListener);
trackHolder.setOnLongClickListener(mLongClickListener);
trackHolder.setTrackIconClickListener(mIconClickListener);
trackHolder.setMoreButtonClickListener(mMoreClickListener);
holder = trackHolder;
break;
case TYPE_BOOKMARK:

View file

@ -2,6 +2,7 @@ package app.organicmaps.bookmarks;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -10,6 +11,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.CallSuper;
@ -18,6 +20,8 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.FragmentFactory;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.ConcatAdapter;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
@ -29,12 +33,14 @@ import app.organicmaps.bookmarks.data.BookmarkInfo;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.bookmarks.data.BookmarkSharingResult;
import app.organicmaps.bookmarks.data.CategoryDataSource;
import app.organicmaps.bookmarks.data.Icon;
import app.organicmaps.bookmarks.data.KmlFileType;
import app.organicmaps.bookmarks.data.SortedBlock;
import app.organicmaps.bookmarks.data.Track;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.search.NativeBookmarkSearchListener;
import app.organicmaps.search.SearchEngine;
import app.organicmaps.util.Graphics;
import app.organicmaps.util.SharingUtils;
import app.organicmaps.util.UiUtils;
import app.organicmaps.util.Utils;
@ -42,6 +48,7 @@ import app.organicmaps.util.WindowInsetUtils;
import app.organicmaps.util.bottomsheet.MenuBottomSheetFragment;
import app.organicmaps.util.bottomsheet.MenuBottomSheetItem;
import app.organicmaps.widget.SearchToolbarController;
import app.organicmaps.widget.placepage.BookmarkColorDialogFragment;
import app.organicmaps.widget.placepage.EditBookmarkFragment;
import app.organicmaps.widget.recycler.DividerItemDecorationWithPadding;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
@ -238,6 +245,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
adapter.setOnClickListener((v, position) -> onItemClick(position));
adapter.setOnLongClickListener((v, position) -> onItemMore(position));
adapter.setMoreListener((v, position) -> onItemMore(position));
adapter.setIconClickListener(this::showColorDialog);
}
private void configureFab(@NonNull View view)
@ -579,6 +587,36 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
i.putExtra(MwmActivity.EXTRA_BOOKMARK_ID, bookmark.getBookmarkId());
}
private void showColorDialog(ImageView v, int position)
{
BookmarkListAdapter adapter = getBookmarkListAdapter();
mSelectedPosition = position;
final Track mTrack = (Track) adapter.getItem(mSelectedPosition);
if (mTrack == null) return;
final Bundle args = new Bundle();
args.putInt(BookmarkColorDialogFragment.ICON_TYPE, Icon.getColorPosition(mTrack.getColor()));
final FragmentManager manager = getChildFragmentManager();
String className = BookmarkColorDialogFragment.class.getName();
final FragmentFactory factory = manager.getFragmentFactory();
final BookmarkColorDialogFragment dialogFragment =
(BookmarkColorDialogFragment) factory.instantiate(getContext().getClassLoader(), className);
dialogFragment.setArguments(args);
dialogFragment.setOnColorSetListener((colorPos) -> {
int from = mTrack.getColor();
int to = BookmarkManager.ICONS.get(colorPos).argb();
if (from == to)
return;
BookmarkManager.INSTANCE.changeTrackColor(mTrack.getTrackId(), to);
Drawable circle = Graphics.drawCircle(to,
R.dimen.track_circle_size,
requireContext().getResources());
v.setImageDrawable(circle);
});
dialogFragment.show(requireActivity().getSupportFragmentManager(), null);
}
public void onItemMore(int position)
{
BookmarkListAdapter adapter = getBookmarkListAdapter();

View file

@ -20,6 +20,7 @@ import app.organicmaps.adapter.OnItemClickListener;
import app.organicmaps.bookmarks.data.BookmarkCategory;
import app.organicmaps.bookmarks.data.BookmarkInfo;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.bookmarks.data.IconClickListener;
import app.organicmaps.bookmarks.data.Track;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.util.Utils;
@ -388,6 +389,7 @@ public class Holders
private final TextView mName;
@NonNull
private final TextView mDistance;
private final ImageView mMoreButton;
TrackViewHolder(@NonNull View itemView)
{
@ -395,6 +397,7 @@ public class Holders
mIcon = itemView.findViewById(R.id.iv__bookmark_color);
mName = itemView.findViewById(R.id.tv__bookmark_name);
mDistance = itemView.findViewById(R.id.tv__bookmark_distance);
mMoreButton = itemView.findViewById(R.id.more);
}
@Override
@ -413,6 +416,16 @@ public class Holders
mIcon.getContext().getResources());
mIcon.setImageDrawable(circle);
}
public void setMoreButtonClickListener(RecyclerClickListener listener)
{
mMoreButton.setOnClickListener(v -> listener.onItemClick(v, getBindingAdapterPosition()));
}
public void setTrackIconClickListener(IconClickListener listener)
{
mIcon.setOnClickListener(v -> listener.onItemClick((ImageView) v, getBindingAdapterPosition()));
}
}
public static class SectionViewHolder extends BaseBookmarkHolder

View file

@ -631,11 +631,16 @@ public enum BookmarkManager
}
public void setTrackParams(@IntRange(from = 0) long trackId, @NonNull String name,
@Icon.PredefinedColor int color, @NonNull String descr)
int color, @NonNull String descr)
{
nativeSetTrackParams(trackId, name, color, descr);
}
public void changeTrackColor(@IntRange(from = 0) long trackId, int color)
{
nativeChangeTrackColor(trackId, color);
}
public void changeBookmarkCategory(@IntRange(from = 0) long oldCatId,
@IntRange(from = 0) long newCatId,
@IntRange(from = 0) long bookmarkId)
@ -867,6 +872,9 @@ public enum BookmarkManager
@Icon.PredefinedColor int color,
@NonNull String descr);
private static native void nativeChangeTrackColor(@IntRange(from = 0) long trackId,
@Icon.PredefinedColor int color);
private static native void nativeSetTrackParams(@IntRange(from = 0) long trackId,
@NonNull String name,
@Icon.PredefinedColor int color,

View file

@ -219,6 +219,16 @@ public class Icon implements Parcelable
return ARGB_COLORS[mColor];
}
public static int getColorPosition(int color)
{
for (int index = 1; index < ARGB_COLORS.length; index++)
{
if (ARGB_COLORS[index] == color)
return index;
}
return -1;
}
@BookmarkIconType
public int getType()
{

View file

@ -0,0 +1,8 @@
package app.organicmaps.bookmarks.data;
import android.widget.ImageView;
public interface IconClickListener
{
void onItemClick(ImageView v, int position);
}

View file

@ -24,7 +24,7 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment
private int mIconColor;
interface OnBookmarkColorChangeListener
public interface OnBookmarkColorChangeListener
{
void onBookmarkColorSet(int colorPos);
}
@ -42,7 +42,7 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment
return new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
.setView(buildView())
.setTitle(R.string.bookmark_color)
.setTitle(R.string.choose_color)
.setNegativeButton(R.string.cancel, null)
.create();
}

View file

@ -41,9 +41,10 @@ import java.util.List;
public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.OnClickListener, Listener
{
public static final String EXTRA_CATEGORY_ID = "CategoryId";
public static final String EXTRA_BOOKMARK_ID = "BookmarkId";
public static final String EXTRA_ID = "BookmarkTrackId";
public static final String EXTRA_BOOKMARK_TYPE = "BookmarkType";
public static final String EXTRA_TRACK_ID = "TrackId";
public static final int TYPE_BOOKMARK = 1;
public static final int TYPE_TRACK = 2;
private TextInputEditText mEtDescription;
private TextInputEditText mEtName;
@ -72,9 +73,9 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
@Nullable EditBookmarkListener listener)
{
final Bundle args = new Bundle();
args.putInt(EXTRA_BOOKMARK_TYPE, 1);
args.putInt(EXTRA_BOOKMARK_TYPE, TYPE_BOOKMARK);
args.putLong(EXTRA_CATEGORY_ID, categoryId);
args.putLong(EXTRA_BOOKMARK_ID, bookmarkId);
args.putLong(EXTRA_ID, bookmarkId);
String name = EditBookmarkFragment.class.getName();
final FragmentFactory factory = manager.getFragmentFactory();
final EditBookmarkFragment fragment = (EditBookmarkFragment) factory.instantiate(context.getClassLoader(), name);
@ -86,9 +87,9 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
public static void editTrack(long categoryId, long trackId, Context context, FragmentManager manager, @Nullable EditBookmarkListener listener)
{
final Bundle args = new Bundle();
args.putInt(EXTRA_BOOKMARK_TYPE, 2);
args.putInt(EXTRA_BOOKMARK_TYPE, TYPE_TRACK);
args.putLong(EXTRA_CATEGORY_ID, categoryId);
args.putLong(EXTRA_TRACK_ID, trackId);
args.putLong(EXTRA_ID, trackId);
String name = EditBookmarkFragment.class.getName();
final FragmentFactory factory = manager.getFragmentFactory();
final EditBookmarkFragment fragment = (EditBookmarkFragment) factory.instantiate(context.getClassLoader(), name);
@ -140,34 +141,28 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
mIvColor = view.findViewById(R.id.iv__bookmark_color);
mIvColor.setOnClickListener(this);
//For tracks an bookmarks same category is used so this portion is common for both
long categoryId = args.getLong(EXTRA_CATEGORY_ID);
mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId);
long id = args.getLong(EXTRA_ID);
switch (mType)
{
case 1:
case TYPE_BOOKMARK ->
{
long categoryId = args.getLong(EXTRA_CATEGORY_ID);
mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId);
long bookmarkId = args.getLong(EXTRA_BOOKMARK_ID);
mBookmark = BookmarkManager.INSTANCE.getBookmarkInfo(bookmarkId);
mBookmark = BookmarkManager.INSTANCE.getBookmarkInfo(id);
if (mBookmark != null)
mIcon = mBookmark.getIcon();
refreshBookmark();
initToolbar(view);
break;
}
case 2:
case TYPE_TRACK ->
{
long categoryId = args.getLong(EXTRA_CATEGORY_ID);
mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId);
long trackId = args.getLong(EXTRA_TRACK_ID);
mTrack = BookmarkManager.INSTANCE.getTrack(trackId);
mTrack = BookmarkManager.INSTANCE.getTrack(id);
mColor = mTrack.getColor();
refreshTrack();
initToolbar(view);
break;
}
}
initToolbar(view);
}
@Override
@ -195,13 +190,18 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
final ImageView imageView = toolbar.findViewById(R.id.save);
switch (mType)
{
case 1:
case TYPE_BOOKMARK ->
{
imageView.setOnClickListener(v -> saveBookmark());
case 2:
toolbar.setTitle(R.string.placepage_edit_bookmark_button);
}
case TYPE_TRACK ->
{
imageView.setOnClickListener(v -> saveTrack());
toolbar.setTitle(R.string.edit_track);
}
}
UiUtils.showHomeUpButton(toolbar);
toolbar.setTitle(R.string.placepage_edit_bookmark_button);
toolbar.setNavigationOnClickListener(v -> dismiss());
}
@ -233,10 +233,8 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
boolean movedFromCategory = mTrack.getCategoryId() != mBookmarkCategory.getId();
if (movedFromCategory)
BookmarkManager.INSTANCE.notifyCategoryChanging(mTrack, mBookmarkCategory.getId());
BookmarkManager.INSTANCE.notifyParametersUpdating(mTrack, mEtName.getText()
.toString(), mColor, mEtDescription.getText()
.toString());
BookmarkManager.INSTANCE.notifyParametersUpdating(mTrack, mEtName.getText().toString(),
mColor, mEtDescription.getText().toString());
if (mListener != null)
mListener.onBookmarkSaved(mTrack.getTrackId(), movedFromCategory);
dismiss();
@ -289,11 +287,10 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
dialogFragment.setArguments(args);
switch (mType)
{
case 1:
{
case TYPE_BOOKMARK ->
dialogFragment.setOnColorSetListener(colorPos -> {
final Icon newIcon = BookmarkManager.ICONS.get(colorPos);
final String from = mTrack.getName();
final String from = mIcon.getName();
final String to = newIcon.getName();
if (TextUtils.equals(from, to))
return;
@ -301,9 +298,7 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
mIcon = newIcon;
refreshColorMarker();
});
}
case 2:
{
case TYPE_TRACK ->
dialogFragment.setOnColorSetListener(colorPos -> {
int from = mTrack.getColor();
int to = BookmarkManager.ICONS.get(colorPos).argb();
@ -312,8 +307,6 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
mColor = to;
refreshTrackColor();
});
break;
}
}
dialogFragment.show(requireActivity().getSupportFragmentManager(), null);

View file

@ -2,6 +2,7 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_multiline"
android:background="@drawable/bg_clickable_card">
@ -9,13 +10,16 @@
android:id="@+id/iv__bookmark_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Editor.MetadataBlock.Clickable"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:paddingHorizontal="8dp"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginEnd="@dimen/margin_base" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toStartOf="@+id/more"
android:layout_toEndOf="@id/iv__bookmark_color"
android:orientation="vertical">
<TextView
@ -38,4 +42,14 @@
android:textAppearance="?fontBody2"
tools:text="@string/by_distance" />
</LinearLayout>
<ImageView
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:background="?selectableItemBackgroundBorderless"
android:paddingHorizontal="@dimen/margin_half"
app:srcCompat="@drawable/ic_more"
app:tint="?secondary"
android:importantForAccessibility="no" />
</RelativeLayout>

View file

@ -2262,4 +2262,6 @@
<string name="type.amenity.dojo">Dojo</string>
<!-- https://wiki.openstreetmap.org/wiki/Tag:leisure=sports_hall -->
<string name="type.leisure.sports_hall">Sports hall</string>
<string name="choose_color">Choose Color</string>
<string name="edit_track">Edit Track</string>
</resources>

View file

@ -2316,17 +2316,18 @@ void BookmarkManager::UpdateBookmark(kml::MarkId bmID, kml::BookmarkData const &
SetLastEditedBmColor(bookmark->GetColor());
}
void BookmarkManager::ChangeTrackColor(kml::TrackId trackId, uint32_t color)
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
auto * track = GetTrackForEdit(trackId);
track->SetColor(color);
}
void BookmarkManager::UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData)
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
auto * track = GetTrackForEdit(trackId);
// auto const prevColor = track->GetColor(0);
track->setData(trackData);
ASSERT(track->GetGroupId() != kml::kInvalidTrackId, ());
// if (prevColor != track->GetColor())
// SetLastEditedBmColor(track->GetColor());
}
kml::MarkGroupId BookmarkManager::LastEditedBMCategory()
@ -3654,6 +3655,11 @@ void BookmarkManager::EditSession::UpdateTrack(kml::TrackId trackId, kml::TrackD
return m_bmManager.UpdateTrack(trackId,trackData);
}
void BookmarkManager::EditSession::ChangeTrackColor(kml::TrackId trackId, uint32_t color)
{
m_bmManager.ChangeTrackColor(trackId, color);
}
void BookmarkManager::EditSession::AttachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId)
{
m_bmManager.AttachBookmark(bmId, groupId);

View file

@ -145,7 +145,6 @@ public:
void MoveBookmark(kml::MarkId bmID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID);
void UpdateBookmark(kml::MarkId bmId, kml::BookmarkData const & bm);
void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData);
void AttachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId);
void DetachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId);
@ -155,6 +154,8 @@ public:
void MoveTrack(kml::TrackId trackID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID);
void AttachTrack(kml::TrackId trackId, kml::MarkGroupId groupId);
void DetachTrack(kml::TrackId trackId, kml::MarkGroupId groupId);
void ChangeTrackColor(kml::TrackId trackId, uint32_t color);
void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData);
void SetCategoryName(kml::MarkGroupId categoryId, std::string const & name);
void SetCategoryDescription(kml::MarkGroupId categoryId, std::string const & desc);
@ -586,6 +587,8 @@ private:
void DetachTrack(kml::TrackId trackId, kml::MarkGroupId groupId);
void DeleteTrack(kml::TrackId trackId);
void MoveTrack(kml::TrackId trackID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID);
void ChangeTrackColor(kml::TrackId trackId, uint32_t color);
void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData);
void ClearGroup(kml::MarkGroupId groupId);
void SetIsVisible(kml::MarkGroupId groupId, bool visible);
@ -600,7 +603,6 @@ private:
void MoveBookmark(kml::MarkId bmID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID);
void UpdateBookmark(kml::MarkId bmId, kml::BookmarkData const & bm);
void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData);
UserMark const * GetMark(kml::MarkId markId) const;

View file

@ -237,6 +237,12 @@ void Track::SetColor(dp::Color color)
m_data.m_layers[0].m_color.m_rgba = color.GetRGBA();
}
void Track::SetColor(uint32_t color)
{
m_isDirty = true;
m_data.m_layers[0].m_color.m_rgba = color;
}
float Track::GetWidth(size_t layerIndex) const
{
CHECK_LESS(layerIndex, m_data.m_layers.size(), ());

View file

@ -55,6 +55,7 @@ public:
size_t GetLayerCount() const override;
dp::Color GetColor(size_t layerIndex) const override;
void SetColor(dp::Color color);
void SetColor(uint32_t color);
float GetWidth(size_t layerIndex) const override;
float GetDepth(size_t layerIndex) const override;
void ForEachGeometry(GeometryFnT && fn) const override;